Skip to content

Commit 2704eba

Browse files
authored
[flang][runtime] Create CUDA PTX OBJECT library target for F18 runtime CUDA build. (#88821)
This is to experiment with distributing F18 runtime CUDA library in the form of a pure PTX library. The change is under FLANG_EXPERIMENTAL_CUDA_RUNTIME CMake control.
1 parent 9d11128 commit 2704eba

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

flang/cmake/modules/AddFlangOffloadRuntime.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ set(FLANG_EXPERIMENTAL_OMP_OFFLOAD_BUILD "off" CACHE STRING
1010
set(FLANG_OMP_DEVICE_ARCHITECTURES "all" CACHE STRING
1111
"List of OpenMP device architectures to be used to compile the Fortran runtime (e.g. 'gfx1103;sm_90')")
1212

13-
macro(enable_cuda_compilation files)
13+
macro(enable_cuda_compilation name files)
1414
if (FLANG_EXPERIMENTAL_CUDA_RUNTIME)
1515
if (BUILD_SHARED_LIBS)
1616
message(FATAL_ERROR
@@ -52,6 +52,10 @@ macro(enable_cuda_compilation files)
5252
include_directories(AFTER ${FLANG_LIBCUDACXX_PATH}/include)
5353
add_compile_definitions(RT_USE_LIBCUDACXX=1)
5454
endif()
55+
56+
# Add an OBJECT library consisting of CUDA PTX.
57+
llvm_add_library(${name}PTX OBJECT PARTIAL_SOURCES_INTENDED ${files})
58+
set_property(TARGET obj.${name}PTX PROPERTY CUDA_PTX_COMPILATION ON)
5559
endif()
5660
endmacro()
5761

flang/lib/Decimal/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ set(sources
5555
)
5656

5757
include(AddFlangOffloadRuntime)
58-
enable_cuda_compilation("${sources}")
58+
enable_cuda_compilation(FortranDecimal "${sources}")
5959
enable_omp_offload_compilation("${sources}")
6060

6161
add_flang_library(FortranDecimal INSTALL_WITH_TOOLCHAIN ${sources})

flang/runtime/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ set(supported_files
224224
utf.cpp
225225
)
226226

227-
enable_cuda_compilation("${supported_files}")
227+
enable_cuda_compilation(FortranRuntime "${supported_files}")
228228
enable_omp_offload_compilation("${supported_files}")
229229

230230
if (NOT TARGET FortranFloat128Math)

0 commit comments

Comments
 (0)