New strategy for producing aligned blocks of memory

On platforms that do not support aligned mmap/VirtualAlloc,
we need to produce heavily aligned blocks to guarantee we can meet
all possible alignment requests.

This commit grabs a block much larger than requested, and then produces
"offcuts" before and after the block of smaller/same "large_classes".  This
enables one mmap/virtual alloc request to services many other requests
for aligned memory.
This commit is contained in:
Matthew Parkinson
2020-01-29 17:07:32 +00:00
parent 4fea7b8bb1
commit 350df5d13d
3 changed files with 85 additions and 21 deletions

View File

@@ -32,8 +32,9 @@ int main()
{
MemoryProviderStateMixin<DefaultPal> mp;
size_t size = 1ULL << 28;
oe_base = mp.reserve<true>(size, 1);
size_t large_class = 28 - SUPERSLAB_BITS;
size_t size = 1ULL << (SUPERSLAB_BITS + large_class);
oe_base = mp.reserve<true>(large_class);
oe_end = (uint8_t*)oe_base + size;
std::cout << "Allocated region " << oe_base << " - " << oe_end << std::endl;

View File

@@ -45,8 +45,9 @@ int main()
MemoryProviderStateMixin<DefaultPal> mp;
size_t size = 1ULL << 26;
oe_base = mp.reserve<true>(size, 1);
size_t large_class = 26 - SUPERSLAB_BITS;
size_t size = 1ULL << (SUPERSLAB_BITS + large_class);
oe_base = mp.reserve<true>(large_class);
oe_end = (uint8_t*)oe_base + size;
std::cout << "Allocated region " << oe_base << " - " << oe_end << std::endl;