Skip to content

Is Large Page support on Linux only Transparent Huge Pages? #3887

Answered by vondele
RogerThiede asked this question in Q&A
Discussion options

You must be logged in to vote

yes, I think it is, but by way of an experiment might be not too difficult to change, the code is simple

Stockfish/src/misc.cpp

Lines 447 to 462 in 44b1ba8

void* aligned_large_pages_alloc(size_t allocSize) {
#if defined(__linux__)
constexpr size_t alignment = 2 * 1024 * 1024; // assumed 2MB page size
#else
constexpr size_t alignment = 4096; // assumed small page size
#endif
// round up to multiples of alignment
size_t size = ((allocSize + alignment - 1) / alignment) * alignment;
void *mem = std_aligned_alloc(alignment, size);
#if defined(MADV_HUGEPAGE)
madvise(mem, size, MADV_HUGEPAGE);
#endif
return mem;

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by RogerThiede
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants