From 0b4c968f5c9d72238d3e9e8d23de698f2de11891 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Tue, 9 Jan 2024 10:13:37 +0000 Subject: [PATCH] Respond to feedback from @wence- --- benchmarks/device_uvector/device_uvector_bench.cu | 2 +- include/rmm/cuda_device.hpp | 7 ++++--- include/rmm/mr/device/pool_memory_resource.hpp | 13 ++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/benchmarks/device_uvector/device_uvector_bench.cu b/benchmarks/device_uvector/device_uvector_bench.cu index 12256ef3a..8b7f9a5ba 100644 --- a/benchmarks/device_uvector/device_uvector_bench.cu +++ b/benchmarks/device_uvector/device_uvector_bench.cu @@ -40,7 +40,7 @@ void BM_UvectorSizeConstruction(benchmark::State& state) { rmm::mr::cuda_memory_resource cuda_mr{}; rmm::mr::pool_memory_resource mr{ - &cuda_mr, rmm::percent_of_free_device_memory(1. / 2)}; + &cuda_mr, rmm::percent_of_free_device_memory(50)}; rmm::mr::set_current_device_resource(&mr); for (auto _ : state) { // NOLINT(clang-analyzer-deadcode.DeadStores) diff --git a/include/rmm/cuda_device.hpp b/include/rmm/cuda_device.hpp index c7f94dc37..05028fe9f 100644 --- a/include/rmm/cuda_device.hpp +++ b/include/rmm/cuda_device.hpp @@ -131,8 +131,9 @@ const auto available_device_memory = rmm::available_device_memory; } // namespace detail /** - * @brief Returns the approximate specified percent of free device memory on the current CUDA - * device, aligned to the nearest CUDA allocation size. + * @brief Returns the approximate specified percent of total device memory on the current CUDA + * device or the total free device memory (whichever is smaller), aligned to the nearest CUDA + * allocation size. * * @param percent The percent of free memory to return. Defaults to 50%. * @@ -142,7 +143,7 @@ inline std::size_t percent_of_free_device_memory(int percent = 50) { auto const [free, total] = rmm::available_device_memory(); - double fraction = static_cast(percent) / 100; + double const fraction = static_cast(percent) / 100.0; return rmm::detail::align_up( std::min(free, static_cast(static_cast(total) * fraction)), diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index 6dc61a8a7..0e6f8ecbe 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -113,6 +113,8 @@ class pool_memory_resource final * @brief [DEPRECATED] Construct a `pool_memory_resource` and allocate the initial device memory * pool using `upstream_mr`. * + * @deprecated Use the constructor that takes an explicit initial pool size instead. + * * @throws rmm::logic_error if `upstream_mr == nullptr` * @throws rmm::logic_error if `initial_pool_size` is neither the default nor aligned to a * multiple of pool_memory_resource::allocation_alignment bytes. @@ -136,6 +138,8 @@ class pool_memory_resource final * @brief Construct a `pool_memory_resource` and allocate the initial device memory pool using * `upstream_mr`. * + * @deprecated Use the constructor that takes an explicit initial size instead. + * * @throws rmm::logic_error if `upstream_mr == nullptr` * @throws rmm::logic_error if `initial_pool_size` is neither the default nor aligned to a * multiple of pool_memory_resource::allocation_alignment bytes. @@ -320,16 +324,11 @@ class pool_memory_resource final /** * @brief Allocate initial memory for the pool * - * If initial_size is unset, then queries the upstream memory resource for available memory if - * upstream supports `get_mem_info`, or queries the device (using CUDA API) for available memory - * if not. Then attempts to initialize to half the available memory. - * - * If initial_size is set, then tries to initialize the pool to that size. - * * @param initial_size The optional initial size for the pool * @param maximum_size The optional maximum size for the pool + * + * @throws logic_error if @p initial_size is larger than @p maximum_size (if set). */ - // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) void initialize_pool(std::size_t initial_size, thrust::optional maximum_size) { current_pool_size_ = 0; // try_to_expand will set this if it succeeds