[Openmp-commits] [PATCH] D97012: [OpenMP] Fix nvptx CUDA_VERSION conversion

Joel E. Denny via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Feb 18 17:15:21 PST 2021

jdenny created this revision.
jdenny added reviewers: tianshilei1992, grokos, jdoerfert, RaviNarayanaswamy.
Herald added subscribers: guansong, yaxunl, mgorny.
jdenny requested review of this revision.
Herald added a subscriber: sstefan1.
Herald added a project: OpenMP.

As mentioned in PR#49250, without this patch, ptxas for CUDA 9.1 fails
in the following two tests:

- openmp/libomptarget/test/mapping/lambda_mapping.cpp
- openmp/libomptarget/test/offloading/bug49021.cpp

The error looks like:

  ptxas /tmp/lambda_mapping-081ea9.s, line 828; error   : Not a name of any known instruction: 'activemask'

The problem is that our cmake script converts CUDA version strings
incorrectly: 9.1 becomes 9100, but it should be 9010, as shown in
`getCudaVersion` in `clang/lib/Driver/ToolChains/Cuda.cpp`.  Thus,
inadvertently enables `activemask` because it apparently becomes
available in 9.2.  This patch fixes the conversion.

This patch does not fix the other two tests in PR#49250.

  rG LLVM Github Monorepo



Index: openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
--- openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
+++ openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
@@ -172,7 +172,14 @@
     list(GET ptx_feature_list ${itr} ptx_num)
     set(cuda_flags ${sm_flags})
     list(APPEND cuda_flags -Xclang -target-feature -Xclang +ptx${ptx_num})
-    list(APPEND cuda_flags "-DCUDA_VERSION=${cuda_version}00")
+    if("${cuda_version}" MATCHES "^([0-9]+)([0-9])$")
+      set(cuda_version_major ${CMAKE_MATCH_1})
+      set(cuda_version_minor ${CMAKE_MATCH_2})
+    else()
+      message(FATAL_ERROR "Unrecognized CUDA version format: ${cuda_version}")
+    endif()
+    list(APPEND cuda_flags
+      "-DCUDA_VERSION=${cuda_version_major}0${cuda_version_minor}0")
     set(bc_files "")
     foreach(src ${cuda_src_files})

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97012.324820.patch
Type: text/x-patch
Size: 894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210219/a23d93f7/attachment.bin>

More information about the Openmp-commits mailing list