aligned.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2020-2025, NVIDIA CORPORATION.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
6 #pragma once
7 
8 #include <rmm/detail/export.hpp>
9 
10 #include <cassert>
11 #include <cstddef>
12 
13 namespace RMM_EXPORT rmm {
14 
26 [[deprecated("RMM_DEFAULT_HOST_ALIGNMENT is deprecated in 25.12 and will be removed in 26.02.")]]
27 static constexpr std::size_t RMM_DEFAULT_HOST_ALIGNMENT{alignof(std::max_align_t)};
28 
33 static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT{256};
34 
42 [[nodiscard]] bool is_pow2(std::size_t value) noexcept;
43 
51 [[nodiscard]] bool is_supported_alignment(std::size_t alignment) noexcept;
52 
61 [[nodiscard]] std::size_t align_up(std::size_t value, std::size_t alignment) noexcept;
62 
71 [[nodiscard]] std::size_t align_down(std::size_t value, std::size_t alignment) noexcept;
72 
81 [[nodiscard]] bool is_aligned(std::size_t value, std::size_t alignment) noexcept;
82 
91 [[nodiscard]] bool is_pointer_aligned(void* ptr,
92  std::size_t alignment = CUDA_ALLOCATION_ALIGNMENT) noexcept;
93  // end of group
95 
96 } // namespace RMM_EXPORT rmm
static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT
Default alignment used for CUDA memory allocation.
Definition: aligned.hpp:33
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.
bool is_supported_alignment(std::size_t alignment) noexcept
Returns whether or not alignment is a valid memory alignment.
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.
static constexpr std::size_t RMM_DEFAULT_HOST_ALIGNMENT
Default alignment used for host memory allocated by RMM.
Definition: aligned.hpp:27
bool is_pow2(std::size_t value) noexcept
Returns whether or not value is a power of 2.
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.
std::size_t align_up(std::size_t value, std::size_t alignment) noexcept
Align up to nearest multiple of specified power of 2.
RAPIDS Memory Manager - The top-level namespace for all RMM functionality.