[flang-commits] [flang] [flang][runtime] Create CUDA PTX OBJECT library target for F18 runtime CUDA build. (PR #88821)
Slava Zakharin via flang-commits
flang-commits at lists.llvm.org
Mon Apr 15 17:18:23 PDT 2024
https://github.com/vzakhari created https://github.com/llvm/llvm-project/pull/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.
>From fefde0d92e06a07e002280c864cba4a359a2052a Mon Sep 17 00:00:00 2001
From: Slava Zakharin <szakharin at nvidia.com>
Date: Mon, 15 Apr 2024 16:48:40 -0700
Subject: [PATCH] [flang][runtime] Create CUDA PTX OBJECT library target for
F18 runtime CUDA build.
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.
---
flang/cmake/modules/AddFlangOffloadRuntime.cmake | 6 +++++-
flang/lib/Decimal/CMakeLists.txt | 2 +-
flang/runtime/CMakeLists.txt | 2 +-
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/flang/cmake/modules/AddFlangOffloadRuntime.cmake b/flang/cmake/modules/AddFlangOffloadRuntime.cmake
index 6fb6213e90fc49..e34d3851187acf 100644
--- a/flang/cmake/modules/AddFlangOffloadRuntime.cmake
+++ b/flang/cmake/modules/AddFlangOffloadRuntime.cmake
@@ -10,7 +10,7 @@ set(FLANG_EXPERIMENTAL_OMP_OFFLOAD_BUILD "off" CACHE STRING
set(FLANG_OMP_DEVICE_ARCHITECTURES "all" CACHE STRING
"List of OpenMP device architectures to be used to compile the Fortran runtime (e.g. 'gfx1103;sm_90')")
-macro(enable_cuda_compilation files)
+macro(enable_cuda_compilation name files)
if (FLANG_EXPERIMENTAL_CUDA_RUNTIME)
if (BUILD_SHARED_LIBS)
message(FATAL_ERROR
@@ -52,6 +52,10 @@ macro(enable_cuda_compilation files)
include_directories(AFTER ${FLANG_LIBCUDACXX_PATH}/include)
add_compile_definitions(RT_USE_LIBCUDACXX=1)
endif()
+
+ # Add an OBJECT library consisting of CUDA PTX.
+ llvm_add_library(${name}PTX OBJECT PARTIAL_SOURCES_INTENDED ${files})
+ set_property(TARGET obj.${name}PTX PROPERTY CUDA_PTX_COMPILATION ON)
endif()
endmacro()
diff --git a/flang/lib/Decimal/CMakeLists.txt b/flang/lib/Decimal/CMakeLists.txt
index 3d562b8e3ce1e5..880b190f1c5815 100644
--- a/flang/lib/Decimal/CMakeLists.txt
+++ b/flang/lib/Decimal/CMakeLists.txt
@@ -55,7 +55,7 @@ set(sources
)
include(AddFlangOffloadRuntime)
-enable_cuda_compilation("${sources}")
+enable_cuda_compilation(FortranDecimal "${sources}")
enable_omp_offload_compilation("${sources}")
add_flang_library(FortranDecimal INSTALL_WITH_TOOLCHAIN ${sources})
diff --git a/flang/runtime/CMakeLists.txt b/flang/runtime/CMakeLists.txt
index 2a65a22ab674c4..bdd0e07bbfd4d1 100644
--- a/flang/runtime/CMakeLists.txt
+++ b/flang/runtime/CMakeLists.txt
@@ -224,7 +224,7 @@ set(supported_files
utf.cpp
)
-enable_cuda_compilation("${supported_files}")
+enable_cuda_compilation(FortranRuntime "${supported_files}")
enable_omp_offload_compilation("${supported_files}")
if (NOT TARGET FortranFloat128Math)
More information about the flang-commits
mailing list