File include/brisk/core/Memory.hpp
¶
cacheAlignment
variable¶
constexpr inline size_t cacheAlignment = 64
Cache line alignment size.
This constant defines the alignment size for cache lines, which is typically 64 bytes.
defaultMemoryAlignment
variable¶
constexpr inline size_t defaultMemoryAlignment =
maximumSIMDAlignment
Default memory alignment.
This constant sets the default alignment for memory allocations, which is the same as the maximum SIMD alignment.
alignUp
function¶
template <typename T>
constexpr T alignUp(T value,
std::type_identity_t<T> alignment)
Aligns a value up to the nearest multiple of the specified alignment.
Template param T
Type of the value to be aligned.
Param value
The value to be aligned.
Param alignment
The alignment requirement.
Returns The aligned value.
alignedAlloc
function¶
template <typename T = void>
[[nodiscard]] inline T *
alignedAlloc(size_t size,
size_t alignment = defaultMemoryAlignment)
Allocates memory with specified alignment.
This function allocates memory with the given size and alignment. If alignment is not specified, the
default memory alignment is used.
Template param T
Type of the allocated memory. Defaults to void.
Param size
The number of elements of type T to allocate.
Param alignment
The alignment requirement (default is defaultMemoryAlignment).
Returns Pointer to the allocated memory.
alignedFree
function¶
template <typename T = void> inline void alignedFree(T *ptr)
Frees memory allocated with alignedAlloc.
This function frees memory that was previously allocated with alignedAlloc.
Template param T
Type of the pointer to be freed. Defaults to void.
Param ptr
Pointer to the memory to be freed.
AlignedAllocation
class¶
AlignedAllocation
Provides custom new
and delete
operators for aligned memory allocation.
This struct defines custom new
and delete
operators that use aligned memory allocation. By inheriting
from AlignedAllocation
, a derived class will automatically use these aligned operators for dynamic memory
allocation. This ensures that instances of the derived class are always allocated with the appropriate
alignment.
operator new
function (AlignedAllocation::operator new
)¶
static void *operator new(size_t size) noexcept
Allocates memory with alignment using the new
operator.
This function allocates memory with default alignment using the new
operator.
Param size
The size of the memory to allocate.
Returns Pointer to the allocated memory.
operator delete
function (AlignedAllocation::operator delete
)¶
static void operator delete(void *ptr) noexcept
Frees memory using the delete
operator.
This function frees memory that was previously allocated with the custom new
operator.
Param ptr
Pointer to the memory to be freed.
operator new
function (AlignedAllocation::operator new
)¶
static void *operator new(size_t size,
std::align_val_t al) noexcept
Allocates memory with specified alignment using the new
operator.
This function allocates memory with the specified alignment using the new
operator.
Param size
The size of the memory to allocate.
Param al
The alignment requirement.
Returns Pointer to the allocated memory.
operator delete
function (AlignedAllocation::operator delete
)¶
static void operator delete(void *ptr,
std::align_val_t al) noexcept
Frees memory with specified alignment using the delete
operator.
This function frees memory that was previously allocated with the custom new
operator with alignment.
Param ptr
Pointer to the memory to be freed.
Param al
The alignment requirement.
Auto-generated from sources, Revision , https://github.com/brisklib/brisk/blob//include/brisk/