[PATCH] D109718: [HIP] Diagnose -fopenmp-targets for HIP programs

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 13 12:58:10 PDT 2021


yaxunl created this revision.
yaxunl added a reviewer: tra.
Herald added a subscriber: guansong.
yaxunl requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

Diagnose -fopenmp-targets for HIP programs since dual HIP and OpenMP offloading in the same compilation
is currently not supported by HIP toolchain.


https://reviews.llvm.org/D109718

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/hip-options.hip


Index: clang/test/Driver/hip-options.hip
===================================================================
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -87,3 +87,15 @@
 // THINLTO-NOT: clang{{.*}}" "-triple" "amdgcn-amd-amdhsa" {{.*}} "-fwhole-program-vtables"
 // THINLTO: clang{{.*}}" "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-flto=thin" {{.*}} "-fwhole-program-vtables"
 // THINLTO-NOT: clang{{.*}}" "-triple" "amdgcn-amd-amdhsa" {{.*}} "-fwhole-program-vtables"
+
+// Check -fopenmp is allowed with HIP but -fopenmp-targets= is not allowed.
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --offload-arch=gfx906 -fopenmp %s 2>&1 | FileCheck -check-prefix=OMP %s
+// OMP-NOT: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} "-fopenmp"
+// OMP: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-fopenmp"
+
+// RUN: not %clang -target x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --offload-arch=gfx906 -fopenmp -fopenmp-targets=amdgcn %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=OMPTGT %s
+// OMPTGT: unsupported option '-fopenmp-targets='
Index: clang/lib/Driver/Driver.cpp
===================================================================
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -699,6 +699,11 @@
     }
     C.addOffloadDeviceToolChain(CudaTC.get(), OFK);
   } else if (IsHIP) {
+    if (auto *OMPTargetArg =
+            C.getInputArgs().getLastArg(options::OPT_fopenmp_targets_EQ)) {
+      Diag(clang::diag::err_drv_unsupported_opt) << OMPTargetArg->getSpelling();
+      return;
+    }
     const ToolChain *HostTC = C.getSingleOffloadToolChain<Action::OFK_Host>();
     const llvm::Triple &HostTriple = HostTC->getTriple();
     auto OFK = Action::OFK_HIP;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109718.372330.patch
Type: text/x-patch
Size: 1800 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210913/2570e299/attachment.bin>


More information about the cfe-commits mailing list