Skip to content

Commit 49c993d

Browse files
committed
Remove our own align_up/align_down methods, these were not used outside of the arena code, and were causing build errors
Signed-off-by: David Gardner <dagardner@nvidia.com>
1 parent 8fb38f8 commit 49c993d

File tree

2 files changed

+9
-28
lines changed

2 files changed

+9
-28
lines changed

cpp/mrc/include/mrc/memory/resources/arena_resource.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include <cuda_runtime_api.h>
2424
#include <glog/logging.h>
25+
#include <rmm/detail/aligned.hpp>
2526
#include <rmm/detail/error.hpp>
2627
#include <rmm/logger.hpp>
2728

@@ -135,7 +136,7 @@ class arena_resource final : public adaptor<Upstream>
135136
return nullptr;
136137
}
137138

138-
bytes = detail::arena::align_up(bytes);
139+
bytes = rmm::align_up(bytes, rmm::CUDA_ALLOCATION_ALIGNMENT);
139140
auto& arena = get_thread_arena();
140141
void* pointer = arena.allocate(bytes);
141142

@@ -173,7 +174,7 @@ class arena_resource final : public adaptor<Upstream>
173174
return;
174175
}
175176

176-
bytes = detail::arena::align_up(bytes);
177+
bytes = rmm::align_up(bytes, rmm::CUDA_ALLOCATION_ALIGNMENT);
177178
get_thread_arena().deallocate(ptr, bytes);
178179
}
179180

cpp/mrc/include/mrc/memory/resources/detail/arena.hpp

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -161,28 +161,6 @@ inline bool block_size_compare(block lhs, block rhs)
161161
return lhs.size() < rhs.size();
162162
}
163163

164-
/**
165-
* @brief Align up to the allocation alignment.
166-
*
167-
* @param[in] v value to align
168-
* @return Return the aligned value
169-
*/
170-
std::size_t align_up(std::size_t value) noexcept
171-
{
172-
return rmm::align_up(value, rmm::CUDA_ALLOCATION_ALIGNMENT);
173-
}
174-
175-
/**
176-
* @brief Align down to the allocation alignment.
177-
*
178-
* @param[in] v value to align
179-
* @return Return the aligned value
180-
*/
181-
std::size_t align_down(std::size_t value) noexcept
182-
{
183-
return rmm::align_down(value, rmm::CUDA_ALLOCATION_ALIGNMENT);
184-
}
185-
186164
/**
187165
* @brief Get the first free block of at least `size` bytes.
188166
*
@@ -318,9 +296,11 @@ class global_arena final
318296
maximum_size_{maximum_size}
319297
{
320298
RMM_EXPECTS(nullptr != upstream_mr_, "Unexpected null upstream pointer.");
321-
RMM_EXPECTS(initial_size == default_initial_size || initial_size == align_up(initial_size),
299+
RMM_EXPECTS(initial_size == default_initial_size ||
300+
initial_size == rmm::align_up(initial_size, rmm::CUDA_ALLOCATION_ALIGNMENT),
322301
"Error, Initial arena size required to be a multiple of 256 bytes");
323-
RMM_EXPECTS(maximum_size_ == default_maximum_size || maximum_size_ == align_up(maximum_size_),
302+
RMM_EXPECTS(maximum_size_ == default_maximum_size ||
303+
maximum_size_ == rmm::align_up(maximum_size_, rmm::CUDA_ALLOCATION_ALIGNMENT),
324304
"Error, Maximum arena size required to be a multiple of 256 bytes");
325305

326306
if (initial_size == default_initial_size || maximum_size == default_maximum_size)
@@ -330,11 +310,11 @@ class global_arena final
330310
RMM_CUDA_TRY(cudaMemGetInfo(&free, &total));
331311
if (initial_size == default_initial_size)
332312
{
333-
initial_size = align_up(std::min(free, total / 2));
313+
initial_size = rmm::align_up(std::min(free, total / 2), rmm::CUDA_ALLOCATION_ALIGNMENT);
334314
}
335315
if (maximum_size_ == default_maximum_size)
336316
{
337-
maximum_size_ = align_down(free) - reserved_size;
317+
maximum_size_ = rmm::align_down(free, rmm::CUDA_ALLOCATION_ALIGNMENT) - reserved_size;
338318
}
339319
}
340320
RMM_EXPECTS(initial_size <= maximum_size_, "Initial arena size exceeds the maximum pool size!");

0 commit comments

Comments
 (0)