Skip to content

Commit

Permalink
Use posix_memalign instead of aligned_alloc
Browse files Browse the repository at this point in the history
should be a little more portable to older linux systems (before glibc-2.16).

fixes #2665

closes #2668

No functional change.
  • Loading branch information
vondele committed May 11, 2020
1 parent fcaf073 commit 8a1de26
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 8a1de26

Please sign in to comment.