1
0
Fork 0

Use posix_memalign instead of aligned_alloc

should be a little more portable to older linux systems (before glibc-2.16).

fixes https://github.com/official-stockfish/Stockfish/issues/2665

closes https://github.com/official-stockfish/Stockfish/pull/2668

No functional change.
pull/2674/head
Joost VandeVondele 2020-05-09 19:45:07 +02:00
parent fcaf0736fe
commit 8a1de2655c
1 changed files with 2 additions and 1 deletions

View File

@ -303,7 +303,8 @@ void* aligned_ttmem_alloc(size_t allocSize, void*& mem) {
constexpr size_t alignment = 2 * 1024 * 1024; // assumed 2MB page sizes
size_t size = ((allocSize + alignment - 1) / alignment) * alignment; // multiple of alignment
mem = aligned_alloc(alignment, size);
if (posix_memalign(&mem, alignment, size))
mem = nullptr;
madvise(mem, allocSize, MADV_HUGEPAGE);
return mem;
}