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 17 commits into
base: branch-24.12
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 @@ -90,7 +90,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
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ static void benchmark_range(benchmark::internal::Benchmark* bench)
MRFactoryFunc get_mr_factory(std::string const& resource_name)
{
if (resource_name == "cuda") { return &make_cuda; }
#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT
if (resource_name == "cuda_async") { return &make_cuda_async; }
#endif
if (resource_name == "pool") { return &make_pool; }
if (resource_name == "arena") { return &make_arena; }
if (resource_name == "binning") { return &make_binning; }
Expand All @@ -153,13 +151,11 @@ void declare_benchmark(std::string const& name)
return;
}

#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT
if (name == "cuda_async") {
BENCHMARK_CAPTURE(BM_MultiStreamAllocations, cuda_async, &make_cuda_async) //
->Apply(benchmark_range);
return;
}
#endif

if (name == "pool") {
BENCHMARK_CAPTURE(BM_MultiStreamAllocations, pool_mr, &make_pool) //
Expand Down Expand Up @@ -248,9 +244,7 @@ int main(int argc, char** argv)
resource_names.emplace_back(args["resource"].as<std::string>());
} else {
resource_names.emplace_back("cuda");
#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT
resource_names.emplace_back("cuda_async");
#endif
resource_names.emplace_back("pool");
resource_names.emplace_back("arena");
resource_names.emplace_back("binning");
Expand Down
6 changes: 0 additions & 6 deletions benchmarks/random_allocations/random_allocations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,7 @@ int main(int argc, char** argv)
std::map<std::string, MRFactoryFunc> const funcs({{"arena", &make_arena},
{"binning", &make_binning},
{"cuda", &make_cuda},
#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT
{"cuda_async", &make_cuda_async},
#endif
{"pool", &make_pool}});
auto resource = args["resource"].as<std::string>();

Expand All @@ -340,11 +338,7 @@ int main(int argc, char** argv)
std::string mr_name = args["resource"].as<std::string>();
declare_benchmark(mr_name);
} else {
#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT
std::vector<std::string> mrs{"pool", "binning", "arena", "cuda_async", "cuda"};
#else
std::vector<std::string> mrs{"pool", "binning", "arena", "cuda"};
#endif
std::for_each(
std::cbegin(mrs), std::cend(mrs), [](auto const& mr) { declare_benchmark(mr); });
}
Expand Down
191 changes: 0 additions & 191 deletions include/rmm/detail/dynamic_load_runtime.hpp

This file was deleted.

84 changes: 84 additions & 0 deletions include/rmm/detail/runtime_async_alloc.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Copyright (c) 2022-2024, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once

#include <rmm/cuda_device.hpp>
#include <rmm/detail/export.hpp>

#include <cuda_runtime_api.h>

#include <dlfcn.h>

#include <memory>
#include <optional>

namespace RMM_NAMESPACE {
namespace detail {

/**
* @brief Determine at runtime if the CUDA driver supports the stream-ordered
* memory allocator functions.
*
* This allows RMM users to compile/link against CUDA 11.2+ and run with
* older drivers.
*/

struct runtime_async_alloc {
static bool is_supported()
{
static auto driver_supports_pool{[] {
int cuda_pool_supported{};
auto result = cudaDeviceGetAttribute(&cuda_pool_supported,
cudaDevAttrMemoryPoolsSupported,
rmm::get_current_cuda_device().value());
return result == cudaSuccess and cuda_pool_supported == 1;
}()};
return driver_supports_pool;
}

/**
* @brief Check whether the specified `cudaMemAllocationHandleType` is supported on the present
* CUDA driver/runtime version.
*
* @note This query was introduced in CUDA 11.3 so on CUDA 11.2 this function will only return
* true for `cudaMemHandleTypeNone`.
*
* @param handle_type An IPC export handle type to check for support.
* @return true if supported
* @return false if unsupported
*/
static bool is_export_handle_type_supported(cudaMemAllocationHandleType handle_type)
{
int supported_handle_types_bitmask{};
#if CUDART_VERSION >= 11030 // 11.3 introduced cudaDevAttrMemoryPoolSupportedHandleTypes
if (cudaMemHandleTypeNone != handle_type) {
auto const result = cudaDeviceGetAttribute(&supported_handle_types_bitmask,
cudaDevAttrMemoryPoolSupportedHandleTypes,
rmm::get_current_cuda_device().value());

// Don't throw on cudaErrorInvalidValue
auto const unsupported_runtime = (result == cudaErrorInvalidValue);
if (unsupported_runtime) return false;
// throw any other error that may have occurred
RMM_CUDA_TRY(result);
}
#endif
return (supported_handle_types_bitmask & handle_type) == handle_type;
}
};

} // namespace detail
} // namespace RMM_NAMESPACE
Loading
Loading