From d06fcc8599252b00695dd7a6ae3f1ea8e887342f Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Wed, 19 Jun 2019 10:47:03 +0200 Subject: [PATCH] Dont force system memory for pipe and global surface Related-To: NEO-3127 Change-Id: Iffb1b04401a19043bdb898b7896068bc760f4797 Signed-off-by: Mateusz Jablonski --- runtime/memory_manager/graphics_allocation.h | 2 ++ runtime/memory_manager/memory_manager.cpp | 2 -- .../graphics_allocation_tests.cpp | 28 ++++++++++++------- ...nager_allocate_in_preferred_pool_tests.inl | 16 +++++++++++ 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/runtime/memory_manager/graphics_allocation.h b/runtime/memory_manager/graphics_allocation.h index 60920d4081..cc3a369066 100644 --- a/runtime/memory_manager/graphics_allocation.h +++ b/runtime/memory_manager/graphics_allocation.h @@ -172,8 +172,10 @@ class GraphicsAllocation : public IDNode { static bool isCpuAccessRequired(AllocationType allocationType) { return allocationType == AllocationType::COMMAND_BUFFER || allocationType == AllocationType::CONSTANT_SURFACE || + allocationType == AllocationType::GLOBAL_SURFACE || allocationType == AllocationType::INTERNAL_HEAP || allocationType == AllocationType::LINEAR_STREAM || + allocationType == AllocationType::PIPE || allocationType == AllocationType::TIMESTAMP_PACKET_TAG_BUFFER; } void *getReservedAddressPtr() const { diff --git a/runtime/memory_manager/memory_manager.cpp b/runtime/memory_manager/memory_manager.cpp index dcb83145ac..86c129f4e6 100644 --- a/runtime/memory_manager/memory_manager.cpp +++ b/runtime/memory_manager/memory_manager.cpp @@ -271,9 +271,7 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo case GraphicsAllocation::AllocationType::DEVICE_QUEUE_BUFFER: case GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR: case GraphicsAllocation::AllocationType::FILL_PATTERN: - case GraphicsAllocation::AllocationType::GLOBAL_SURFACE: case GraphicsAllocation::AllocationType::MCS: - case GraphicsAllocation::AllocationType::PIPE: case GraphicsAllocation::AllocationType::PREEMPTION: case GraphicsAllocation::AllocationType::PRINTF_SURFACE: case GraphicsAllocation::AllocationType::PROFILING_TAG_BUFFER: diff --git a/unit_tests/memory_manager/graphics_allocation_tests.cpp b/unit_tests/memory_manager/graphics_allocation_tests.cpp index 658c5ead7a..5b24e8cdc8 100644 --- a/unit_tests/memory_manager/graphics_allocation_tests.cpp +++ b/unit_tests/memory_manager/graphics_allocation_tests.cpp @@ -115,28 +115,36 @@ TEST(GraphicsAllocationTest, givenResidentGraphicsAllocationWhenCheckIfResidency EXPECT_TRUE(graphicsAllocation.isResidencyTaskCountBelow(currentResidencyTaskCount + 1u, 0u)); } +TEST(GraphicsAllocationTest, whenAllocationTypeIsCommandBufferThenCpuAccessIsRequired) { + EXPECT_TRUE(GraphicsAllocation::isCpuAccessRequired(GraphicsAllocation::AllocationType::COMMAND_BUFFER)); +} + TEST(GraphicsAllocationTest, whenAllocationTypeIsConstantSurfaceThenCpuAccessIsRequired) { EXPECT_TRUE(GraphicsAllocation::isCpuAccessRequired(GraphicsAllocation::AllocationType::CONSTANT_SURFACE)); } -TEST(GraphicsAllocationTest, whenAllocationTypeIsLinearStreamThenCpuAccessIsRequired) { - EXPECT_TRUE(GraphicsAllocation::isCpuAccessRequired(GraphicsAllocation::AllocationType::LINEAR_STREAM)); -} - -TEST(GraphicsAllocationTest, whenAllocationTypeIsKernelIsaThenCpuAccessIsNotRequired) { - EXPECT_FALSE(GraphicsAllocation::isCpuAccessRequired(GraphicsAllocation::AllocationType::KERNEL_ISA)); +TEST(GraphicsAllocationTest, whenAllocationTypeIsGlobalSurfaceThenCpuAccessIsRequired) { + EXPECT_TRUE(GraphicsAllocation::isCpuAccessRequired(GraphicsAllocation::AllocationType::GLOBAL_SURFACE)); } TEST(GraphicsAllocationTest, whenAllocationTypeIsInternalHeapThenCpuAccessIsRequired) { EXPECT_TRUE(GraphicsAllocation::isCpuAccessRequired(GraphicsAllocation::AllocationType::INTERNAL_HEAP)); } -TEST(GraphicsAllocationTest, whenAllocationTypeIsTimestampPacketThenCpuAccessIsRequired) { - EXPECT_TRUE(GraphicsAllocation::isCpuAccessRequired(GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER)); +TEST(GraphicsAllocationTest, whenAllocationTypeIsKernelIsaThenCpuAccessIsNotRequired) { + EXPECT_FALSE(GraphicsAllocation::isCpuAccessRequired(GraphicsAllocation::AllocationType::KERNEL_ISA)); } -TEST(GraphicsAllocationTest, whenAllocationTypeIsCommandBufferThenCpuAccessIsRequired) { - EXPECT_TRUE(GraphicsAllocation::isCpuAccessRequired(GraphicsAllocation::AllocationType::COMMAND_BUFFER)); +TEST(GraphicsAllocationTest, whenAllocationTypeIsLinearStreamThenCpuAccessIsRequired) { + EXPECT_TRUE(GraphicsAllocation::isCpuAccessRequired(GraphicsAllocation::AllocationType::LINEAR_STREAM)); +} + +TEST(GraphicsAllocationTest, whenAllocationTypeIsPipeThenCpuAccessIsRequired) { + EXPECT_TRUE(GraphicsAllocation::isCpuAccessRequired(GraphicsAllocation::AllocationType::PIPE)); +} + +TEST(GraphicsAllocationTest, whenAllocationTypeIsTimestampPacketThenCpuAccessIsRequired) { + EXPECT_TRUE(GraphicsAllocation::isCpuAccessRequired(GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER)); } TEST(GraphicsAllocationTest, givenDefaultAllocationWhenGettingNumHandlesThenOneIsReturned) { diff --git a/unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.inl b/unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.inl index 4d9412895a..0dd2f0c6a3 100644 --- a/unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.inl +++ b/unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.inl @@ -401,6 +401,22 @@ TEST(MemoryManagerTest, givenMCSTypeWhenGetAllocationDataIsCalledThenSystemMemor EXPECT_TRUE(allocData.flags.useSystemMemory); } +TEST(MemoryManagerTest, givenPipeTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsNotRequested) { + AllocationData allocData; + MockMemoryManager mockMemoryManager; + AllocationProperties properties{1, GraphicsAllocation::AllocationType::PIPE}; + MockMemoryManager::getAllocationData(allocData, properties, nullptr, mockMemoryManager.createStorageInfoFromProperties(properties)); + EXPECT_FALSE(allocData.flags.useSystemMemory); +} + +TEST(MemoryManagerTest, givenGlobalSurfaceTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsNotRequested) { + AllocationData allocData; + MockMemoryManager mockMemoryManager; + AllocationProperties properties{1, GraphicsAllocation::AllocationType::GLOBAL_SURFACE}; + MockMemoryManager::getAllocationData(allocData, properties, nullptr, mockMemoryManager.createStorageInfoFromProperties(properties)); + EXPECT_FALSE(allocData.flags.useSystemMemory); +} + TEST(MemoryManagerTest, givenDeviceQueueBufferTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsRequested) { AllocationData allocData; MockMemoryManager mockMemoryManager;