19 #include <rmm/detail/export.hpp>
25 namespace RMM_NAMESPACE {
52 [[nodiscard]] constexpr
bool is_pow2(std::size_t value) noexcept
54 return (value != 0U) && ((value & (value - 1)) == 0U);
77 [[nodiscard]] constexpr std::size_t
align_up(std::size_t value, std::size_t alignment) noexcept
80 return (value + (alignment - 1)) & ~(alignment - 1);
91 [[nodiscard]] constexpr std::size_t
align_down(std::size_t value, std::size_t alignment) noexcept
94 return value & ~(alignment - 1);
105 [[nodiscard]] constexpr
bool is_aligned(std::size_t value, std::size_t alignment) noexcept
123 return is_aligned(
reinterpret_cast<std::uintptr_t
>(ptr), alignment);
static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT
Default alignment used for CUDA memory allocation.
Definition: aligned.hpp:43
constexpr bool is_aligned(std::size_t value, std::size_t alignment) noexcept
Checks whether a value is aligned to a multiple of a specified power of 2.
Definition: aligned.hpp:105
bool is_pointer_aligned(void *ptr, std::size_t alignment=CUDA_ALLOCATION_ALIGNMENT) noexcept
Checks whether the provided pointer is aligned to a specified alignment.
Definition: aligned.hpp:119
static constexpr std::size_t RMM_DEFAULT_HOST_ALIGNMENT
Default alignment used for host memory allocated by RMM.
Definition: aligned.hpp:37
constexpr bool is_supported_alignment(std::size_t alignment) noexcept
Returns whether or not alignment is a valid memory alignment.
Definition: aligned.hpp:64
constexpr std::size_t align_down(std::size_t value, std::size_t alignment) noexcept
Align down to the nearest multiple of specified power of 2.
Definition: aligned.hpp:91
constexpr std::size_t align_up(std::size_t value, std::size_t alignment) noexcept
Align up to nearest multiple of specified power of 2.
Definition: aligned.hpp:77
constexpr bool is_pow2(std::size_t value) noexcept
Returns whether or not value is a power of 2.
Definition: aligned.hpp:52