[Openmp-commits] [openmp] dbb6344 - [Libomptarget] Add the CUDA feature to the packager

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Thu Feb 23 11:25:38 PST 2023


Author: Joseph Huber
Date: 2023-02-23T13:25:27-06:00
New Revision: dbb6344b26ae29d44ddc8d943ad1c061deb70e6a

URL: https://github.com/llvm/llvm-project/commit/dbb6344b26ae29d44ddc8d943ad1c061deb70e6a
DIFF: https://github.com/llvm/llvm-project/commit/dbb6344b26ae29d44ddc8d943ad1c061deb70e6a.diff

LOG: [Libomptarget] Add the CUDA feature to the packager

Summary:
Internally we need to know the feature that was used to build the CUDA.
This used to be added when the deviceRTL was build via the OpenMP
interface, but ever since it was moved to call the packager explicitly
it was not being added. This causes failured if the user attempts to use
the library without LTO enabled.

Added: 
    

Modified: 
    openmp/libomptarget/DeviceRTL/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/DeviceRTL/CMakeLists.txt b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
index 49b398c9f7659..6844e885fa6d0 100644
--- a/openmp/libomptarget/DeviceRTL/CMakeLists.txt
+++ b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
@@ -123,7 +123,7 @@ set (LIBOMPTARGET_LLVM_INCLUDE_DIRS_DEVICERTL "${LIBOMPTARGET_LLVM_INCLUDE_DIRS}
 list(TRANSFORM LIBOMPTARGET_LLVM_INCLUDE_DIRS_DEVICERTL PREPEND "-I")
 
 # Set flags for LLVM Bitcode compilation.
-set(bc_flags -c -emit-llvm -std=c++17 -fvisibility=hidden
+set(bc_flags -c -foffload-lto -std=c++17 -fvisibility=hidden
               ${clang_opt_flags} --offload-device-only
              -nocudalib -nogpulib -nostdinc
              -fopenmp -fopenmp-cuda-mode
@@ -234,10 +234,15 @@ function(compileDeviceRTLLibrary target_cpu target_name target_triple)
       APPEND)
   endif()
 
+  set(target_feature "")
+  if("${target_triple}" STREQUAL "nvptx64-nvidia-cuda")
+    set(target_feature "feature=+ptx61")
+  endif()
+
   # Package the bitcode in the bitcode and embed it in an ELF for the static library
   add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/packaged_${bclib_name}
       COMMAND ${PACKAGER_TOOL} -o ${CMAKE_CURRENT_BINARY_DIR}/packaged_${bclib_name}
-        "--image=file=${CMAKE_CURRENT_BINARY_DIR}/extracted_${bclib_name},triple=${target_triple},arch=${target_cpu},kind=openmp"
+        "--image=file=${CMAKE_CURRENT_BINARY_DIR}/extracted_${bclib_name},${target_feature},triple=${target_triple},arch=${target_cpu},kind=openmp"
       DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/extracted_${bclib_name}
       COMMENT "Packaging LLVM offloading binary ${bclib_name}.out"
   )


        


More information about the Openmp-commits mailing list