From ce4a75e12152e9a286175e02f83448494b43c893 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Fri, 1 Feb 2019 13:49:24 +0100 Subject: [PATCH] Require same allocation type when obtaining reusable allocation Change-Id: I829301b83a6214bcfb4fc9f2692f21ae9a002456 Signed-off-by: Mateusz Jablonski --- runtime/command_queue/command_queue.cpp | 9 ++- runtime/command_queue/enqueue_svm.h | 9 ++- .../command_stream_receiver.cpp | 21 +++---- .../experimental_command_buffer.cpp | 8 +-- runtime/memory_manager/allocations_list.h | 8 +-- .../internal_allocation_storage.cpp | 14 ++--- .../internal_allocation_storage.h | 6 +- .../command_queue/command_queue_tests.cpp | 16 +++-- ...and_stream_receiver_flush_task_2_tests.cpp | 6 +- .../experimental_command_buffer_tests.cpp | 6 +- .../internal_allocation_storage_tests.cpp | 60 +++++-------------- 11 files changed, 64 insertions(+), 99 deletions(-) diff --git a/runtime/command_queue/command_queue.cpp b/runtime/command_queue/command_queue.cpp index ce7eab9e82..256e95914f 100644 --- a/runtime/command_queue/command_queue.cpp +++ b/runtime/command_queue/command_queue.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Intel Corporation + * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -209,14 +209,13 @@ LinearStream &CommandQueue::getCS(size_t minRequiredSize) { auto requiredSize = minRequiredSize + CSRequirements::csOverfetchSize; - GraphicsAllocation *allocation = storageForAllocation->obtainReusableAllocation(requiredSize, false).release(); + auto allocationType = GraphicsAllocation::AllocationType::LINEAR_STREAM; + GraphicsAllocation *allocation = storageForAllocation->obtainReusableAllocation(requiredSize, allocationType).release(); if (!allocation) { - allocation = memoryManager->allocateGraphicsMemoryWithProperties({requiredSize, GraphicsAllocation::AllocationType::LINEAR_STREAM}); + allocation = memoryManager->allocateGraphicsMemoryWithProperties({requiredSize, allocationType}); } - allocation->setAllocationType(GraphicsAllocation::AllocationType::LINEAR_STREAM); - // Deallocate the old block, if not null auto oldAllocation = commandStream->getGraphicsAllocation(); diff --git a/runtime/command_queue/enqueue_svm.h b/runtime/command_queue/enqueue_svm.h index 0d7206d038..d3f29469a4 100644 --- a/runtime/command_queue/enqueue_svm.h +++ b/runtime/command_queue/enqueue_svm.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2018 Intel Corporation + * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -224,15 +224,14 @@ cl_int CommandQueueHw::enqueueSVMMemFill(void *svmPtr, auto commandStreamReceieverOwnership = getCommandStreamReceiver().obtainUniqueOwnership(); auto storageWithAllocations = getCommandStreamReceiver().getInternalAllocationStorage(); - auto patternAllocation = storageWithAllocations->obtainReusableAllocation(patternSize, false).release(); + auto allocationType = GraphicsAllocation::AllocationType::FILL_PATTERN; + auto patternAllocation = storageWithAllocations->obtainReusableAllocation(patternSize, allocationType).release(); commandStreamReceieverOwnership.unlock(); if (!patternAllocation) { - patternAllocation = memoryManager->allocateGraphicsMemoryWithProperties({patternSize, GraphicsAllocation::AllocationType::FILL_PATTERN}); + patternAllocation = memoryManager->allocateGraphicsMemoryWithProperties({patternSize, allocationType}); } - patternAllocation->setAllocationType(GraphicsAllocation::AllocationType::FILL_PATTERN); - if (patternSize == 1) { int patternInt = (uint32_t)((*(uint8_t *)pattern << 24) | (*(uint8_t *)pattern << 16) | (*(uint8_t *)pattern << 8) | *(uint8_t *)pattern); memcpy_s(patternAllocation->getUnderlyingBuffer(), sizeof(int), &patternInt, sizeof(int)); diff --git a/runtime/command_stream/command_stream_receiver.cpp b/runtime/command_stream/command_stream_receiver.cpp index 592fcf6c58..e013323fa3 100644 --- a/runtime/command_stream/command_stream_receiver.cpp +++ b/runtime/command_stream/command_stream_receiver.cpp @@ -131,14 +131,12 @@ LinearStream &CommandStreamReceiver::getCS(size_t minRequiredSize) { minRequiredSize = alignUp(minRequiredSize, MemoryConstants::pageSize); auto requiredSize = minRequiredSize + CSRequirements::csOverfetchSize; - - auto allocation = internalAllocationStorage->obtainReusableAllocation(requiredSize, false).release(); + auto allocationType = GraphicsAllocation::AllocationType::LINEAR_STREAM; + auto allocation = internalAllocationStorage->obtainReusableAllocation(requiredSize, allocationType).release(); if (!allocation) { - allocation = getMemoryManager()->allocateGraphicsMemoryWithProperties({requiredSize, GraphicsAllocation::AllocationType::LINEAR_STREAM}); + allocation = getMemoryManager()->allocateGraphicsMemoryWithProperties({requiredSize, allocationType}); } - allocation->setAllocationType(GraphicsAllocation::AllocationType::LINEAR_STREAM); - //pass current allocation to reusable list if (commandStream.getCpuBase()) { internalAllocationStorage->storeAllocation(std::unique_ptr(commandStream.getGraphicsAllocation()), REUSABLE_ALLOCATION); @@ -283,21 +281,18 @@ void CommandStreamReceiver::allocateHeapMemory(IndirectHeap::Type heapType, minRequiredSize += reservedSize; finalHeapSize = alignUp(std::max(finalHeapSize, minRequiredSize), MemoryConstants::pageSize); - - auto heapMemory = internalAllocationStorage->obtainReusableAllocation(finalHeapSize, requireInternalHeap).release(); + auto allocationType = GraphicsAllocation::AllocationType::LINEAR_STREAM; + if (requireInternalHeap) { + allocationType = GraphicsAllocation::AllocationType::INTERNAL_HEAP; + } + auto heapMemory = internalAllocationStorage->obtainReusableAllocation(finalHeapSize, allocationType).release(); if (!heapMemory) { - auto allocationType = GraphicsAllocation::AllocationType::LINEAR_STREAM; - if (requireInternalHeap) { - allocationType = GraphicsAllocation::AllocationType::INTERNAL_HEAP; - } heapMemory = getMemoryManager()->allocateGraphicsMemoryWithProperties({finalHeapSize, allocationType}); } else { finalHeapSize = std::max(heapMemory->getUnderlyingBufferSize(), finalHeapSize); } - heapMemory->setAllocationType(GraphicsAllocation::AllocationType::LINEAR_STREAM); - if (IndirectHeap::SURFACE_STATE == heapType) { DEBUG_BREAK_IF(minRequiredSize > defaultSshSize - MemoryConstants::pageSize); finalHeapSize = defaultSshSize - MemoryConstants::pageSize; diff --git a/runtime/command_stream/experimental_command_buffer.cpp b/runtime/command_stream/experimental_command_buffer.cpp index 6524685676..879ca5d086 100644 --- a/runtime/command_stream/experimental_command_buffer.cpp +++ b/runtime/command_stream/experimental_command_buffer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Intel Corporation + * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -59,11 +59,11 @@ void ExperimentalCommandBuffer::getCS(size_t minRequiredSize) { auto requiredSize = minRequiredSize + CSRequirements::csOverfetchSize; auto storageWithAllocations = commandStreamReceiver->getInternalAllocationStorage(); - GraphicsAllocation *allocation = storageWithAllocations->obtainReusableAllocation(requiredSize, false).release(); + auto allocationType = GraphicsAllocation::AllocationType::LINEAR_STREAM; + GraphicsAllocation *allocation = storageWithAllocations->obtainReusableAllocation(requiredSize, allocationType).release(); if (!allocation) { - allocation = memoryManager->allocateGraphicsMemoryWithProperties({requiredSize, GraphicsAllocation::AllocationType::LINEAR_STREAM}); + allocation = memoryManager->allocateGraphicsMemoryWithProperties({requiredSize, allocationType}); } - allocation->setAllocationType(GraphicsAllocation::AllocationType::LINEAR_STREAM); // Deallocate the old block, if not null auto oldAllocation = currentStream->getGraphicsAllocation(); if (oldAllocation) { diff --git a/runtime/memory_manager/allocations_list.h b/runtime/memory_manager/allocations_list.h index 810e78ab62..f8fb4ac38f 100644 --- a/runtime/memory_manager/allocations_list.h +++ b/runtime/memory_manager/allocations_list.h @@ -1,21 +1,19 @@ /* - * Copyright (C) 2018 Intel Corporation + * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * */ #pragma once -#include "runtime/utilities/idlist.h" -#include +#include "runtime/memory_manager/graphics_allocation.h" namespace OCLRT { -class GraphicsAllocation; class CommandStreamReceiver; class AllocationsList : public IDList { public: - std::unique_ptr detachAllocation(size_t requiredMinimalSize, CommandStreamReceiver &commandStreamReceiver, bool internalAllocationRequired); + std::unique_ptr detachAllocation(size_t requiredMinimalSize, CommandStreamReceiver &commandStreamReceiver, GraphicsAllocation::AllocationType allocationType); private: GraphicsAllocation *detachAllocationImpl(GraphicsAllocation *, void *); diff --git a/runtime/memory_manager/internal_allocation_storage.cpp b/runtime/memory_manager/internal_allocation_storage.cpp index e0be5d5b28..cb6ca162c7 100644 --- a/runtime/memory_manager/internal_allocation_storage.cpp +++ b/runtime/memory_manager/internal_allocation_storage.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Intel Corporation + * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -57,23 +57,23 @@ void InternalAllocationStorage::freeAllocationsList(uint32_t waitTaskCount, Allo } } -std::unique_ptr InternalAllocationStorage::obtainReusableAllocation(size_t requiredSize, bool internalAllocation) { - auto allocation = allocationsForReuse.detachAllocation(requiredSize, commandStreamReceiver, internalAllocation); +std::unique_ptr InternalAllocationStorage::obtainReusableAllocation(size_t requiredSize, GraphicsAllocation::AllocationType allocationType) { + auto allocation = allocationsForReuse.detachAllocation(requiredSize, commandStreamReceiver, allocationType); return allocation; } struct ReusableAllocationRequirements { size_t requiredMinimalSize; volatile uint32_t *csrTagAddress; - bool internalAllocationRequired; + GraphicsAllocation::AllocationType allocationType; uint32_t contextId; }; -std::unique_ptr AllocationsList::detachAllocation(size_t requiredMinimalSize, CommandStreamReceiver &commandStreamReceiver, bool internalAllocationRequired) { +std::unique_ptr AllocationsList::detachAllocation(size_t requiredMinimalSize, CommandStreamReceiver &commandStreamReceiver, GraphicsAllocation::AllocationType allocationType) { ReusableAllocationRequirements req; req.requiredMinimalSize = requiredMinimalSize; req.csrTagAddress = commandStreamReceiver.getTagAddress(); - req.internalAllocationRequired = internalAllocationRequired; + req.allocationType = allocationType; req.contextId = commandStreamReceiver.getOsContext().getContextId(); GraphicsAllocation *a = nullptr; GraphicsAllocation *retAlloc = processLocked(a, static_cast(&req)); @@ -85,7 +85,7 @@ GraphicsAllocation *AllocationsList::detachAllocationImpl(GraphicsAllocation *, auto *curr = head; while (curr != nullptr) { auto currentTagValue = *req->csrTagAddress; - if ((req->internalAllocationRequired == curr->is32BitAllocation) && + if ((req->allocationType == curr->getAllocationType()) && (curr->getUnderlyingBufferSize() >= req->requiredMinimalSize) && (currentTagValue >= curr->getTaskCount(req->contextId))) { return removeOneImpl(curr, nullptr); diff --git a/runtime/memory_manager/internal_allocation_storage.h b/runtime/memory_manager/internal_allocation_storage.h index 508802eba0..dc556d9f8f 100644 --- a/runtime/memory_manager/internal_allocation_storage.h +++ b/runtime/memory_manager/internal_allocation_storage.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Intel Corporation + * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -7,11 +7,9 @@ #pragma once #include "runtime/memory_manager/allocations_list.h" -#include namespace OCLRT { class CommandStreamReceiver; -class GraphicsAllocation; class InternalAllocationStorage { public: @@ -20,7 +18,7 @@ class InternalAllocationStorage { MOCKABLE_VIRTUAL void cleanAllocationList(uint32_t waitTaskCount, uint32_t allocationUsage); void storeAllocation(std::unique_ptr gfxAllocation, uint32_t allocationUsage); void storeAllocationWithTaskCount(std::unique_ptr gfxAllocation, uint32_t allocationUsage, uint32_t taskCount); - std::unique_ptr obtainReusableAllocation(size_t requiredSize, bool isInternalAllocationRequired); + std::unique_ptr obtainReusableAllocation(size_t requiredSize, GraphicsAllocation::AllocationType allocationType); AllocationsList &getTemporaryAllocations() { return temporaryAllocations; } AllocationsList &getAllocationsForReuse() { return allocationsForReuse; } diff --git a/unit_tests/command_queue/command_queue_tests.cpp b/unit_tests/command_queue/command_queue_tests.cpp index 6aebe47a1f..0b1c6f50df 100644 --- a/unit_tests/command_queue/command_queue_tests.cpp +++ b/unit_tests/command_queue/command_queue_tests.cpp @@ -331,7 +331,7 @@ TEST_F(CommandQueueCommandStreamTest, givenCommandStreamReceiverWithReusableAllo auto memoryManager = pDevice->getMemoryManager(); size_t requiredSize = alignUp(100, MemoryConstants::pageSize) + CSRequirements::csOverfetchSize; - auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{requiredSize}); + auto allocation = memoryManager->allocateGraphicsMemoryWithProperties({requiredSize, GraphicsAllocation::AllocationType::LINEAR_STREAM}); auto &commandStreamReceiver = cmdQ.getCommandStreamReceiver(); commandStreamReceiver.getInternalAllocationStorage()->storeAllocation(std::unique_ptr(allocation), REUSABLE_ALLOCATION); @@ -623,15 +623,21 @@ TEST_P(CommandQueueIndirectHeapTest, GivenCommandQueueWithHeapWhenGraphicAllocat memoryManager->freeGraphicsMemory(allocation); } -TEST_P(CommandQueueIndirectHeapTest, givenCommandQueueWhenGetIndirectHeapIsCalledThenIndirectHeapAllocationTypeShouldBeSetToLinearStream) { +TEST_P(CommandQueueIndirectHeapTest, givenCommandQueueWhenGetIndirectHeapIsCalledThenIndirectHeapAllocationTypeShouldBeSetToInternalHeapForIohAndLinearStreamForOthers) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; CommandQueue cmdQ(context.get(), pDevice, props); - const auto &indirectHeap = cmdQ.getIndirectHeap(this->GetParam(), 100); + auto heapType = this->GetParam(); + + bool requireInternalHeap = IndirectHeap::INDIRECT_OBJECT == heapType; + const auto &indirectHeap = cmdQ.getIndirectHeap(heapType, 100); auto indirectHeapAllocation = indirectHeap.getGraphicsAllocation(); ASSERT_NE(nullptr, indirectHeapAllocation); - - EXPECT_EQ(GraphicsAllocation::AllocationType::LINEAR_STREAM, indirectHeapAllocation->getAllocationType()); + auto expectedAllocationType = GraphicsAllocation::AllocationType::LINEAR_STREAM; + if (requireInternalHeap) { + expectedAllocationType = GraphicsAllocation::AllocationType::INTERNAL_HEAP; + } + EXPECT_EQ(expectedAllocationType, indirectHeapAllocation->getAllocationType()); } TEST_P(CommandQueueIndirectHeapTest, givenCommandQueueWhenGetHeapMemoryIsCalledThenHeapIsCreated) { diff --git a/unit_tests/command_stream/command_stream_receiver_flush_task_2_tests.cpp b/unit_tests/command_stream/command_stream_receiver_flush_task_2_tests.cpp index 9b79a1634a..992951b2a2 100644 --- a/unit_tests/command_stream/command_stream_receiver_flush_task_2_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_flush_task_2_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Intel Corporation + * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -688,7 +688,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, InForced32BitAllocationsModeDoNotS auto newScratchAllocation = commandStreamReceiver->getScratchAllocation(); EXPECT_NE(scratchAllocation, newScratchAllocation); // Allocation changed - std::unique_ptr allocationReusable = commandStreamReceiver->getInternalAllocationStorage()->obtainReusableAllocation(4096, false); + std::unique_ptr allocationReusable = commandStreamReceiver->getInternalAllocationStorage()->obtainReusableAllocation(4096, GraphicsAllocation::AllocationType::LINEAR_STREAM); if (allocationReusable.get() != nullptr) { if (is64bit) { @@ -722,7 +722,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, InForced32BitAllocationsModeStore3 auto newScratchAllocation = commandStreamReceiver->getScratchAllocation(); EXPECT_NE(scratchAllocation, newScratchAllocation); // Allocation changed - std::unique_ptr allocationTemporary = commandStreamReceiver->getTemporaryAllocations().detachAllocation(0, *commandStreamReceiver, true); + std::unique_ptr allocationTemporary = commandStreamReceiver->getTemporaryAllocations().detachAllocation(0, *commandStreamReceiver, GraphicsAllocation::AllocationType::SCRATCH_SURFACE); EXPECT_EQ(scratchAllocation, allocationTemporary.get()); pDevice->getMemoryManager()->freeGraphicsMemory(allocationTemporary.release()); diff --git a/unit_tests/command_stream/experimental_command_buffer_tests.cpp b/unit_tests/command_stream/experimental_command_buffer_tests.cpp index c8a4a6a8ac..e7436732c3 100644 --- a/unit_tests/command_stream/experimental_command_buffer_tests.cpp +++ b/unit_tests/command_stream/experimental_command_buffer_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Intel Corporation + * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -247,9 +247,9 @@ HWTEST_F(MockExperimentalCommandBufferTest, givenEnabledExperimentalCmdBufferWhe MemoryManager *memoryManager = commandStreamReceiver.getMemoryManager(); //Make two allocations, since CSR will try to reuse it also - auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{3 * MemoryConstants::pageSize}); + auto allocation = memoryManager->allocateGraphicsMemoryWithProperties({3 * MemoryConstants::pageSize, GraphicsAllocation::AllocationType::LINEAR_STREAM}); storage->storeAllocation(std::unique_ptr(allocation), REUSABLE_ALLOCATION); - allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{3 * MemoryConstants::pageSize}); + allocation = memoryManager->allocateGraphicsMemoryWithProperties({3 * MemoryConstants::pageSize, GraphicsAllocation::AllocationType::LINEAR_STREAM}); storage->storeAllocation(std::unique_ptr(allocation), REUSABLE_ALLOCATION); MockExperimentalCommandBuffer *mockExCmdBuffer = static_cast(commandStreamReceiver.experimentalCmdBuffer.get()); diff --git a/unit_tests/memory_manager/internal_allocation_storage_tests.cpp b/unit_tests/memory_manager/internal_allocation_storage_tests.cpp index 71d25b54fc..ba38961ddf 100644 --- a/unit_tests/memory_manager/internal_allocation_storage_tests.cpp +++ b/unit_tests/memory_manager/internal_allocation_storage_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Intel Corporation + * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -74,25 +74,25 @@ TEST_F(InternalAllocationStorageTest, whenCleanAllocationListThenRemoveOnlyCompl } TEST_F(InternalAllocationStorageTest, whenAllocationIsStoredAsReusableButIsStillUsedThenCannotBeObtained) { - auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); + auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(AllocationProperties{MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER}); storage->storeAllocationWithTaskCount(std::unique_ptr(allocation), REUSABLE_ALLOCATION, 2u); auto *hwTag = csr->getTagAddress(); *hwTag = 1u; - auto newAllocation = storage->obtainReusableAllocation(1, false); + auto newAllocation = storage->obtainReusableAllocation(1, GraphicsAllocation::AllocationType::BUFFER); EXPECT_EQ(nullptr, newAllocation); storage->cleanAllocationList(2u, REUSABLE_ALLOCATION); } TEST_F(InternalAllocationStorageTest, whenObtainAllocationFromEmptyReuseListThenReturnNullptr) { - auto allocation2 = storage->obtainReusableAllocation(1, false); + auto allocation2 = storage->obtainReusableAllocation(1, GraphicsAllocation::AllocationType::BUFFER); EXPECT_EQ(nullptr, allocation2); } TEST_F(InternalAllocationStorageTest, whenCompletedAllocationIsStoredAsReusableAndThenCanBeObtained) { - auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); + auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(AllocationProperties{MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER}); EXPECT_NE(nullptr, allocation); storage->storeAllocationWithTaskCount(std::unique_ptr(allocation), REUSABLE_ALLOCATION, 2u); @@ -101,7 +101,7 @@ TEST_F(InternalAllocationStorageTest, whenCompletedAllocationIsStoredAsReusableA auto *hwTag = csr->getTagAddress(); *hwTag = 2u; - auto reusedAllocation = storage->obtainReusableAllocation(1, false).release(); + auto reusedAllocation = storage->obtainReusableAllocation(1, GraphicsAllocation::AllocationType::BUFFER).release(); EXPECT_EQ(allocation, reusedAllocation); EXPECT_TRUE(csr->getAllocationsForReuse().peekIsEmpty()); @@ -110,7 +110,7 @@ TEST_F(InternalAllocationStorageTest, whenCompletedAllocationIsStoredAsReusableA TEST_F(InternalAllocationStorageTest, whenNotUsedAllocationIsStoredAsReusableAndThenCanBeObtained) { - auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); + auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(AllocationProperties{MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER}); EXPECT_NE(nullptr, allocation); EXPECT_FALSE(allocation->isUsed()); EXPECT_EQ(0u, csr->peekTaskCount()); @@ -120,7 +120,7 @@ TEST_F(InternalAllocationStorageTest, whenNotUsedAllocationIsStoredAsReusableAnd EXPECT_EQ(0u, allocation->getTaskCount(csr->getOsContext().getContextId())); EXPECT_FALSE(csr->getAllocationsForReuse().peekIsEmpty()); - auto reusedAllocation = storage->obtainReusableAllocation(1, false).release(); + auto reusedAllocation = storage->obtainReusableAllocation(1, GraphicsAllocation::AllocationType::BUFFER).release(); EXPECT_EQ(allocation, reusedAllocation); EXPECT_TRUE(csr->getAllocationsForReuse().peekIsEmpty()); @@ -131,9 +131,9 @@ TEST_F(InternalAllocationStorageTest, whenObtainAllocationFromMidlleOfReusableLi auto &reusableAllocations = csr->getAllocationsForReuse(); EXPECT_TRUE(reusableAllocations.peekIsEmpty()); - auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{1}); - auto allocation2 = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{10000}); - auto allocation3 = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{1}); + auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(AllocationProperties{1, GraphicsAllocation::AllocationType::BUFFER}); + auto allocation2 = memoryManager->allocateGraphicsMemoryWithProperties(AllocationProperties{10000, GraphicsAllocation::AllocationType::BUFFER}); + auto allocation3 = memoryManager->allocateGraphicsMemoryWithProperties(AllocationProperties{1, GraphicsAllocation::AllocationType::BUFFER}); EXPECT_TRUE(reusableAllocations.peekIsEmpty()); EXPECT_EQ(nullptr, allocation2->next); @@ -163,7 +163,7 @@ TEST_F(InternalAllocationStorageTest, whenObtainAllocationFromMidlleOfReusableLi EXPECT_EQ(allocation3, allocation2->next); EXPECT_EQ(allocation, allocation2->prev); - auto reusableAllocation = storage->obtainReusableAllocation(10000, false).release(); + auto reusableAllocation = storage->obtainReusableAllocation(10000, GraphicsAllocation::AllocationType::BUFFER).release(); EXPECT_EQ(reusableAllocation, allocation2); EXPECT_EQ(nullptr, allocation2->next); EXPECT_EQ(nullptr, allocation2->prev); @@ -181,44 +181,14 @@ TEST_F(InternalAllocationStorageTest, whenObtainAllocationFromMidlleOfReusableLi allocation3->updateTaskCount(0u, csr->getOsContext().getContextId()); } -TEST_F(InternalAllocationStorageTest, givenNonInternalAllocationWhenItIsPutOnReusableListWhenInternalAllocationIsRequestedThenNullIsReturned) { +TEST_F(InternalAllocationStorageTest, givenAllocationWhenItIsPutOnReusableListWhenOtherAllocationTypeIsRequestedThenNullIsReturned) { EXPECT_TRUE(csr->getAllocationsForReuse().peekIsEmpty()); - auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); + auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(AllocationProperties{MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER}); storage->storeAllocation(std::unique_ptr(allocation), REUSABLE_ALLOCATION); EXPECT_FALSE(csr->getAllocationsForReuse().peekIsEmpty()); - auto internalAllocation = storage->obtainReusableAllocation(1, true); + auto internalAllocation = storage->obtainReusableAllocation(1, GraphicsAllocation::AllocationType::INTERNAL_HEAP); EXPECT_EQ(nullptr, internalAllocation); } - -TEST_F(InternalAllocationStorageTest, givenInternalAllocationWhenItIsPutOnReusableListWhenNonInternalAllocationIsRequestedThenNullIsReturned) { - EXPECT_TRUE(csr->getAllocationsForReuse().peekIsEmpty()); - - auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - allocation->is32BitAllocation = true; - - storage->storeAllocation(std::unique_ptr(allocation), REUSABLE_ALLOCATION); - - EXPECT_FALSE(csr->getAllocationsForReuse().peekIsEmpty()); - - auto internalAllocation = storage->obtainReusableAllocation(1, false); - EXPECT_EQ(nullptr, internalAllocation); -} - -TEST_F(InternalAllocationStorageTest, givenInternalAllocationWhenItIsPutOnReusableListWhenInternalAllocationIsRequestedThenItIsReturned) { - EXPECT_TRUE(csr->getAllocationsForReuse().peekIsEmpty()); - - auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - allocation->is32BitAllocation = true; - - storage->storeAllocation(std::unique_ptr(allocation), REUSABLE_ALLOCATION); - - EXPECT_FALSE(csr->getAllocationsForReuse().peekIsEmpty()); - - auto internalAllocation = storage->obtainReusableAllocation(1, true); - EXPECT_EQ(allocation, internalAllocation.get()); - internalAllocation.release(); - memoryManager->freeGraphicsMemory(allocation); -}