Skip to content

Commit ef8b3b5

Browse files
committed
[OpenMP] Fix nvptx CUDA_VERSION conversion
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, `openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu` 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. Reviewed By: tianshilei1992 Differential Revision: https://reviews.llvm.org/D97012
1 parent d2147b1 commit ef8b3b5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,15 @@ foreach(sm ${nvptx_sm_list})
172172
list(GET ptx_feature_list ${itr} ptx_num)
173173
set(cuda_flags ${sm_flags})
174174
list(APPEND cuda_flags -Xclang -target-feature -Xclang +ptx${ptx_num})
175-
list(APPEND cuda_flags "-DCUDA_VERSION=${cuda_version}00")
175+
if("${cuda_version}" MATCHES "^([0-9]+)([0-9])$")
176+
set(cuda_version_major ${CMAKE_MATCH_1})
177+
set(cuda_version_minor ${CMAKE_MATCH_2})
178+
else()
179+
libomptarget_error_say(
180+
"Unrecognized CUDA version format: ${cuda_version}")
181+
endif()
182+
list(APPEND cuda_flags
183+
"-DCUDA_VERSION=${cuda_version_major}0${cuda_version_minor}0")
176184

177185
set(bc_files "")
178186
foreach(src ${cuda_src_files})

0 commit comments

Comments
 (0)