[Openmp-commits] [PATCH] D101663: [OpenMP] Avoid unintentional use of host compiler as bclib compiler.
Michael Kruse via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Fri Apr 30 13:50:53 PDT 2021
Meinersbur created this revision.
Meinersbur added reviewers: tianshilei1992, jdoerfert, protze.joachim.
Meinersbur added a project: OpenMP.
Herald added subscribers: guansong, yaxunl, mgorny.
Meinersbur requested review of this revision.
Herald added subscribers: llvm-commits, sstefan1.
Herald added a project: LLVM.
Before this patch, libomptarget assumed that if the host compiler is clang, then it is also suitable for compile CUDA to LLVM-IR. The intention was that if libomptarget is compiled using `LLVM_ENABLE_RUMTIMES=openmp`, the host compiler will be clang from the same propository.
However, the host compiler may also be clang when compiling as a `LLVM_ENABLE_PROJECTS=openmp` or standalone build if the user explicitly set the tool chain or, clang is the system's default compiler (MacOS, most BSDs). Various vendor compilers such as Apple's clang, Intel's dpcpp/icx, IBM's xlclang, etc. may be identified as 'clang' by CMake. However, these potentially use an incompatible IR, or stripped CUDA support, with unpredictable results.
Fix by explicitly set LIBOMPTARGET_NVPTX_CUDA_COMPILER (and LIBOMPTARGET_NVPTX_BC_LINKER) when using `LLVM_ENABLE_RUMTIMES=openmp` and do not try to use the host compiler.
Implementation of discussion in D101265 <https://reviews.llvm.org/D101265>. Compilation result: http://meinersbur.de:8011/#/builders/143/builds/375
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D101663
Files:
llvm/runtimes/CMakeLists.txt
openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
Index: openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
===================================================================
--- openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
+++ openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
@@ -33,15 +33,6 @@
elseif (LLVM_TOOL_CLANG_BUILD AND NOT CMAKE_CROSSCOMPILING)
# Compile the deviceRTL with the clang that is built in the project.
set(cuda_compiler "$<TARGET_FILE:clang>")
-elseif(${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
- # Compile the device runtime with the compiler that OpenMP is built with.
- # This is the case with LLVM_ENABLE_RUNTIMES=openmp.
- # FIXME: This is unreliable; the compiler can be on older version of clang
- # that does not support compiling CUDA, or only an older version of it. The
- # risk is especially high on sytems where clang is the default compiler
- # (MacOS, BSDs). LLVM_ENABLE_RUNTIMES=openmp should itself set
- # LIBOMPTARGET_NVPTX_CUDA_COMPILER instead.
- set(cuda_compiler ${CMAKE_C_COMPILER})
else()
libomptarget_say("Not building NVPTX deviceRTL: clang not found")
return()
Index: llvm/runtimes/CMakeLists.txt
===================================================================
--- llvm/runtimes/CMakeLists.txt
+++ llvm/runtimes/CMakeLists.txt
@@ -235,6 +235,8 @@
-DCMAKE_C_COMPILER_WORKS=ON
-DCMAKE_CXX_COMPILER_WORKS=ON
-DCMAKE_ASM_COMPILER_WORKS=ON
+ -DLIBOMPTARGET_NVPTX_CUDA_COMPILER=$<TARGET_FILE:clang>
+ -DLIBOMPTARGET_NVPTX_BC_LINKER=$<TARGET_FILE:llvm-link>
${RUNTIMES_CMAKE_ARGS}
PASSTHROUGH_PREFIXES LLVM_ENABLE_RUNTIMES
${ARG_PREFIXES}
@@ -335,6 +337,8 @@
-DCMAKE_C_COMPILER_WORKS=ON
-DCMAKE_CXX_COMPILER_WORKS=ON
-DCMAKE_ASM_COMPILER_WORKS=ON
+ -DLIBOMPTARGET_NVPTX_CUDA_COMPILER=$<TARGET_FILE:clang>
+ -DLIBOMPTARGET_NVPTX_BC_LINKER=$<TARGET_FILE:llvm-link>
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
-DLLVM_RUNTIMES_TARGET=${name}
${${name}_extra_args}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101663.342024.patch
Type: text/x-patch
Size: 2498 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210430/395dc1c5/attachment.bin>
More information about the Openmp-commits
mailing list