[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

Gheorghe-Teodor Bercea via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 28 08:34:16 PDT 2017


gtbercea updated this revision to Diff 93244.
gtbercea added a comment.
Herald added a subscriber: rengolin.

Update patch to reflect latest source code changes.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload.c


Index: test/Driver/openmp-offload.c
===================================================================
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -636,6 +636,16 @@
 
 /// ###########################################################################
 
+/// Check PTXAS is passed the compute capability passed to the driver.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda --fopenmp-ptx=+ptx52 -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTX %s
+
+// CHK-PTX: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTX-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTX-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+
+/// ###########################################################################
+
 /// Check that CLANG forwards the -v flag to PTXAS.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes -v %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-VERBOSE %s
Index: lib/Driver/ToolChains/Cuda.cpp
===================================================================
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -492,8 +492,18 @@
   // than LLVM defaults to. Use PTX4.2 which is the PTX version that
   // came with CUDA-7.0.
   CC1Args.push_back("-target-feature");
+
+  StringRef PtxVersion = DriverArgs.getLastArgValue(
+        options::OPT_fopenmp_ptx_EQ);
+
   CC1Args.push_back("+ptx42");
 
+  if (DeviceOffloadingKind == Action::OFK_OpenMP &&
+      !PtxVersion.empty()) {
+    // Use PTX version passed to the driver.
+    CC1Args.back() = PtxVersion.data();
+  }
+
   if (DeviceOffloadingKind == Action::OFK_OpenMP) {
     SmallVector<std::string, 8> LibraryPaths;
     if (char *Env = ::getenv("LIBRARY_PATH")) {
Index: include/clang/Driver/Options.td
===================================================================
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -529,6 +529,8 @@
   HelpText<"CUDA installation path">;
 def fopenmp_cuda_gpu_arch_EQ : Joined<["--"], "fopenmp-cuda-gpu-arch=">, Flags<[DriverOption]>,
   HelpText<"Pass a single CUDA GPU architecture (default sm_20) to be used by OpenMP device offloading.">;
+def fopenmp_ptx_EQ : Joined<["--"], "fopenmp-ptx=">, Flags<[DriverOption]>,
+  HelpText<"Pass a PTX version +ptxXX, default +ptx42 (for PTX version 4.2) used by OpenMP device offloading.">;
 def ptxas_path_EQ : Joined<["--"], "ptxas-path=">, Group<i_Group>,
   HelpText<"Path to ptxas (used for compiling CUDA code)">;
 def fcuda_flush_denormals_to_zero : Flag<["-"], "fcuda-flush-denormals-to-zero">,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29660.93244.patch
Type: text/x-patch
Size: 2687 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170328/bdb34738/attachment.bin>


More information about the cfe-commits mailing list