Utilities#
-
static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT = {256}#
Default alignment used for CUDA memory allocation.
-
bool is_pow2(std::size_t value) noexcept#
Returns whether or not
valueis 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.
-
bool is_supported_alignment(std::size_t alignment) noexcept#
Returns whether or not
alignmentis a valid memory alignment.- Parameters:
alignment – [in] to check
- Returns:
True if the alignment is valid, false otherwise.
- bool is_supported_base_resource_alignment(
- std::size_t alignment
Returns whether or not
alignmentis supported by base CUDA memory resources.- Parameters:
alignment – [in] to check
- Returns:
True if the alignment is a valid memory alignment and is no larger than CUDA_ALLOCATION_ALIGNMENT, false otherwise.
- std::size_t align_up(
- std::size_t value,
- std::size_t alignment
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
- std::size_t align_down(
- std::size_t value,
- std::size_t alignment
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
-
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
- bool is_pointer_aligned(
- void *ptr,
- std::size_t alignment = rmm::CUDA_ALLOCATION_ALIGNMENT
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 or if concurrent managed access is not supported.
- 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