[PATCH] D22895: [OpenMP][CUDA] Do not forward OpenMP flags for CUDA device actions.
Samuel Antao via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 27 17:40:08 PDT 2016
sfantao created this revision.
sfantao added reviewers: ABataev, hfinkel, carlo.bertolli, arpith-jacob, kkwli0, tra.
sfantao added subscribers: cfe-commits, caomhin.
This patch prevents OpenMP flags from being forwarded to CUDA device commands. That was causing the CUDA frontend to attempt to emit OpenMP code which is not supported.
https://reviews.llvm.org/D22895
Files:
lib/Driver/Tools.cpp
test/Driver/offloading-interoperability.c
Index: test/Driver/offloading-interoperability.c
===================================================================
--- /dev/null
+++ test/Driver/offloading-interoperability.c
@@ -0,0 +1,17 @@
+// REQUIRES: clang-driver
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
+//
+// Verify that CUDA device commands do not get OpenMP flags.
+//
+// RUN: %clang -### -x cuda -target powerpc64le-linux-gnu -std=c++11 --cuda-gpu-arch=sm_35 -fopenmp %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix NO-OPENMP-FLAGS-FOR-CUDA-DEVICE
+//
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE: clang{{.*}}" "-cc1" "-triple" "nvptx64-nvidia-cuda"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NOT: -fopenmp
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ptxas" "-m64"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: fatbinary" "--cuda" "-64"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux-gnu"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE: -fopenmp
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ld" "-z" "relro" "--hash-style=gnu" "--eh-frame-hdr" "-m" "elf64lppc"
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5049,9 +5049,13 @@
Args.AddLastArg(CmdArgs, options::OPT_fdiagnostics_show_template_tree);
Args.AddLastArg(CmdArgs, options::OPT_fno_elide_type);
- // Forward flags for OpenMP
+ // Forward flags for OpenMP. We don't do this if the current action is an
+ // device offloading action.
+ //
+ // TODO: Allow OpenMP offload actions when they become available.
if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
- options::OPT_fno_openmp, false)) {
+ options::OPT_fno_openmp, false) &&
+ JA.isDeviceOffloading(Action::OFK_None)) {
switch (getOpenMPRuntime(getToolChain(), Args)) {
case OMPRT_OMP:
case OMPRT_IOMP5:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22895.65847.patch
Type: text/x-patch
Size: 1931 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160728/82b5b172/attachment.bin>
More information about the cfe-commits
mailing list