Utilities¶
- group utilities
Functions
-
constexpr bool is_pow2(std::size_t value) noexcept¶
Returns whether or not
value
is a power of 2.- Parameters:
value – [in] value to check.
- Returns:
True if the input is a power of two with non-negative integer exponent, false otherwise.
-
constexpr bool is_supported_alignment(std::size_t alignment) noexcept¶
Returns whether or not
alignment
is a valid memory alignment.- Parameters:
alignment – [in] to check
- Returns:
True if the alignment is valid, false otherwise.
-
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.
- Parameters:
value – [in] value to align
alignment – [in] amount, in bytes, must be a power of 2
- Returns:
the aligned value
-
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.
- Parameters:
value – [in] value to align
alignment – [in] amount, in bytes, must be a power of 2
- Returns:
the aligned value
-
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.
- Parameters:
value – [in] value to check for alignment
alignment – [in] amount, in bytes, must be a power of 2
- Returns:
true if aligned
-
inline 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
.- Parameters:
ptr – [in] pointer to check for alignment
alignment – [in] required alignment in bytes, must be a power of 2
- Returns:
true if the pointer is aligned
-
void prefetch(void const *ptr, std::size_t size, rmm::cuda_device_id device, rmm::cuda_stream_view stream)¶
Prefetch memory to the specified device on the specified stream.
This function is a no-op if the pointer is not to CUDA managed memory.
- Throws:
rmm::cuda_error – if the prefetch fails.
- Parameters:
ptr – The pointer to the memory to prefetch
size – The number of bytes to prefetch
device – The device to prefetch to
stream – The stream to use for the prefetch
-
template<typename T>
void prefetch(cuda::std::span<T const> data, rmm::cuda_device_id device, rmm::cuda_stream_view stream)¶ Prefetch a span of memory to the specified device on the specified stream.
This function is a no-op if the buffer is not backed by CUDA managed memory.
- Throws:
rmm::cuda_error – if the prefetch fails.
- Parameters:
data – The span to prefetch
device – The device to prefetch to
stream – The stream to use for the prefetch
-
constexpr bool is_pow2(std::size_t value) noexcept¶