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
-
constexpr bool is_pow2(std::size_t value) noexcept¶