BenBot 1.7.5
A chess engine
Loading...
Searching...
No Matches
Memory utilities
Collaboration diagram for Memory utilities:

Files

file  Memory.hpp

Namespaces

namespace  util
namespace  util::memory

Functions

auto util::memory::page_aligned_alloc (size_t size) -> void *
void util::memory::page_aligned_free (void *mem)
void util::memory::prefetch (const void *mem)

Variables

constexpr auto util::memory::CacheLineSize

Detailed Description

Memory handling utility functions used throughout the code.

Function Documentation

◆ page_aligned_alloc()

auto util::memory::page_aligned_alloc ( size_t size) -> void *
nodiscard

Allocates memory aligned by page size, with a minimum alignment of 4096 bytes. Memory allocated by this function must be freed by calling page_aligned_free(). Returns nullptr if the memory could not be allocated.

See also
page_aligned_free()

◆ page_aligned_free()

void util::memory::page_aligned_free ( void * mem)

Frees page-aligned memory allocated by page_aligned_alloc(). This is a no-op if mem is nullptr.

See also
page_aligned_alloc()

◆ prefetch()

void util::memory::prefetch ( const void * mem)

Hints the CPU to prefetch the page that the given memory address is on. This function is nonblocking, and may be a no-op depending on the target platform.

Variable Documentation

◆ CacheLineSize

auto util::memory::CacheLineSize
inlineconstexpr
Initial value:
= std::max(
std::hardware_constructive_interference_size,
std::hardware_destructive_interference_size)

The cache line size of the target platform. If the standard library doesn't provide this feature, uses a sensible default.

Definition at line 73 of file Memory.hpp.