Revert "fix: HeapAllocator - ensure getBaseAddress returns initial base address"
This reverts commit ffec97acc5
.
Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:
parent
ff1c5837fa
commit
58e45afd39
|
@ -31,7 +31,7 @@ class HeapAllocator {
|
|||
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) : baseAddress(address), size(size), availableSize(size), allocationAlignment(allocationAlignment), sizeThreshold(threshold) {
|
||||
HeapAllocator(uint64_t address, uint64_t size, size_t allocationAlignment, size_t threshold) : size(size), availableSize(size), allocationAlignment(allocationAlignment), sizeThreshold(threshold) {
|
||||
pLeftBound = address;
|
||||
pRightBound = address + size;
|
||||
freedChunksBig.reserve(10);
|
||||
|
@ -59,11 +59,10 @@ class HeapAllocator {
|
|||
double getUsage() const;
|
||||
|
||||
uint64_t getBaseAddress() const {
|
||||
return this->baseAddress;
|
||||
return this->pLeftBound;
|
||||
}
|
||||
|
||||
protected:
|
||||
const uint64_t baseAddress;
|
||||
const uint64_t size;
|
||||
uint64_t availableSize;
|
||||
uint64_t pLeftBound;
|
||||
|
|
|
@ -1438,19 +1438,14 @@ TEST(HeapAllocatorTest, givenZeroAlignmentPassedWhenAllocatingMemoryWithCustomAl
|
|||
EXPECT_EQ(alignUp(heapBase, allocationAlignment), ptr);
|
||||
}
|
||||
|
||||
TEST(HeapAllocatorTest, whenGetBaseAddressIsCalledThenReturnInitialBaseAddress) {
|
||||
TEST(HeapAllocatorTest, whenGetBaseAddressIsCalledThenReturnInitialLeftBoundAddress) {
|
||||
const uint64_t heapBase = 0x100000llu;
|
||||
const size_t heapSize = 16 * MemoryConstants::megaByte;
|
||||
const size_t sizeThreshold = 4 * MemoryConstants::megaByte;
|
||||
|
||||
const size_t heapSize = 1024 * 4096;
|
||||
HeapAllocatorUnderTest heapAllocator(heapBase, heapSize, allocationAlignment, sizeThreshold);
|
||||
|
||||
EXPECT_EQ(heapBase, heapAllocator.getBaseAddress());
|
||||
|
||||
size_t bigChunk = 5 * MemoryConstants::megaByte;
|
||||
EXPECT_NE(0u, heapAllocator.allocate(bigChunk));
|
||||
EXPECT_EQ(heapBase, heapAllocator.getBaseAddress());
|
||||
|
||||
size_t smallChunk = 4096;
|
||||
EXPECT_NE(0u, heapAllocator.allocate(smallChunk));
|
||||
size_t sizeToAlloc = 4096;
|
||||
heapAllocator.allocate(sizeToAlloc);
|
||||
EXPECT_EQ(heapBase, heapAllocator.getBaseAddress());
|
||||
}
|
Loading…
Reference in New Issue