mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-22 10:17:01 +08:00
Configure 2MB alignment for allocations on standard heap 64k
Signed-off-by: Slawomir Milczarek <slawomir.milczarek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
edf339fdf1
commit
2a1069eda2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2020 Intel Corporation
|
* Copyright (C) 2020-2021 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -577,15 +577,17 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenNotSetUseSystemMemoryWhenGraphicsAl
|
|||||||
EXPECT_NE(0u, gpuAddress);
|
EXPECT_NE(0u, gpuAddress);
|
||||||
|
|
||||||
auto heap = HeapIndex::HEAP_STANDARD64KB;
|
auto heap = HeapIndex::HEAP_STANDARD64KB;
|
||||||
|
auto sizeReserved = alignUp(sizeAligned, 2 * MemoryConstants::megaByte);
|
||||||
if (memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTENDED)) {
|
if (memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTENDED)) {
|
||||||
heap = HeapIndex::HEAP_EXTENDED;
|
heap = HeapIndex::HEAP_EXTENDED;
|
||||||
|
sizeReserved = alignUp(sizeAligned, MemoryConstants::pageSize);
|
||||||
}
|
}
|
||||||
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapBase(heap)), gpuAddress);
|
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapBase(heap)), gpuAddress);
|
||||||
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapLimit(heap)), gpuAddress);
|
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapLimit(heap)), gpuAddress);
|
||||||
EXPECT_EQ(0u, allocation->getGpuBaseAddress());
|
EXPECT_EQ(0u, allocation->getGpuBaseAddress());
|
||||||
EXPECT_EQ(sizeAligned, allocation->getUnderlyingBufferSize());
|
EXPECT_EQ(sizeAligned, allocation->getUnderlyingBufferSize());
|
||||||
EXPECT_EQ(gpuAddress, reinterpret_cast<uint64_t>(allocation->getReservedAddressPtr()));
|
EXPECT_EQ(gpuAddress, reinterpret_cast<uint64_t>(allocation->getReservedAddressPtr()));
|
||||||
EXPECT_EQ(sizeAligned, allocation->getReservedAddressSize());
|
EXPECT_EQ(sizeReserved, allocation->getReservedAddressSize());
|
||||||
|
|
||||||
EXPECT_EQ(1u, allocation->storageInfo.getNumBanks());
|
EXPECT_EQ(1u, allocation->storageInfo.getNumBanks());
|
||||||
EXPECT_EQ(allocData.storageInfo.getMemoryBanks(), allocation->storageInfo.getMemoryBanks());
|
EXPECT_EQ(allocData.storageInfo.getMemoryBanks(), allocation->storageInfo.getMemoryBanks());
|
||||||
@@ -636,7 +638,7 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenNotSetUseSystemMemoryWhenGraphicsAl
|
|||||||
EXPECT_EQ(0u, allocation->getGpuBaseAddress());
|
EXPECT_EQ(0u, allocation->getGpuBaseAddress());
|
||||||
EXPECT_EQ(sizeAligned, allocation->getUnderlyingBufferSize());
|
EXPECT_EQ(sizeAligned, allocation->getUnderlyingBufferSize());
|
||||||
EXPECT_EQ(gpuAddress, reinterpret_cast<uint64_t>(allocation->getReservedAddressPtr()));
|
EXPECT_EQ(gpuAddress, reinterpret_cast<uint64_t>(allocation->getReservedAddressPtr()));
|
||||||
EXPECT_EQ(sizeAligned, allocation->getReservedAddressSize());
|
EXPECT_EQ(alignUp(sizeAligned, 2 * MemoryConstants::megaByte), allocation->getReservedAddressSize());
|
||||||
|
|
||||||
EXPECT_EQ(1u, allocation->storageInfo.getNumBanks());
|
EXPECT_EQ(1u, allocation->storageInfo.getNumBanks());
|
||||||
EXPECT_EQ(allocData.storageInfo.getMemoryBanks(), allocation->storageInfo.getMemoryBanks());
|
EXPECT_EQ(allocData.storageInfo.getMemoryBanks(), allocation->storageInfo.getMemoryBanks());
|
||||||
@@ -925,18 +927,18 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenOversizedAllocationWhenGraphicsAllo
|
|||||||
if (memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTENDED)) {
|
if (memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTENDED)) {
|
||||||
heap = HeapIndex::HEAP_EXTENDED;
|
heap = HeapIndex::HEAP_EXTENDED;
|
||||||
}
|
}
|
||||||
auto largerSize = 3 * MemoryConstants::pageSize64k;
|
auto largerSize = 6 * MemoryConstants::megaByte;
|
||||||
auto gpuAddress1 = memoryManager->getGfxPartition(0)->heapAllocate(heap, largerSize);
|
auto gpuAddress1 = memoryManager->getGfxPartition(0)->heapAllocate(heap, largerSize);
|
||||||
EXPECT_NE(0u, gpuAddress1);
|
EXPECT_NE(0u, gpuAddress1);
|
||||||
EXPECT_EQ(3 * MemoryConstants::pageSize64k, largerSize);
|
EXPECT_EQ(6 * MemoryConstants::megaByte, largerSize);
|
||||||
auto gpuAddress2 = memoryManager->getGfxPartition(0)->heapAllocate(heap, largerSize);
|
auto gpuAddress2 = memoryManager->getGfxPartition(0)->heapAllocate(heap, largerSize);
|
||||||
EXPECT_NE(0u, gpuAddress2);
|
EXPECT_NE(0u, gpuAddress2);
|
||||||
EXPECT_EQ(3 * MemoryConstants::pageSize64k, largerSize);
|
EXPECT_EQ(6 * MemoryConstants::megaByte, largerSize);
|
||||||
memoryManager->getGfxPartition(0)->heapFree(heap, gpuAddress1, largerSize);
|
memoryManager->getGfxPartition(0)->heapFree(heap, gpuAddress1, largerSize);
|
||||||
|
|
||||||
auto status = MemoryManager::AllocationStatus::Error;
|
auto status = MemoryManager::AllocationStatus::Error;
|
||||||
AllocationData allocData;
|
AllocationData allocData;
|
||||||
allocData.size = 2 * MemoryConstants::pageSize64k;
|
allocData.size = 5 * MemoryConstants::megaByte;
|
||||||
allocData.type = GraphicsAllocation::AllocationType::BUFFER;
|
allocData.type = GraphicsAllocation::AllocationType::BUFFER;
|
||||||
allocData.rootDeviceIndex = rootDeviceIndex;
|
allocData.rootDeviceIndex = rootDeviceIndex;
|
||||||
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocData, status);
|
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||||
@@ -1248,7 +1250,7 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenGraphicsAllocationInDevicePoolIsAll
|
|||||||
EXPECT_NE(0u, gpuAddress);
|
EXPECT_NE(0u, gpuAddress);
|
||||||
EXPECT_EQ(sizeAlignedTo64KB, allocation->getUnderlyingBufferSize());
|
EXPECT_EQ(sizeAlignedTo64KB, allocation->getUnderlyingBufferSize());
|
||||||
EXPECT_EQ(gpuAddress, reinterpret_cast<uint64_t>(allocation->getReservedAddressPtr()));
|
EXPECT_EQ(gpuAddress, reinterpret_cast<uint64_t>(allocation->getReservedAddressPtr()));
|
||||||
EXPECT_EQ(sizeAlignedTo64KB, allocation->getReservedAddressSize());
|
EXPECT_EQ(alignUp(sizeAlignedTo64KB, 2 * MemoryConstants::megaByte), allocation->getReservedAddressSize());
|
||||||
|
|
||||||
auto drmAllocation = static_cast<DrmAllocation *>(allocation);
|
auto drmAllocation = static_cast<DrmAllocation *>(allocation);
|
||||||
auto bo = drmAllocation->getBO();
|
auto bo = drmAllocation->getBO();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2017-2020 Intel Corporation
|
* Copyright (C) 2017-2021 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -1946,7 +1946,7 @@ TEST_F(DrmMemoryManagerWithLocalMemoryTest, givenDrmMemoryManagerWithLocalMemory
|
|||||||
ASSERT_NE(nullptr, graphicsAllocation);
|
ASSERT_NE(nullptr, graphicsAllocation);
|
||||||
|
|
||||||
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
|
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
|
||||||
EXPECT_EQ(size, graphicsAllocation->getUnderlyingBufferSize());
|
EXPECT_EQ(alignUp(size, 2 * MemoryConstants::megaByte), graphicsAllocation->getUnderlyingBufferSize());
|
||||||
EXPECT_EQ(MemoryPool::SystemCpuInaccessible, graphicsAllocation->getMemoryPool());
|
EXPECT_EQ(MemoryPool::SystemCpuInaccessible, graphicsAllocation->getMemoryPool());
|
||||||
EXPECT_EQ(this->mock->inputFd, static_cast<int32_t>(handle));
|
EXPECT_EQ(this->mock->inputFd, static_cast<int32_t>(handle));
|
||||||
|
|
||||||
@@ -1958,7 +1958,7 @@ TEST_F(DrmMemoryManagerWithLocalMemoryTest, givenDrmMemoryManagerWithLocalMemory
|
|||||||
auto bo = drmAllocation->getBO();
|
auto bo = drmAllocation->getBO();
|
||||||
EXPECT_EQ(this->mock->outputHandle, static_cast<uint32_t>(bo->peekHandle()));
|
EXPECT_EQ(this->mock->outputHandle, static_cast<uint32_t>(bo->peekHandle()));
|
||||||
EXPECT_EQ(gpuAddress, bo->peekAddress());
|
EXPECT_EQ(gpuAddress, bo->peekAddress());
|
||||||
EXPECT_EQ(size, bo->peekSize());
|
EXPECT_EQ(alignUp(size, 2 * MemoryConstants::megaByte), bo->peekSize());
|
||||||
|
|
||||||
EXPECT_EQ(handle, graphicsAllocation->peekSharedHandle());
|
EXPECT_EQ(handle, graphicsAllocation->peekSharedHandle());
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ GfxPartition::~GfxPartition() {
|
|||||||
reservedCpuAddressRange = {0};
|
reservedCpuAddressRange = {0};
|
||||||
}
|
}
|
||||||
|
|
||||||
void GfxPartition::Heap::init(uint64_t base, uint64_t size) {
|
void GfxPartition::Heap::init(uint64_t base, uint64_t size, size_t allocationAlignment) {
|
||||||
this->base = base;
|
this->base = base;
|
||||||
this->size = size;
|
this->size = size;
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ void GfxPartition::Heap::init(uint64_t base, uint64_t size) {
|
|||||||
size -= 2 * GfxPartition::heapGranularity;
|
size -= 2 * GfxPartition::heapGranularity;
|
||||||
}
|
}
|
||||||
|
|
||||||
alloc = std::make_unique<HeapAllocator>(base + GfxPartition::heapGranularity, size);
|
alloc = std::make_unique<HeapAllocator>(base + GfxPartition::heapGranularity, size, allocationAlignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GfxPartition::Heap::initExternalWithFrontWindow(uint64_t base, uint64_t size) {
|
void GfxPartition::Heap::initExternalWithFrontWindow(uint64_t base, uint64_t size) {
|
||||||
@@ -52,7 +52,7 @@ void GfxPartition::Heap::initExternalWithFrontWindow(uint64_t base, uint64_t siz
|
|||||||
|
|
||||||
size -= GfxPartition::heapGranularity;
|
size -= GfxPartition::heapGranularity;
|
||||||
|
|
||||||
alloc = std::make_unique<HeapAllocator>(base, size, 0u);
|
alloc = std::make_unique<HeapAllocator>(base, size, MemoryConstants::pageSize, 0u);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GfxPartition::Heap::initWithFrontWindow(uint64_t base, uint64_t size, uint64_t frontWindowSize) {
|
void GfxPartition::Heap::initWithFrontWindow(uint64_t base, uint64_t size, uint64_t frontWindowSize) {
|
||||||
@@ -63,14 +63,14 @@ void GfxPartition::Heap::initWithFrontWindow(uint64_t base, uint64_t size, uint6
|
|||||||
size -= GfxPartition::heapGranularity;
|
size -= GfxPartition::heapGranularity;
|
||||||
size -= frontWindowSize;
|
size -= frontWindowSize;
|
||||||
|
|
||||||
alloc = std::make_unique<HeapAllocator>(base + frontWindowSize, size);
|
alloc = std::make_unique<HeapAllocator>(base + frontWindowSize, size, MemoryConstants::pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GfxPartition::Heap::initFrontWindow(uint64_t base, uint64_t size) {
|
void GfxPartition::Heap::initFrontWindow(uint64_t base, uint64_t size) {
|
||||||
this->base = base;
|
this->base = base;
|
||||||
this->size = size;
|
this->size = size;
|
||||||
|
|
||||||
alloc = std::make_unique<HeapAllocator>(base, size, 0u);
|
alloc = std::make_unique<HeapAllocator>(base, size, MemoryConstants::pageSize, 0u);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GfxPartition::freeGpuAddressRange(uint64_t ptr, size_t size) {
|
void GfxPartition::freeGpuAddressRange(uint64_t ptr, size_t size) {
|
||||||
@@ -191,7 +191,7 @@ bool GfxPartition::init(uint64_t gpuAddressSpace, size_t cpuAddressRangeSizeToRe
|
|||||||
|
|
||||||
// Split HEAP_STANDARD64K among root devices
|
// Split HEAP_STANDARD64K among root devices
|
||||||
auto gfxStandard64KBSize = alignDown(gfxStandardSize / numRootDevices, GfxPartition::heapGranularity);
|
auto gfxStandard64KBSize = alignDown(gfxStandardSize / numRootDevices, GfxPartition::heapGranularity);
|
||||||
heapInit(HeapIndex::HEAP_STANDARD64KB, gfxBase + rootDeviceIndex * gfxStandard64KBSize, gfxStandard64KBSize);
|
heapInitWithAllocationAlignment(HeapIndex::HEAP_STANDARD64KB, gfxBase + rootDeviceIndex * gfxStandard64KBSize, gfxStandard64KBSize, 2 * MemoryConstants::megaByte);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,11 @@ class GfxPartition {
|
|||||||
MOCKABLE_VIRTUAL bool init(uint64_t gpuAddressSpace, size_t cpuAddressRangeSizeToReserve, uint32_t rootDeviceIndex, size_t numRootDevices, bool useExternalFrontWindowPool);
|
MOCKABLE_VIRTUAL bool init(uint64_t gpuAddressSpace, size_t cpuAddressRangeSizeToReserve, uint32_t rootDeviceIndex, size_t numRootDevices, bool useExternalFrontWindowPool);
|
||||||
|
|
||||||
void heapInit(HeapIndex heapIndex, uint64_t base, uint64_t size) {
|
void heapInit(HeapIndex heapIndex, uint64_t base, uint64_t size) {
|
||||||
getHeap(heapIndex).init(base, size);
|
getHeap(heapIndex).init(base, size, MemoryConstants::pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
void heapInitWithAllocationAlignment(HeapIndex heapIndex, uint64_t base, uint64_t size, size_t allocationAlignment) {
|
||||||
|
getHeap(heapIndex).init(base, size, allocationAlignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
void heapInitExternalWithFrontWindow(HeapIndex heapIndex, uint64_t base, uint64_t size) {
|
void heapInitExternalWithFrontWindow(HeapIndex heapIndex, uint64_t base, uint64_t size) {
|
||||||
@@ -112,7 +116,7 @@ class GfxPartition {
|
|||||||
class Heap {
|
class Heap {
|
||||||
public:
|
public:
|
||||||
Heap() = default;
|
Heap() = default;
|
||||||
void init(uint64_t base, uint64_t size);
|
void init(uint64_t base, uint64_t size, size_t allocationAlignment);
|
||||||
void initExternalWithFrontWindow(uint64_t base, uint64_t size);
|
void initExternalWithFrontWindow(uint64_t base, uint64_t size);
|
||||||
void initWithFrontWindow(uint64_t base, uint64_t size, uint64_t frontWindowSize);
|
void initWithFrontWindow(uint64_t base, uint64_t size, uint64_t frontWindowSize);
|
||||||
void initFrontWindow(uint64_t base, uint64_t size);
|
void initFrontWindow(uint64_t base, uint64_t size);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2017-2020 Intel Corporation
|
* Copyright (C) 2017-2021 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -26,10 +26,13 @@ bool operator<(const HeapChunk &hc1, const HeapChunk &hc2);
|
|||||||
|
|
||||||
class HeapAllocator {
|
class HeapAllocator {
|
||||||
public:
|
public:
|
||||||
HeapAllocator(uint64_t address, uint64_t size) : HeapAllocator(address, size, 4 * MemoryConstants::megaByte) {
|
HeapAllocator(uint64_t address, uint64_t size) : HeapAllocator(address, size, MemoryConstants::pageSize) {
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapAllocator(uint64_t address, uint64_t size, size_t threshold) : size(size), availableSize(size), sizeThreshold(threshold) {
|
HeapAllocator(uint64_t address, uint64_t size, size_t allocationAlignment) : HeapAllocator(address, size, allocationAlignment, 4 * MemoryConstants::megaByte) {
|
||||||
|
}
|
||||||
|
|
||||||
|
HeapAllocator(uint64_t address, uint64_t size, size_t allocationAlignment, size_t threshold) : size(size), availableSize(size), allocationAlignment(allocationAlignment), sizeThreshold(threshold) {
|
||||||
pLeftBound = address;
|
pLeftBound = address;
|
||||||
pRightBound = address + size;
|
pRightBound = address + size;
|
||||||
freedChunksBig.reserve(10);
|
freedChunksBig.reserve(10);
|
||||||
@@ -123,8 +126,8 @@ class HeapAllocator {
|
|||||||
uint64_t availableSize;
|
uint64_t availableSize;
|
||||||
uint64_t pLeftBound;
|
uint64_t pLeftBound;
|
||||||
uint64_t pRightBound;
|
uint64_t pRightBound;
|
||||||
|
size_t allocationAlignment;
|
||||||
const size_t sizeThreshold;
|
const size_t sizeThreshold;
|
||||||
size_t allocationAlignment = MemoryConstants::pageSize;
|
|
||||||
|
|
||||||
std::vector<HeapChunk> freedChunksSmall;
|
std::vector<HeapChunk> freedChunksSmall;
|
||||||
std::vector<HeapChunk> freedChunksBig;
|
std::vector<HeapChunk> freedChunksBig;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2017-2020 Intel Corporation
|
* Copyright (C) 2017-2021 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -17,10 +17,12 @@
|
|||||||
using namespace NEO;
|
using namespace NEO;
|
||||||
|
|
||||||
const size_t sizeThreshold = 16 * 4096;
|
const size_t sizeThreshold = 16 * 4096;
|
||||||
|
const size_t allocationAlignment = MemoryConstants::pageSize;
|
||||||
|
|
||||||
class HeapAllocatorUnderTest : public HeapAllocator {
|
class HeapAllocatorUnderTest : public HeapAllocator {
|
||||||
public:
|
public:
|
||||||
HeapAllocatorUnderTest(uint64_t address, uint64_t size, size_t threshold) : HeapAllocator(address, size, threshold) {}
|
HeapAllocatorUnderTest(uint64_t address, uint64_t size, size_t alignment, size_t threshold) : HeapAllocator(address, size, alignment, threshold) {}
|
||||||
|
HeapAllocatorUnderTest(uint64_t address, uint64_t size, size_t alignment) : HeapAllocator(address, size, alignment) {}
|
||||||
HeapAllocatorUnderTest(uint64_t address, uint64_t size) : HeapAllocator(address, size) {}
|
HeapAllocatorUnderTest(uint64_t address, uint64_t size) : HeapAllocator(address, size) {}
|
||||||
|
|
||||||
uint64_t getLeftBound() const { return this->pLeftBound; }
|
uint64_t getLeftBound() const { return this->pLeftBound; }
|
||||||
@@ -41,7 +43,14 @@ class HeapAllocatorUnderTest : public HeapAllocator {
|
|||||||
using HeapAllocator::allocationAlignment;
|
using HeapAllocator::allocationAlignment;
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST(HeapAllocatorTest, WhenHeapAllocatorIsCreatedThenThresholdIsSet) {
|
TEST(HeapAllocatorTest, WhenHeapAllocatorIsCreatedWithAlignmentThenAlignmentIsSet) {
|
||||||
|
uint64_t ptrBase = 0x100000llu;
|
||||||
|
size_t size = 1024 * 4096;
|
||||||
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, allocationAlignment);
|
||||||
|
EXPECT_EQ(MemoryConstants::pageSize, heapAllocator->allocationAlignment);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(HeapAllocatorTest, WhenHeapAllocatorIsCreatedThenThresholdAndAlignmentIsSet) {
|
||||||
uint64_t ptrBase = 0x100000llu;
|
uint64_t ptrBase = 0x100000llu;
|
||||||
size_t size = 1024 * 4096;
|
size_t size = 1024 * 4096;
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size);
|
||||||
@@ -68,7 +77,7 @@ TEST(HeapAllocatorTest, WhenAllocatingThenUsageStatisticsAreUpdated) {
|
|||||||
TEST(HeapAllocatorTest, GivenExactSizeChunkInFreedChunksWhenGetIsCalledThenChunkIsReturned) {
|
TEST(HeapAllocatorTest, GivenExactSizeChunkInFreedChunksWhenGetIsCalledThenChunkIsReturned) {
|
||||||
uint64_t ptrBase = 0x100000llu;
|
uint64_t ptrBase = 0x100000llu;
|
||||||
size_t size = 1024 * 4096;
|
size_t size = 1024 * 4096;
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, sizeThreshold);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, allocationAlignment, sizeThreshold);
|
||||||
|
|
||||||
std::vector<HeapChunk> freedChunks;
|
std::vector<HeapChunk> freedChunks;
|
||||||
uint64_t ptrFreed = 0x101000llu;
|
uint64_t ptrFreed = 0x101000llu;
|
||||||
@@ -84,7 +93,7 @@ TEST(HeapAllocatorTest, GivenExactSizeChunkInFreedChunksWhenGetIsCalledThenChunk
|
|||||||
TEST(HeapAllocatorTest, GivenOnlySmallerSizeChunksInFreedChunksWhenGetIsCalledThenNullptrIsReturned) {
|
TEST(HeapAllocatorTest, GivenOnlySmallerSizeChunksInFreedChunksWhenGetIsCalledThenNullptrIsReturned) {
|
||||||
uint64_t ptrBase = 0x100000llu;
|
uint64_t ptrBase = 0x100000llu;
|
||||||
size_t size = 1024 * 4096;
|
size_t size = 1024 * 4096;
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, sizeThreshold);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, allocationAlignment, sizeThreshold);
|
||||||
|
|
||||||
std::vector<HeapChunk> freedChunks;
|
std::vector<HeapChunk> freedChunks;
|
||||||
|
|
||||||
@@ -109,7 +118,7 @@ TEST(HeapAllocatorTest, GivenOnlyBiggerSizeChunksInFreedChunksWhenGetIsCalledThe
|
|||||||
size_t size = 1024 * 4096;
|
size_t size = 1024 * 4096;
|
||||||
auto pUpperBound = ptrBase + size;
|
auto pUpperBound = ptrBase + size;
|
||||||
|
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, sizeThreshold);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, allocationAlignment, sizeThreshold);
|
||||||
|
|
||||||
std::vector<HeapChunk> freedChunks;
|
std::vector<HeapChunk> freedChunks;
|
||||||
uint64_t ptrExpected = 0llu;
|
uint64_t ptrExpected = 0llu;
|
||||||
@@ -140,7 +149,7 @@ TEST(HeapAllocatorTest, GivenOnlyMoreThanTwiceBiggerSizeChunksInFreedChunksWhenG
|
|||||||
size_t size = 1024 * 4096;
|
size_t size = 1024 * 4096;
|
||||||
auto pLowerBound = ptrBase;
|
auto pLowerBound = ptrBase;
|
||||||
|
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, sizeThreshold);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, allocationAlignment, sizeThreshold);
|
||||||
|
|
||||||
std::vector<HeapChunk> freedChunks;
|
std::vector<HeapChunk> freedChunks;
|
||||||
uint64_t ptrExpected = 0llu;
|
uint64_t ptrExpected = 0llu;
|
||||||
@@ -171,7 +180,7 @@ TEST(HeapAllocatorTest, GivenStoredChunkAdjacentToLeftBoundaryOfIncomingChunkWhe
|
|||||||
size_t size = 1024 * 4096;
|
size_t size = 1024 * 4096;
|
||||||
auto pLowerBound = ptrBase;
|
auto pLowerBound = ptrBase;
|
||||||
|
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, sizeThreshold);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, allocationAlignment, sizeThreshold);
|
||||||
|
|
||||||
std::vector<HeapChunk> freedChunks;
|
std::vector<HeapChunk> freedChunks;
|
||||||
uint64_t ptrExpected = 0llu;
|
uint64_t ptrExpected = 0llu;
|
||||||
@@ -206,7 +215,7 @@ TEST(HeapAllocatorTest, GivenStoredChunkAdjacentToRightBoundaryOfIncomingChunkWh
|
|||||||
size_t size = 1024 * 4096;
|
size_t size = 1024 * 4096;
|
||||||
auto pLowerBound = ptrBase;
|
auto pLowerBound = ptrBase;
|
||||||
|
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, sizeThreshold);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, allocationAlignment, sizeThreshold);
|
||||||
|
|
||||||
std::vector<HeapChunk> freedChunks;
|
std::vector<HeapChunk> freedChunks;
|
||||||
uint64_t ptrExpected = 0llu;
|
uint64_t ptrExpected = 0llu;
|
||||||
@@ -244,7 +253,7 @@ TEST(HeapAllocatorTest, GivenStoredChunkNotAdjacentToIncomingChunkWhenStoreIsCal
|
|||||||
size_t size = 1024 * 4096;
|
size_t size = 1024 * 4096;
|
||||||
auto pLowerBound = ptrBase;
|
auto pLowerBound = ptrBase;
|
||||||
|
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, sizeThreshold);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, allocationAlignment, sizeThreshold);
|
||||||
|
|
||||||
std::vector<HeapChunk> freedChunks;
|
std::vector<HeapChunk> freedChunks;
|
||||||
|
|
||||||
@@ -271,7 +280,7 @@ TEST(HeapAllocatorTest, GivenStoredChunkNotAdjacentToIncomingChunkWhenStoreIsCal
|
|||||||
TEST(HeapAllocatorTest, WhenAllocatingThenEntryIsAddedToMap) {
|
TEST(HeapAllocatorTest, WhenAllocatingThenEntryIsAddedToMap) {
|
||||||
uint64_t ptrBase = 0x100000llu;
|
uint64_t ptrBase = 0x100000llu;
|
||||||
size_t size = 1024 * 4096;
|
size_t size = 1024 * 4096;
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, sizeThreshold);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, allocationAlignment, sizeThreshold);
|
||||||
|
|
||||||
size_t ptrSize = 4096;
|
size_t ptrSize = 4096;
|
||||||
uint64_t ptr = heapAllocator->allocate(ptrSize);
|
uint64_t ptr = heapAllocator->allocate(ptrSize);
|
||||||
@@ -292,7 +301,7 @@ TEST(HeapAllocatorTest, WhenFreeingThenEntryIsRemovedFromMapAndSpaceMadeAvailabl
|
|||||||
auto pLeftBound = ptrBase;
|
auto pLeftBound = ptrBase;
|
||||||
auto pRightBound = pLeftBound + size;
|
auto pRightBound = pLeftBound + size;
|
||||||
|
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, sizeThreshold);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, allocationAlignment, sizeThreshold);
|
||||||
|
|
||||||
size_t ptrSize = 4096;
|
size_t ptrSize = 4096;
|
||||||
uint64_t ptr = heapAllocator->allocate(ptrSize);
|
uint64_t ptr = heapAllocator->allocate(ptrSize);
|
||||||
@@ -325,7 +334,7 @@ TEST(HeapAllocatorTest, WhenAllocatingMultipleThenEachAllocationIsDistinct) {
|
|||||||
size_t doubleAllocSize = 4096 * 2;
|
size_t doubleAllocSize = 4096 * 2;
|
||||||
|
|
||||||
for (uint32_t i = 0u; i < 2u; i++) {
|
for (uint32_t i = 0u; i < 2u; i++) {
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, sizeThreshold);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, allocationAlignment, sizeThreshold);
|
||||||
doubleAllocSize = allocSize * 2;
|
doubleAllocSize = allocSize * 2;
|
||||||
auto pLeftBound = ptrBase;
|
auto pLeftBound = ptrBase;
|
||||||
auto pRightBound = pLeftBound + size;
|
auto pRightBound = pLeftBound + size;
|
||||||
@@ -366,7 +375,7 @@ TEST(HeapAllocatorTest, WhenAllocatingMultipleThenEachAllocationIsDistinct) {
|
|||||||
TEST(HeapAllocatorTest, GivenNoSpaceLeftWhenAllocatingThenZeroIsReturned) {
|
TEST(HeapAllocatorTest, GivenNoSpaceLeftWhenAllocatingThenZeroIsReturned) {
|
||||||
uint64_t ptrBase = 0x100000llu;
|
uint64_t ptrBase = 0x100000llu;
|
||||||
size_t size = 1024 * 4096;
|
size_t size = 1024 * 4096;
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, sizeThreshold);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, allocationAlignment, sizeThreshold);
|
||||||
|
|
||||||
size_t ptrSize = 4096;
|
size_t ptrSize = 4096;
|
||||||
uint64_t ptr1 = heapAllocator->allocate(ptrSize);
|
uint64_t ptr1 = heapAllocator->allocate(ptrSize);
|
||||||
@@ -388,7 +397,7 @@ TEST(HeapAllocatorTest, GivenNoSpaceLeftWhenAllocatingThenZeroIsReturned) {
|
|||||||
TEST(HeapAllocatorTest, GivenReverseOrderWhenFreeingThenHeapAllocatorStateIsCorrect) {
|
TEST(HeapAllocatorTest, GivenReverseOrderWhenFreeingThenHeapAllocatorStateIsCorrect) {
|
||||||
uint64_t ptrBase = 0x100000llu;
|
uint64_t ptrBase = 0x100000llu;
|
||||||
size_t size = 1024 * 4096;
|
size_t size = 1024 * 4096;
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, sizeThreshold);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, allocationAlignment, sizeThreshold);
|
||||||
|
|
||||||
auto pLeftBound = ptrBase;
|
auto pLeftBound = ptrBase;
|
||||||
auto pRightBound = pLeftBound + size;
|
auto pRightBound = pLeftBound + size;
|
||||||
@@ -422,7 +431,7 @@ TEST(HeapAllocatorTest, GivenReverseOrderWhenFreeingThenHeapAllocatorStateIsCorr
|
|||||||
TEST(HeapAllocatorTest, GivenNoMemoryLeftWhenAllocatingThenZeroIsReturned) {
|
TEST(HeapAllocatorTest, GivenNoMemoryLeftWhenAllocatingThenZeroIsReturned) {
|
||||||
uint64_t ptrBase = 0x100000llu;
|
uint64_t ptrBase = 0x100000llu;
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, sizeThreshold);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, allocationAlignment, sizeThreshold);
|
||||||
|
|
||||||
size_t ptrSize = 4096;
|
size_t ptrSize = 4096;
|
||||||
uint64_t ptr = heapAllocator->allocate(ptrSize);
|
uint64_t ptr = heapAllocator->allocate(ptrSize);
|
||||||
@@ -434,7 +443,7 @@ TEST(HeapAllocatorTest, GivenNoMemoryLeftWhenAllocatingThenZeroIsReturned) {
|
|||||||
TEST(HeapAllocatorTest, GivenSizeGreaterThanMemoryLeftWhenAllocatingThenZeroIsReturned) {
|
TEST(HeapAllocatorTest, GivenSizeGreaterThanMemoryLeftWhenAllocatingThenZeroIsReturned) {
|
||||||
uint64_t ptrBase = 0x100000llu;
|
uint64_t ptrBase = 0x100000llu;
|
||||||
size_t size = 11 * 4096;
|
size_t size = 11 * 4096;
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, 3 * 4096);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, allocationAlignment, 3 * 4096);
|
||||||
size_t remainingSize = size;
|
size_t remainingSize = size;
|
||||||
|
|
||||||
// first small succeeds
|
// first small succeeds
|
||||||
@@ -477,7 +486,7 @@ TEST(HeapAllocatorTest, GivenSizeGreaterThanMemoryLeftWhenAllocatingThenZeroIsRe
|
|||||||
|
|
||||||
TEST(HeapAllocatorTest, GivenNullWhenFreeingThenNothingHappens) {
|
TEST(HeapAllocatorTest, GivenNullWhenFreeingThenNothingHappens) {
|
||||||
uint64_t ptrBase = 0x100000llu;
|
uint64_t ptrBase = 0x100000llu;
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, sizeThreshold, sizeThreshold);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, sizeThreshold, allocationAlignment, sizeThreshold);
|
||||||
|
|
||||||
heapAllocator->free(0llu, 0);
|
heapAllocator->free(0llu, 0);
|
||||||
|
|
||||||
@@ -488,7 +497,7 @@ TEST(HeapAllocatorTest, GivenNullWhenFreeingThenNothingHappens) {
|
|||||||
TEST(HeapAllocatorTest, WhenFreeingThenMemoryAvailableForAllocation) {
|
TEST(HeapAllocatorTest, WhenFreeingThenMemoryAvailableForAllocation) {
|
||||||
uint64_t ptrBase = 0x100000llu;
|
uint64_t ptrBase = 0x100000llu;
|
||||||
size_t size = 1024 * 4096;
|
size_t size = 1024 * 4096;
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, sizeThreshold);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, allocationAlignment, sizeThreshold);
|
||||||
|
|
||||||
auto pLeftBound = ptrBase;
|
auto pLeftBound = ptrBase;
|
||||||
auto pRightBound = pLeftBound + size;
|
auto pRightBound = pLeftBound + size;
|
||||||
@@ -538,7 +547,7 @@ TEST(HeapAllocatorTest, WhenFreeingThenMemoryAvailableForAllocation) {
|
|||||||
TEST(HeapAllocatorTest, WhenFreeingChunkThenMemoryAvailableForAllocation) {
|
TEST(HeapAllocatorTest, WhenFreeingChunkThenMemoryAvailableForAllocation) {
|
||||||
uint64_t ptrBase = 0x100000llu;
|
uint64_t ptrBase = 0x100000llu;
|
||||||
size_t size = 1024 * 4096;
|
size_t size = 1024 * 4096;
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, sizeThreshold);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, allocationAlignment, sizeThreshold);
|
||||||
|
|
||||||
auto pLeftBound = ptrBase;
|
auto pLeftBound = ptrBase;
|
||||||
auto pRightBound = pLeftBound + size;
|
auto pRightBound = pLeftBound + size;
|
||||||
@@ -604,7 +613,7 @@ TEST(HeapAllocatorTest, WhenFreeingChunkThenMemoryAvailableForAllocation) {
|
|||||||
TEST(HeapAllocatorTest, GivenSmallAllocationGreaterThanAvailableSizeWhenAllocatingThenZeroIsReturned) {
|
TEST(HeapAllocatorTest, GivenSmallAllocationGreaterThanAvailableSizeWhenAllocatingThenZeroIsReturned) {
|
||||||
uint64_t ptrBase = 0x100000llu;
|
uint64_t ptrBase = 0x100000llu;
|
||||||
size_t size = 1024 * 4096;
|
size_t size = 1024 * 4096;
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, sizeThreshold);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, allocationAlignment, sizeThreshold);
|
||||||
|
|
||||||
size_t ptrSize1 = size - 4096;
|
size_t ptrSize1 = size - 4096;
|
||||||
uint64_t ptr1 = heapAllocator->allocate(ptrSize1);
|
uint64_t ptr1 = heapAllocator->allocate(ptrSize1);
|
||||||
@@ -621,7 +630,7 @@ TEST(HeapAllocatorTest, GivenSmallAllocationGreaterThanAvailableSizeWhenAllocati
|
|||||||
TEST(HeapAllocatorTest, GivenBigAllocationGreaterThanAvailableSizeWhenAllocatingThenZeroIsReturned) {
|
TEST(HeapAllocatorTest, GivenBigAllocationGreaterThanAvailableSizeWhenAllocatingThenZeroIsReturned) {
|
||||||
uint64_t ptrBase = 0x100000llu;
|
uint64_t ptrBase = 0x100000llu;
|
||||||
size_t size = 1024 * 4096;
|
size_t size = 1024 * 4096;
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, sizeThreshold);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, allocationAlignment, sizeThreshold);
|
||||||
|
|
||||||
size_t ptrSize1 = 8192;
|
size_t ptrSize1 = 8192;
|
||||||
uint64_t ptr1 = heapAllocator->allocate(ptrSize1);
|
uint64_t ptr1 = heapAllocator->allocate(ptrSize1);
|
||||||
@@ -669,7 +678,7 @@ TEST(HeapAllocatorTest, WhenMemoryIsAllocatedThenAllocationsDoNotOverlap) {
|
|||||||
size_t bigAllocationThreshold = (512 + 256) * reqAlignment;
|
size_t bigAllocationThreshold = (512 + 256) * reqAlignment;
|
||||||
|
|
||||||
memset(pBasePtr, 0, static_cast<size_t>(allocatorSize));
|
memset(pBasePtr, 0, static_cast<size_t>(allocatorSize));
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(basePtr, allocatorSize, bigAllocationThreshold);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(basePtr, allocatorSize, allocationAlignment, bigAllocationThreshold);
|
||||||
heapAllocator->allocationAlignment = reqAlignment;
|
heapAllocator->allocationAlignment = reqAlignment;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < maxIndex; i++) {
|
for (uint32_t i = 0; i < maxIndex; i++) {
|
||||||
@@ -732,7 +741,7 @@ TEST(HeapAllocatorTest, GivenLargeAllocationsWhenFreeingThenSpaceIsDefragmented)
|
|||||||
size_t doubleallocSize = 2 * allocSize;
|
size_t doubleallocSize = 2 * allocSize;
|
||||||
size_t tripleallocSize = 3 * allocSize;
|
size_t tripleallocSize = 3 * allocSize;
|
||||||
|
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, threshold);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, allocationAlignment, threshold);
|
||||||
|
|
||||||
std::vector<HeapChunk> &freedChunks = heapAllocator->getFreedChunksBig();
|
std::vector<HeapChunk> &freedChunks = heapAllocator->getFreedChunksBig();
|
||||||
|
|
||||||
@@ -789,7 +798,7 @@ TEST(HeapAllocatorTest, GivenSmallAllocationsWhenFreeingThenSpaceIsDefragmented)
|
|||||||
size_t allocSize = MemoryConstants::pageSize;
|
size_t allocSize = MemoryConstants::pageSize;
|
||||||
size_t doubleallocSize = 2 * allocSize;
|
size_t doubleallocSize = 2 * allocSize;
|
||||||
|
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, threshold);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, allocationAlignment, threshold);
|
||||||
|
|
||||||
std::vector<HeapChunk> &freedChunks = heapAllocator->getFreedChunksSmall();
|
std::vector<HeapChunk> &freedChunks = heapAllocator->getFreedChunksSmall();
|
||||||
|
|
||||||
@@ -840,7 +849,7 @@ TEST(HeapAllocatorTest, Given10SmallAllocationsWhenFreedInTheSameOrderThenLastCh
|
|||||||
size_t size = 1024 * 4096;
|
size_t size = 1024 * 4096;
|
||||||
size_t threshold = 2 * 4096;
|
size_t threshold = 2 * 4096;
|
||||||
|
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, threshold);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, allocationAlignment, threshold);
|
||||||
|
|
||||||
std::vector<HeapChunk> &freedChunks = heapAllocator->getFreedChunksSmall();
|
std::vector<HeapChunk> &freedChunks = heapAllocator->getFreedChunksSmall();
|
||||||
|
|
||||||
@@ -876,7 +885,7 @@ TEST(HeapAllocatorTest, Given10SmallAllocationsWhenMergedToBigAllocatedAsSmallSp
|
|||||||
|
|
||||||
size_t threshold = 4 * 4096;
|
size_t threshold = 4 * 4096;
|
||||||
|
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, threshold);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, allocationAlignment, threshold);
|
||||||
|
|
||||||
std::vector<HeapChunk> &freedChunksSmall = heapAllocator->getFreedChunksSmall();
|
std::vector<HeapChunk> &freedChunksSmall = heapAllocator->getFreedChunksSmall();
|
||||||
std::vector<HeapChunk> &freedChunksBig = heapAllocator->getFreedChunksBig();
|
std::vector<HeapChunk> &freedChunksBig = heapAllocator->getFreedChunksBig();
|
||||||
@@ -937,7 +946,7 @@ TEST(HeapAllocatorTest, Given10SmallAllocationsWhenMergedToBigAllocatedAsSmallNo
|
|||||||
|
|
||||||
size_t threshold = 4 * 4096;
|
size_t threshold = 4 * 4096;
|
||||||
|
|
||||||
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, threshold);
|
auto heapAllocator = std::make_unique<HeapAllocatorUnderTest>(ptrBase, size, allocationAlignment, threshold);
|
||||||
|
|
||||||
std::vector<HeapChunk> &freedChunksSmall = heapAllocator->getFreedChunksSmall();
|
std::vector<HeapChunk> &freedChunksSmall = heapAllocator->getFreedChunksSmall();
|
||||||
std::vector<HeapChunk> &freedChunksBig = heapAllocator->getFreedChunksBig();
|
std::vector<HeapChunk> &freedChunksBig = heapAllocator->getFreedChunksBig();
|
||||||
|
|||||||
Reference in New Issue
Block a user