aarch64 openmp offloading support

Hello all,

Are there any known issues with OpenMP offloading to aarch64? The latest "OpenMP Support" documentation indicates that it should work: "Clang supports offloading to X86_64, AArch64, PPC64[LE] ..." (https://clang.llvm.org/docs/OpenMPSupport.html).

But when I try it (using an 8.0.0 development build), the "-fopenmp-targets" option accepts x86_64 and ppc64, but not aarch64:

$ clang -fopenmp -fopenmp-targets=x86_64 -c hello.c
$ clang -fopenmp -fopenmp-targets=ppc64 -c hello.c
$ clang -fopenmp -fopenmp-targets=aarch64 -c hello.c
error: OpenMP target is invalid: 'aarch64'

I can get it to work with a very simple change:

--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -2679,7 +2679,8 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
             TT.getArch() == llvm::Triple::nvptx ||
             TT.getArch() == llvm::Triple::nvptx64 ||
             TT.getArch() == llvm::Triple::x86 ||
- TT.getArch() == llvm::Triple::x86_64))
+ TT.getArch() == llvm::Triple::x86_64 ||
+ TT.getArch() == llvm::Triple::aarch64))
         Diags.Report(diag::err_drv_invalid_omp_target) << A->getValue(i);
       else
         Opts.OMPTargetTriples.push_back(TT);

I haven't done extensive testing, but my simple "hello world" test case now works. Before pursuing this further, does anyone foresee any issues with this change?

Thanks,
Jeff

Hello all,

Are there any known issues with OpenMP offloading to aarch64? The latest "OpenMP Support" documentation indicates that it should work: "Clang supports offloading to X86_64, AArch64, PPC64[LE] ..." (https://clang.llvm.org/docs/OpenMPSupport.html).

But when I try it (using an 8.0.0 development build), the "-fopenmp-targets" option accepts x86_64 and ppc64, but not aarch64:

$ clang -fopenmp -fopenmp-targets=x86_64 -c hello.c
$ clang -fopenmp -fopenmp-targets=ppc64 -c hello.c
$ clang -fopenmp -fopenmp-targets=aarch64 -c hello.c
error: OpenMP target is invalid: 'aarch64'

I can get it to work with a very simple change:

--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -2679,7 +2679,8 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
             TT.getArch() == llvm::Triple::nvptx ||
             TT.getArch() == llvm::Triple::nvptx64 ||
             TT.getArch() == llvm::Triple::x86 ||
- TT.getArch() == llvm::Triple::x86_64))
+ TT.getArch() == llvm::Triple::x86_64 ||
+ TT.getArch() == llvm::Triple::aarch64))
         Diags.Report(diag::err_drv_invalid_omp_target) << A->getValue(i);
       else
         Opts.OMPTargetTriples.push_back(TT);

I haven't done extensive testing, but my simple "hello world" test case now works. Before pursuing this further, does anyone foresee any issues with this change?

Seems right for me. libomptarget has an aarch64 configuration for the
host plugin, and I think that all such targets need to be in this list.

-Hal