BenBot 1.7.5
A chess engine
Loading...
Searching...
No Matches
Memory.hpp
Go to the documentation of this file.
1/*
2 * ======================================================================================
3 *
4 * ░▒▓███████▓▒░░▒▓████████▓▒░▒▓███████▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░▒▓████████▓▒░
5 * ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
6 * ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
7 * ░▒▓███████▓▒░░▒▓██████▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
8 * ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
9 * ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
10 * ░▒▓███████▓▒░░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░
11 *
12 * ======================================================================================
13 */
14
20
25
26#pragma once
27
28#include <algorithm> // IWYU pragma: keep
29#include <cstddef> // IWYU pragma: keep - for size_t
30#include <new> // IWYU pragma: keep
31
35namespace util::memory {
36
37using std::size_t;
38
47[[nodiscard, gnu::alloc_size(1), gnu::malloc, clang::ownership_returns(malloc)]]
48auto page_aligned_alloc(size_t size) -> void*;
49
56[[clang::ownership_takes(malloc, 1)]] void page_aligned_free([[clang::noescape]] void* mem);
57
64void prefetch(const void* mem);
65
66#if defined(DOXYGEN) \
67 or (defined(__cpp_lib_hardware_interference_size) and (__cpp_lib_hardware_interference_size >= 201703L))
73inline constexpr auto CacheLineSize = std::max(
74 std::hardware_constructive_interference_size,
75 std::hardware_destructive_interference_size);
76#else
77# warning std::hardware_constructive_interference_size not available, using default value
78inline constexpr auto CacheLineSize = 32uz;
79#endif
80
81} // namespace util::memory
constexpr auto CacheLineSize
Definition Memory.hpp:73
void page_aligned_free(void *mem)
auto page_aligned_alloc(size_t size) -> void *
void prefetch(const void *mem)