Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,27 @@ set(CUDF_CUDA_FLAGS "")
set(CUDF_CXX_DEFINITIONS "")
set(CUDF_CUDA_DEFINITIONS "")

# LTO IR can only be linked for targets greater than or equal to its architecture. An explicit
# override must therefore not exceed the architecture of any target GPU on which it will be linked.
set(CUDF_LTO_ARCHITECTURE
""
CACHE STRING "LTO fragment architecture; empty selects the minimum supported by the toolkit"
)

if(CUDF_LTO_ARCHITECTURE STREQUAL "")
foreach(architecture IN LISTS CMAKE_CUDA_ARCHITECTURES_ALL)
string(REGEX MATCH "^[0-9]+" architecture "${architecture}")
if(architecture AND (NOT CUDF_LTO_ARCHITECTURE OR architecture LESS CUDF_LTO_ARCHITECTURE))
set(CUDF_LTO_ARCHITECTURE "${architecture}")
endif()
endforeach()
endif()

if(NOT CUDF_LTO_ARCHITECTURE MATCHES "^[0-9]+$")
message(FATAL_ERROR "CUDF_LTO_ARCHITECTURE must be a numeric architecture")
endif()
Comment thread
coderabbitai[bot] marked this conversation as resolved.
message(VERBOSE "CUDF: Using ${CUDF_LTO_ARCHITECTURE} as the common LTO architecture")

# For now, disable CMake's automatic module scanning for C++ files. There is an sccache bug in the
# version RAPIDS uses in CI that causes it to handle the resulting -M* flags incorrectly with
# gcc>=14. We can remove this once we upgrade to a newer sccache version.
Expand Down Expand Up @@ -431,6 +452,9 @@ if(NOT BUILD_SHARED_LIBS)
endif()
endif()

# ##################################################################################################
# * JIT embedding ----------------------------------------------------------------------------------

rtcx_add_embed(cudf_cuda_embed)

rtcx_embed_includes(
Expand Down Expand Up @@ -1218,8 +1242,10 @@ target_include_directories(
)

target_compile_definitions(
cudf PUBLIC "$<$<COMPILE_LANGUAGE:CXX>:${CUDF_CXX_DEFINITIONS}>"
"$<BUILD_INTERFACE:$<$<COMPILE_LANGUAGE:CUDA>:${CUDF_CUDA_DEFINITIONS}>>"
cudf
PUBLIC "$<$<COMPILE_LANGUAGE:CXX>:${CUDF_CXX_DEFINITIONS}>"
"$<BUILD_INTERFACE:$<$<COMPILE_LANGUAGE:CUDA>:${CUDF_CUDA_DEFINITIONS}>>"
"CUDF_LTO_ARCHITECTURE=${CUDF_LTO_ARCHITECTURE}"
)

# Per-thread default stream
Expand Down
1 change: 1 addition & 0 deletions cpp/cmake/Modules/AddFragment.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ macro(add_fragment)
CUDA_STANDARD 20
CUDA_STANDARD_REQUIRED ON
CUDA_VISIBILITY_PRESET hidden
CUDA_ARCHITECTURES ${CUDF_LTO_ARCHITECTURE}
)
target_link_libraries(
${OBJECT_ID}
Expand Down
17 changes: 8 additions & 9 deletions cpp/src/jit/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ constexpr int32_t MIN_NVRTC_VERSION_PCH =
make_cuda_version(12, 8, 0); // minimum CUDA version for the "--pch" NVRTC flag
constexpr int32_t MIN_NVRTC_VERSION_MINIMAL =
make_cuda_version(12, 8, 0); // minimum CUDA version for the "--minimal" NVRTC flag
constexpr int32_t LTO_ARCHITECTURE =
CUDF_LTO_ARCHITECTURE; // target architecture for LTO IR compilation

std::tuple<rtcx::library, rtcx::blob> compile_library(
char const* name,
Expand Down Expand Up @@ -293,11 +295,9 @@ rtcx::blob compile_fragment(char const* name,
{
CUDF_FUNC_RANGE();

auto& ctx = cudf::get_context();
auto& cfg = ctx.config();
auto& bundle = ctx.jit_bundle();
auto& device_properties = ctx.get_device_properties();
auto sm = device_properties.compute_capability;
auto& ctx = cudf::get_context();
auto& cfg = ctx.config();
auto& bundle = ctx.jit_bundle();

auto include_dirs = bundle.get_include_directories();
auto pch_dir = ctx.get_jit_pch_dir();
Expand All @@ -313,12 +313,12 @@ rtcx::blob compile_fragment(char const* name,
options.emplace_back(std::format("-I{}", include_dir));
}

options.emplace_back(std::format("--gpu-architecture=sm_{}", sm));
options.emplace_back(std::format("--gpu-architecture=sm_{}", LTO_ARCHITECTURE));

options.emplace_back("--diag-suppress=47");
options.emplace_back("--device-int128");

if (sm >= 100) { options.emplace_back("--device-float128"); }
if (LTO_ARCHITECTURE >= 100) { options.emplace_back("--device-float128"); }

options.emplace_back("-std=c++20");
options.emplace_back("--device-as-default-execution-space");
Expand Down Expand Up @@ -446,7 +446,6 @@ rtcx::blob get_kernel_fragment(std::string const& name,
auto& device_properties = ctx.get_device_properties();
auto runtime = device_properties.runtime_version;
auto driver = device_properties.driver_version;
auto sm = device_properties.compute_capability;
auto bundle_hash = bundle.get_hash();

auto source_file = std::format("{}/{}", bundle.get_directory(), source_file_id);
Expand All @@ -464,7 +463,7 @@ kernel_instance={}
name,
runtime,
driver,
sm,
LTO_ARCHITECTURE,
bundle_hash,
source_file,
kernel_instance);
Expand Down
Loading