Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove code paths that depend on RMM_STATIC_CUDART #1667

Open
wants to merge 4 commits into
base: branch-24.10
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ target_include_directories(rmm INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOUR
if(CUDA_STATIC_RUNTIME)
message(STATUS "RMM: Enabling static linking of cudart")
target_link_libraries(rmm INTERFACE CUDA::cudart_static)
target_compile_definitions(rmm INTERFACE RMM_STATIC_CUDART)
else()
target_link_libraries(rmm INTERFACE CUDA::cudart)
endif()
Expand Down
28 changes: 6 additions & 22 deletions include/rmm/detail/dynamic_load_runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,18 @@ struct dynamic_load_runtime {
template <typename signature>
static std::optional<signature> function(const char* func_name)
{
auto* runtime = get_cuda_runtime_handle();
auto* handle = ::dlsym(runtime, func_name);
// query if the function has already been loaded
auto* handle = ::dlsym(RTLD_DEFAULT, func_name);
if (!handle) {
auto* runtime = get_cuda_runtime_handle();
handle = ::dlsym(runtime, func_name);
}
if (!handle) { return std::nullopt; }
auto* function_ptr = reinterpret_cast<signature>(handle);
return std::optional<signature>(function_ptr);
}
};

#if defined(RMM_STATIC_CUDART)
// clang-format off
#define RMM_CUDART_API_WRAPPER(name, signature) \
template <typename... Args> \
static cudaError_t name(Args... args) \
{ \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Waddress\"") \
static_assert(static_cast<signature>(::name), \
"Failed to find #name function with arguments #signature"); \
_Pragma("GCC diagnostic pop") \
return ::name(args...); \
}
// clang-format on
#else
#define RMM_CUDART_API_WRAPPER(name, signature) \
template <typename... Args> \
static cudaError_t name(Args... args) \
Expand All @@ -100,7 +89,6 @@ struct dynamic_load_runtime {
if (func) { return (*func)(args...); } \
RMM_FAIL("Failed to find #name function in libcudart.so"); \
}
#endif

#if CUDART_VERSION >= 11020 // 11.2 introduced cudaMallocAsync
/**
Expand All @@ -113,14 +101,10 @@ struct dynamic_load_runtime {
struct async_alloc {
static bool is_supported()
{
#if defined(RMM_STATIC_CUDART)
static bool runtime_supports_pool = (CUDART_VERSION >= 11020);
#else
static bool runtime_supports_pool =
dynamic_load_runtime::function<dynamic_load_runtime::function_sig<void*, cudaStream_t>>(
"cudaFreeAsync")
.has_value();
#endif

static auto driver_supports_pool{[] {
int cuda_pool_supported{};
Expand Down
19 changes: 16 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function(ConfigureTestInternal TEST_NAME)
add_executable(${TEST_NAME} ${ARGN})
target_include_directories(${TEST_NAME} PRIVATE "$<BUILD_INTERFACE:${RMM_SOURCE_DIR}>")
target_link_libraries(${TEST_NAME} GTest::gmock GTest::gtest GTest::gmock_main GTest::gtest_main
pthread rmm)
pthread)
set_target_properties(
${TEST_NAME}
PROPERTIES POSITION_INDEPENDENT_CODE ON
Expand Down Expand Up @@ -82,7 +82,7 @@ endfunction()
function(ConfigureTest TEST_NAME)

set(options)
set(one_value GPUS PERCENT)
set(one_value CUDART GPUS PERCENT)
set(multi_value)
cmake_parse_arguments(_RMM_TEST "${options}" "${one_value}" "${multi_value}" ${ARGN})
if(NOT DEFINED _RMM_TEST_GPUS AND NOT DEFINED _RMM_TEST_PERCENT)
Expand All @@ -96,13 +96,23 @@ function(ConfigureTest TEST_NAME)
set(_RMM_TEST_PERCENT 100)
endif()

if(_RMM_TEST_CUDART STREQUAL SHARED)
set(cudart_link_libs $<COMPILE_ONLY:rmm> CUDA::cudart)
elseif(_RMM_TEST_CUDART STREQUAL STATIC)
set(cudart_link_libs $<COMPILE_ONLY:rmm> CUDA::cudart_static)
else()
set(cudart_link_libs rmm)
endif()

# Test with legacy default stream.
ConfigureTestInternal(${TEST_NAME} ${_RMM_TEST_UNPARSED_ARGUMENTS})
target_link_libraries(${TEST_NAME} ${cudart_link_libs})

# Test with per-thread default stream.
string(REGEX REPLACE "_TEST$" "_PTDS_TEST" PTDS_TEST_NAME "${TEST_NAME}")
ConfigureTestInternal("${PTDS_TEST_NAME}" ${_RMM_TEST_UNPARSED_ARGUMENTS})
target_compile_definitions("${PTDS_TEST_NAME}" PUBLIC CUDA_API_PER_THREAD_DEFAULT_STREAM)
target_link_libraries(${PTDS_TEST_NAME} ${cudart_link_libs})

foreach(name ${TEST_NAME} ${PTDS_TEST_NAME} ${NS_TEST_NAME})
rapids_test_add(
Expand All @@ -128,7 +138,10 @@ ConfigureTest(ADAPTOR_TEST mr/device/adaptor_tests.cpp)
ConfigureTest(POOL_MR_TEST mr/device/pool_mr_tests.cpp GPUS 1 PERCENT 60)

# cuda_async mr tests
ConfigureTest(CUDA_ASYNC_MR_TEST mr/device/cuda_async_mr_tests.cpp GPUS 1 PERCENT 60)
ConfigureTest(CUDA_ASYNC_MR_STATIC_CUDART_TEST mr/device/cuda_async_mr_tests.cpp GPUS 1 PERCENT 60
CUDART STATIC)
ConfigureTest(CUDA_ASYNC_MR_SHARED_CUDART_TEST mr/device/cuda_async_mr_tests.cpp GPUS 1 PERCENT 60
CUDART SHARED)

# thrust allocator tests
ConfigureTest(THRUST_ALLOCATOR_TEST mr/device/thrust_allocator_tests.cu GPUS 1 PERCENT 60)
Expand Down
Loading