Skip to content

Commit

Permalink
Merge branch 'fea-explicit-initial-pool-size' into fea-host-pinned-mr
Browse files Browse the repository at this point in the history
  • Loading branch information
harrism committed Jan 9, 2024
2 parents ce58ff5 + 0b4c968 commit 2f827a5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion benchmarks/device_uvector/device_uvector_bench.cu
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void BM_UvectorSizeConstruction(benchmark::State& state)
{
rmm::mr::cuda_memory_resource cuda_mr{};
rmm::mr::pool_memory_resource<rmm::mr::cuda_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)
Expand Down
7 changes: 4 additions & 3 deletions include/rmm/cuda_device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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%.
*
Expand All @@ -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<double>(percent) / 100;
double const fraction = static_cast<double>(percent) / 100.0;

return rmm::detail::align_up(
std::min(free, static_cast<std::size_t>(static_cast<double>(total) * fraction)),
Expand Down
13 changes: 6 additions & 7 deletions include/rmm/mr/device/pool_memory_resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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<std::size_t> maximum_size)
{
current_pool_size_ = 0; // try_to_expand will set this if it succeeds
Expand Down

0 comments on commit 2f827a5

Please sign in to comment.