From dc1fe7d59a2804209167d3bda16f93b6f8274fed Mon Sep 17 00:00:00 2001 From: Krzysztof Gibala Date: Wed, 1 Jun 2022 21:13:52 +0000 Subject: [PATCH] Change MemoryPool to enum class Use enum class for MemoryPool in GraphicsAllocation This change will ensure that GA is constructed in the proper way - Rename namespace for isSystemMemoryPool method - Add method getMemoryPoolString for logging actual pool which is in used - Remove wrong pattern in GraphicsAllocation constructor Related-To: NEO-6523 Signed-off-by: Krzysztof Gibala --- .../unit_tests/fixtures/memory_ipc_fixture.h | 42 +++++++++---------- .../test/unit_tests/fixtures/module_fixture.h | 24 +++++------ .../test/unit_tests/mocks/mock_cmdlist.cpp | 2 +- .../core/test/unit_tests/mocks/mock_event.cpp | 2 +- .../core/test/unit_tests/mocks/mock_event.h | 2 +- .../core/test/unit_tests/mocks/mock_kernel.h | 2 +- opencl/source/helpers/properties_helper.cpp | 2 +- opencl/source/mem_obj/buffer.cpp | 10 ++--- opencl/source/mem_obj/image.cpp | 6 +-- opencl/source/mem_obj/mem_obj.cpp | 2 +- .../enqueue_map_image_aub_tests.cpp | 2 +- .../enqueue_read_image_aub_tests.cpp | 2 +- .../copy_engine_aub_tests_xehp_and_later.h | 2 +- .../mem_obj/create_image_aub_tests.cpp | 10 ++--- ...tateless_compression_in_sba_xe_hp_core.cpp | 6 +-- ...ateless_compression_in_sba_xe_hpg_core.cpp | 6 +-- .../test/unit_test/mem_obj/buffer_tests.cpp | 10 ++--- .../mem_obj/buffer_tests_xehp_and_later.cpp | 4 +- .../linux/drm_command_stream_tests_2.cpp | 4 +- .../linux/file_logger_linux_tests.cpp | 8 ++-- .../windows/file_logger_win_tests.cpp | 4 +- ..._manager_allocate_in_device_pool_tests.cpp | 2 +- .../unit_test/utilities/file_logger_tests.cpp | 32 ++++++++++++++ .../copy_engine_tests_xe_hp_core.cpp | 16 +++---- .../command_stream_receiver_hw_tests_pvc.cpp | 4 +- .../copy_engine_tests_xe_hpg_core.cpp | 16 +++---- .../command_encoder_xehp_and_later.inl | 2 +- .../blit_commands_helper_xehp_and_later.inl | 6 +-- .../memory_manager/graphics_allocation.cpp | 4 +- .../memory_manager/graphics_allocation.h | 12 +++--- shared/source/memory_manager/memory_pool.h | 38 +++++++++-------- .../os_agnostic_memory_manager.cpp | 4 +- .../os_agnostic_memory_manager.h | 16 +++---- .../os_interface/linux/drm_allocation.h | 12 +++--- .../os_interface/linux/drm_memory_manager.cpp | 2 +- .../os_interface/windows/wddm_allocation.h | 8 ++-- .../windows/wddm_memory_manager.cpp | 2 +- shared/source/utilities/logger.cpp | 26 +++++++++++- shared/source/utilities/logger.h | 1 + ...command_stream_receiver_hw_xe_hpc_core.cpp | 6 +-- .../common/mocks/linux/mock_drm_allocation.h | 2 +- .../common/mocks/mock_graphics_allocation.h | 2 +- ...ommand_stream_receiver_simulated_tests.cpp | 4 +- .../command_stream_receiver_tests.cpp | 2 +- .../graphics_allocation_tests.cpp | 16 +++---- .../memory_manager/memory_pool_tests.cpp | 16 +++---- .../drm_residency_handler_prelim_tests.cpp | 2 +- 47 files changed, 232 insertions(+), 173 deletions(-) diff --git a/level_zero/core/test/unit_tests/fixtures/memory_ipc_fixture.h b/level_zero/core/test/unit_tests/fixtures/memory_ipc_fixture.h index 5030060d8d..7150f01d10 100644 --- a/level_zero/core/test/unit_tests/fixtures/memory_ipc_fixture.h +++ b/level_zero/core/test/unit_tests/fixtures/memory_ipc_fixture.h @@ -458,9 +458,9 @@ class MemoryManagerOpenIpcMock : public MemoryManagerIpcMock { NEO::AllocationType::BUFFER, reinterpret_cast(sharedHandleAddress++), 0x1000, - 0, - sizeof(uint32_t), - MemoryPool::System4KBPages); + 0u, + MemoryPool::System4KBPages, + MemoryManager::maxOsContextCount); alloc->setGpuBaseAddress(0xabcd); return alloc; } @@ -473,9 +473,9 @@ class MemoryManagerOpenIpcMock : public MemoryManagerIpcMock { NEO::AllocationType::BUFFER, reinterpret_cast(sharedHandleAddress++), 0x1000, - 0, - sizeof(uint32_t), - MemoryPool::System4KBPages); + 0u, + MemoryPool::System4KBPages, + MemoryManager::maxOsContextCount); alloc->setGpuBaseAddress(0xabcd); return alloc; } @@ -487,9 +487,9 @@ class MemoryManagerOpenIpcMock : public MemoryManagerIpcMock { NEO::AllocationType::BUFFER, reinterpret_cast(sharedHandleAddress++), 0x1000, - 0, - sizeof(uint32_t), - MemoryPool::System4KBPages); + 0u, + MemoryPool::System4KBPages, + MemoryManager::maxOsContextCount); alloc->setGpuBaseAddress(0xabcd); return alloc; } @@ -498,9 +498,9 @@ class MemoryManagerOpenIpcMock : public MemoryManagerIpcMock { NEO::AllocationType::BUFFER, reinterpret_cast(sharedHandleAddress++), 0x1000, - 0, - sizeof(uint32_t), - MemoryPool::System4KBPages); + 0u, + MemoryPool::System4KBPages, + MemoryManager::maxOsContextCount); alloc->setGpuBaseAddress(0xabcd); return alloc; }; @@ -610,9 +610,9 @@ class MemoryManagerIpcImplicitScalingMock : public NEO::MemoryManager { NEO::AllocationType::BUFFER, reinterpret_cast(sharedHandleAddress++), 0x1000, - 0, - sizeof(uint32_t), - MemoryPool::System4KBPages); + 0u, + MemoryPool::System4KBPages, + MemoryManager::maxOsContextCount); alloc->setGpuBaseAddress(0xabcd); return alloc; } @@ -622,9 +622,9 @@ class MemoryManagerIpcImplicitScalingMock : public NEO::MemoryManager { NEO::AllocationType::BUFFER, reinterpret_cast(sharedHandleAddress++), 0x1000, - 0, - sizeof(uint32_t), - MemoryPool::System4KBPages); + 0u, + MemoryPool::System4KBPages, + MemoryManager::maxOsContextCount); alloc->setGpuBaseAddress(0xabcd); return alloc; } @@ -637,9 +637,9 @@ class MemoryManagerIpcImplicitScalingMock : public NEO::MemoryManager { NEO::AllocationType::BUFFER, reinterpret_cast(sharedHandleAddress++), 0x1000, - 0, - sizeof(uint32_t), - MemoryPool::System4KBPages); + 0u, + MemoryPool::System4KBPages, + MemoryManager::maxOsContextCount); alloc->setGpuBaseAddress(0xabcd); return alloc; } diff --git a/level_zero/core/test/unit_tests/fixtures/module_fixture.h b/level_zero/core/test/unit_tests/fixtures/module_fixture.h index cbbad80e56..2454049174 100644 --- a/level_zero/core/test/unit_tests/fixtures/module_fixture.h +++ b/level_zero/core/test/unit_tests/fixtures/module_fixture.h @@ -65,9 +65,9 @@ struct ModuleImmutableDataFixture : public DeviceFixture { NEO::AllocationType::KERNEL_ISA, reinterpret_cast(0x1234), 0x1000, - 0, - sizeof(uint32_t), - MemoryPool::System4KBPages)); + 0u, + MemoryPool::System4KBPages, + MemoryManager::maxOsContextCount)); kernelInfo->kernelAllocation = isaGraphicsAllocation.get(); } @@ -319,9 +319,9 @@ struct ModuleWithZebinFixture : public DeviceFixture { NEO::AllocationType::KERNEL_ISA, reinterpret_cast(0x1234), 0x1000, - 0, - sizeof(uint32_t), - MemoryPool::System4KBPages)); + 0u, + MemoryPool::System4KBPages, + MemoryManager::maxOsContextCount)); } ~MockImmutableData() override { @@ -343,16 +343,16 @@ struct ModuleWithZebinFixture : public DeviceFixture { NEO::AllocationType::GLOBAL_SURFACE, reinterpret_cast(0x1234), 0x1000, - 0, - sizeof(uint32_t), - MemoryPool::System4KBPages); + 0u, + MemoryPool::System4KBPages, + MemoryManager::maxOsContextCount); translationUnit->globalConstBuffer = new NEO::MockGraphicsAllocation(0, NEO::AllocationType::GLOBAL_SURFACE, reinterpret_cast(0x1234), 0x1000, - 0, - sizeof(uint32_t), - MemoryPool::System4KBPages); + 0u, + MemoryPool::System4KBPages, + MemoryManager::maxOsContextCount); translationUnit->programInfo.globalStrings.initData = &strings; translationUnit->programInfo.globalStrings.size = sizeof(strings); diff --git a/level_zero/core/test/unit_tests/mocks/mock_cmdlist.cpp b/level_zero/core/test/unit_tests/mocks/mock_cmdlist.cpp index c79f5c1b15..199614570c 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_cmdlist.cpp +++ b/level_zero/core/test/unit_tests/mocks/mock_cmdlist.cpp @@ -24,7 +24,7 @@ MockCommandList::MockCommandList(Device *device) : WhiteBox<::L0::CommandList>(d reinterpret_cast(&batchBuffer), 0, sizeof(batchBufferSize), - MemoryPool::System4KBPages, + NEO::MemoryPool::System4KBPages, NEO::MemoryManager::maxOsContextCount); } diff --git a/level_zero/core/test/unit_tests/mocks/mock_event.cpp b/level_zero/core/test/unit_tests/mocks/mock_event.cpp index 3477278a3f..2195b46b1d 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_event.cpp +++ b/level_zero/core/test/unit_tests/mocks/mock_event.cpp @@ -16,7 +16,7 @@ Mock::Mock() : mockAllocation(0, reinterpret_cast(&memory), 0, sizeof(memory), - MemoryPool::System4KBPages, + NEO::MemoryPool::System4KBPages, NEO::MemoryManager::maxOsContextCount) {} Mock::~Mock() {} diff --git a/level_zero/core/test/unit_tests/mocks/mock_event.h b/level_zero/core/test/unit_tests/mocks/mock_event.h index 3fdf658eba..7d95460f69 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_event.h +++ b/level_zero/core/test/unit_tests/mocks/mock_event.h @@ -74,7 +74,7 @@ class MockEvent : public ::L0::Event { 0x1000, 0, sizeof(uint32_t), - MemoryPool::System4KBPages, + NEO::MemoryPool::System4KBPages, NEO::MemoryManager::maxOsContextCount)); this->timestampSizeInDw = 1; this->contextStartOffset = 0; diff --git a/level_zero/core/test/unit_tests/mocks/mock_kernel.h b/level_zero/core/test/unit_tests/mocks/mock_kernel.h index 82372dab66..f0445f0b1f 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_kernel.h +++ b/level_zero/core/test/unit_tests/mocks/mock_kernel.h @@ -121,7 +121,7 @@ struct Mock<::L0::Kernel> : public WhiteBox<::L0::Kernel> { 0, 0, 4096, - MemoryPool::System4KBPages, + NEO::MemoryPool::System4KBPages, NEO::MemoryManager::maxOsContextCount); immutableData.isaGraphicsAllocation.reset(allocation); diff --git a/opencl/source/helpers/properties_helper.cpp b/opencl/source/helpers/properties_helper.cpp index 1af6b72f8b..60d56a20da 100644 --- a/opencl/source/helpers/properties_helper.cpp +++ b/opencl/source/helpers/properties_helper.cpp @@ -99,7 +99,7 @@ TransferProperties::TransferProperties(MemObj *memObj, cl_command_type cmdType, size[0] = *sizePtr; offset[0] = *offsetPtr; if (doTransferOnCpu && - (false == MemoryPool::isSystemMemoryPool(memObj->getGraphicsAllocation(rootDeviceIndex)->getMemoryPool())) && + (false == MemoryPoolHelper::isSystemMemoryPool(memObj->getGraphicsAllocation(rootDeviceIndex)->getMemoryPool())) && (memObj->getMemoryManager() != nullptr)) { this->lockedPtr = memObj->getMemoryManager()->lockResource(memObj->getGraphicsAllocation(rootDeviceIndex)); } diff --git a/opencl/source/mem_obj/buffer.cpp b/opencl/source/mem_obj/buffer.cpp index ac287440a4..02c212b49f 100644 --- a/opencl/source/mem_obj/buffer.cpp +++ b/opencl/source/mem_obj/buffer.cpp @@ -306,7 +306,7 @@ Buffer *Buffer::create(Context *context, } } - if (allocationInfo[rootDeviceIndex].allocateMemory && allocationInfo[rootDeviceIndex].memory && MemoryPool::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool())) { + if (allocationInfo[rootDeviceIndex].allocateMemory && allocationInfo[rootDeviceIndex].memory && MemoryPoolHelper::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool())) { memoryManager->addAllocationToHostPtrManager(allocationInfo[rootDeviceIndex].memory); } @@ -330,7 +330,7 @@ Buffer *Buffer::create(Context *context, return nullptr; } - if (!MemoryPool::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool())) { + if (!MemoryPoolHelper::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool())) { allocationInfo[rootDeviceIndex].zeroCopyAllowed = false; if (hostPtr) { if (!allocationInfo[rootDeviceIndex].isHostPtrSVM) { @@ -376,7 +376,7 @@ Buffer *Buffer::create(Context *context, DBG_LOG(LogMemoryObject, __FUNCTION__, "Created Buffer: Handle: ", pBuffer, ", hostPtr: ", hostPtr, ", size: ", size, ", memoryStorage: ", allocationInfo[rootDeviceIndex].memory->getUnderlyingBuffer(), ", GPU address: ", allocationInfo[rootDeviceIndex].memory->getGpuAddress(), - ", memoryPool: ", allocationInfo[rootDeviceIndex].memory->getMemoryPool()); + ", memoryPool: ", getMemoryPoolString(allocationInfo[rootDeviceIndex].memory)); for (auto &rootDeviceIndex : context->getRootDeviceIndices()) { if (memoryProperties.flags.useHostPtr) { @@ -399,7 +399,7 @@ Buffer *Buffer::create(Context *context, pBuffer->setHostPtrMinSize(size); if (allocationInfo[rootDeviceIndex].copyMemoryFromHostPtr && !copyExecuted) { - auto isLocalMemory = !MemoryPool::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool()); + auto isLocalMemory = !MemoryPoolHelper::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool()); bool gpuCopyRequired = (allocationInfo[rootDeviceIndex].memory->isCompressionEnabled()) || isLocalMemory; if (gpuCopyRequired) { @@ -652,7 +652,7 @@ bool Buffer::isReadWriteOnCpuAllowed(const Device &device) { bool Buffer::isReadWriteOnCpuPreferred(void *ptr, size_t size, const Device &device) { auto graphicsAllocation = multiGraphicsAllocation.getGraphicsAllocation(device.getRootDeviceIndex()); - if (MemoryPool::isSystemMemoryPool(graphicsAllocation->getMemoryPool())) { + if (MemoryPoolHelper::isSystemMemoryPool(graphicsAllocation->getMemoryPool())) { //if buffer is not zero copy and pointer is aligned it will be more beneficial to do the transfer on GPU if (!isMemObjZeroCopy() && (reinterpret_cast(ptr) & (MemoryConstants::cacheLineSize - 1)) == 0) { return false; diff --git a/opencl/source/mem_obj/image.cpp b/opencl/source/mem_obj/image.cpp index c0f7b0f99f..b83f66fbe6 100644 --- a/opencl/source/mem_obj/image.cpp +++ b/opencl/source/mem_obj/image.cpp @@ -334,7 +334,7 @@ Image *Image::create(Context *context, allocProperties.flags.preferCompressed = preferCompression; allocationInfo[rootDeviceIndex].memory = memoryManager->allocateGraphicsMemoryWithProperties(allocProperties); - if (allocationInfo[rootDeviceIndex].memory && MemoryPool::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool())) { + if (allocationInfo[rootDeviceIndex].memory && MemoryPoolHelper::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool())) { allocationInfo[rootDeviceIndex].zeroCopyAllowed = true; } } @@ -431,7 +431,7 @@ Image *Image::create(Context *context, } bool isCpuTransferPreferrred = imgInfo.linearStorage && - (MemoryPool::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool()) || + (MemoryPoolHelper::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool()) || defaultHwHelper.isCpuImageTransferPreferred(hwInfo)); if (!isCpuTransferPreferrred) { auto cmdQ = context->getSpecialQueue(rootDeviceIndex); @@ -445,7 +445,7 @@ Image *Image::create(Context *context, } } else { void *pDestinationAddress = allocationInfo[rootDeviceIndex].memory->getUnderlyingBuffer(); - auto isNotInSystemMemory = !MemoryPool::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool()); + auto isNotInSystemMemory = !MemoryPoolHelper::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool()); if (isNotInSystemMemory) { pDestinationAddress = context->getMemoryManager()->lockResource(allocationInfo[rootDeviceIndex].memory); } diff --git a/opencl/source/mem_obj/mem_obj.cpp b/opencl/source/mem_obj/mem_obj.cpp index 2f92242d53..5121f2fc95 100644 --- a/opencl/source/mem_obj/mem_obj.cpp +++ b/opencl/source/mem_obj/mem_obj.cpp @@ -415,7 +415,7 @@ bool MemObj::isTiledAllocation() const { bool MemObj::mappingOnCpuAllowed() const { auto graphicsAllocation = multiGraphicsAllocation.getDefaultGraphicsAllocation(); return !isTiledAllocation() && !peekSharingHandler() && !isMipMapped(this) && !DebugManager.flags.DisableZeroCopyForBuffers.get() && - !graphicsAllocation->isCompressionEnabled() && MemoryPool::isSystemMemoryPool(graphicsAllocation->getMemoryPool()); + !graphicsAllocation->isCompressionEnabled() && MemoryPoolHelper::isSystemMemoryPool(graphicsAllocation->getMemoryPool()); } void MemObj::storeProperties(const cl_mem_properties *properties) { diff --git a/opencl/test/unit_test/aub_tests/command_queue/enqueue_map_image_aub_tests.cpp b/opencl/test/unit_test/aub_tests/command_queue/enqueue_map_image_aub_tests.cpp index 6147a9ffac..d994da2518 100644 --- a/opencl/test/unit_test/aub_tests/command_queue/enqueue_map_image_aub_tests.cpp +++ b/opencl/test/unit_test/aub_tests/command_queue/enqueue_map_image_aub_tests.cpp @@ -155,7 +155,7 @@ HWTEST_P(AUBMapImage, WhenMappingAndUnmappingThenExpectationsAreMet) { uint8_t *mappedPtrStart; uint8_t *srcMemoryStart; - bool isGpuCopy = srcImage->isTiledAllocation() || !MemoryPool::isSystemMemoryPool( + bool isGpuCopy = srcImage->isTiledAllocation() || !MemoryPoolHelper::isSystemMemoryPool( srcImage->getGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex())->getMemoryPool()); if (isGpuCopy) { mappedPtrStart = static_cast(mappedPtr); diff --git a/opencl/test/unit_test/aub_tests/command_queue/enqueue_read_image_aub_tests.cpp b/opencl/test/unit_test/aub_tests/command_queue/enqueue_read_image_aub_tests.cpp index 32961ab3cc..4ef3726eba 100644 --- a/opencl/test/unit_test/aub_tests/command_queue/enqueue_read_image_aub_tests.cpp +++ b/opencl/test/unit_test/aub_tests/command_queue/enqueue_read_image_aub_tests.cpp @@ -153,7 +153,7 @@ struct AUBReadImage auto imageMemory = srcMemory; auto memoryPool = srcImage->getGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex())->getMemoryPool(); - bool isGpuCopy = srcImage->isTiledAllocation() || !MemoryPool::isSystemMemoryPool(memoryPool); + bool isGpuCopy = srcImage->isTiledAllocation() || !MemoryPoolHelper::isSystemMemoryPool(memoryPool); if (!isGpuCopy) { imageMemory = reinterpret_cast(srcImage->getCpuAddress()); } diff --git a/opencl/test/unit_test/aub_tests/command_stream/copy_engine_aub_tests_xehp_and_later.h b/opencl/test/unit_test/aub_tests/command_stream/copy_engine_aub_tests_xehp_and_later.h index 4c7fa00a46..928b142adf 100644 --- a/opencl/test/unit_test/aub_tests/command_stream/copy_engine_aub_tests_xehp_and_later.h +++ b/opencl/test/unit_test/aub_tests/command_stream/copy_engine_aub_tests_xehp_and_later.h @@ -95,7 +95,7 @@ struct CopyEngineXeHPAndLater : public MulticontextAubFixture, public ::testing: if (compressed) { EXPECT_TRUE(graphicsAllocation->getDefaultGmm()->isCompressionEnabled); } - EXPECT_EQ(!inLocalMemory, MemoryPool::isSystemMemoryPool(graphicsAllocation->getMemoryPool())); + EXPECT_EQ(!inLocalMemory, MemoryPoolHelper::isSystemMemoryPool(graphicsAllocation->getMemoryPool())); return buffer; } diff --git a/opencl/test/unit_test/aub_tests/mem_obj/create_image_aub_tests.cpp b/opencl/test/unit_test/aub_tests/mem_obj/create_image_aub_tests.cpp index 16bc8b6739..5c6cd4e655 100644 --- a/opencl/test/unit_test/aub_tests/mem_obj/create_image_aub_tests.cpp +++ b/opencl/test/unit_test/aub_tests/mem_obj/create_image_aub_tests.cpp @@ -148,7 +148,7 @@ HWTEST_F(AUBCreateImageArray, Given1DImageArrayThenExpectationsMet) { for (auto height = 0u; height < imageHeight; height++) { for (auto element = 0u; element < imageDesc.image_width; element++) { auto offset = (array * imgInfo.slicePitch + element * pixelSize + height * imgInfo.rowPitch) / 4; - if (MemoryPool::isSystemMemoryPool(image->getGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex())->getMemoryPool()) == false) { + if (MemoryPoolHelper::isSystemMemoryPool(image->getGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex())->getMemoryPool()) == false) { AUBCommandStreamFixture::expectMemory(&destGpuAddress[offset], ¤tCounter, pixelSize); } else { EXPECT_EQ(currentCounter, address[offset]); @@ -228,7 +228,7 @@ HWTEST_F(AUBCreateImageArray, Given2DImageArrayThenExpectationsMet) { for (auto height = 0u; height < imageHeight; height++) { for (auto element = 0u; element < imageDesc.image_width; element++) { auto offset = (array * imgInfo.slicePitch + element * pixelSize + height * imgInfo.rowPitch) / 4; - if (MemoryPool::isSystemMemoryPool(image->getGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex())->getMemoryPool()) == false) { + if (MemoryPoolHelper::isSystemMemoryPool(image->getGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex())->getMemoryPool()) == false) { AUBCommandStreamFixture::expectMemory(&destGpuAddress[offset], ¤tCounter, pixelSize); } else { EXPECT_EQ(currentCounter, address[offset]); @@ -326,7 +326,7 @@ HWTEST_P(CopyHostPtrTest, GivenImageWithDoubledRowPitchWhenCreatedWithCopyHostPt data = (char *)pHostPtr; uint8_t *readMemory = nullptr; - bool isGpuCopy = image->isTiledAllocation() || !MemoryPool::isSystemMemoryPool(image->getGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex())->getMemoryPool()); + bool isGpuCopy = image->isTiledAllocation() || !MemoryPoolHelper::isSystemMemoryPool(image->getGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex())->getMemoryPool()); if (isGpuCopy) { readMemory = new uint8_t[testImageDimensions * testImageDimensions * elementSize * 4]; size_t imgOrigin[] = {0, 0, 0}; @@ -430,7 +430,7 @@ HWTEST_P(UseHostPtrTest, GivenImageWithRowPitchWhenCreatedWithUseHostPtrFlagThen heightToCopy = imageDesc.image_height; char *imageStorage = (char *)ptr; data = (char *)pUseHostPtr; - bool isGpuCopy = image->isTiledAllocation() || !MemoryPool::isSystemMemoryPool( + bool isGpuCopy = image->isTiledAllocation() || !MemoryPoolHelper::isSystemMemoryPool( image->getGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex())->getMemoryPool()); while (heightToCopy--) { @@ -484,7 +484,7 @@ HWTEST_F(AUBCreateImage, GivenImage3DCreatedWithDoubledSlicePitchWhenQueriedForD data = (char *)hostPtr; uint8_t *readMemory = nullptr; - bool isGpuCopy = image->isTiledAllocation() || !MemoryPool::isSystemMemoryPool( + bool isGpuCopy = image->isTiledAllocation() || !MemoryPoolHelper::isSystemMemoryPool( image->getGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex())->getMemoryPool()); if (isGpuCopy) { readMemory = new uint8_t[imageSize]; diff --git a/opencl/test/unit_test/aub_tests/xe_hp_core/aub_tests_stateless_compression_in_sba_xe_hp_core.cpp b/opencl/test/unit_test/aub_tests/xe_hp_core/aub_tests_stateless_compression_in_sba_xe_hp_core.cpp index a96299f1f1..e1b86c6f88 100644 --- a/opencl/test/unit_test/aub_tests/xe_hp_core/aub_tests_stateless_compression_in_sba_xe_hp_core.cpp +++ b/opencl/test/unit_test/aub_tests/xe_hp_core/aub_tests_stateless_compression_in_sba_xe_hp_core.cpp @@ -169,7 +169,7 @@ XE_HP_CORE_TEST_P(StatelessCompressionInSBA, givenUncompressibleBufferInHostMemo auto uncompressibleBufferInHostMemory = std::unique_ptr(Buffer::create(context, CL_MEM_FORCE_HOST_MEMORY_INTEL, bufferSize, nullptr, retVal)); auto uncompressibleAllocationInHostMemory = uncompressibleBufferInHostMemory->getGraphicsAllocation(device->getRootDeviceIndex()); EXPECT_EQ(AllocationType::BUFFER_HOST_MEMORY, uncompressibleAllocationInHostMemory->getAllocationType()); - EXPECT_TRUE(MemoryPool::isSystemMemoryPool(uncompressibleAllocationInHostMemory->getMemoryPool())); + EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(uncompressibleAllocationInHostMemory->getMemoryPool())); retVal = pCmdQ->enqueueWriteBuffer(compressedBuffer.get(), CL_FALSE, 0, bufferSize, writePattern, nullptr, 0, nullptr, nullptr); ASSERT_EQ(CL_SUCCESS, retVal); @@ -219,7 +219,7 @@ XE_HP_CORE_TEST_P(StatelessCompressionInSBA, givenUncompressibleHostMemoryAlloca auto uncompressibleHostMemAlloc = context->getSVMAllocsManager()->getSVMAllocs()->get(uncompressibleHostMemAllocPtr)->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex()); EXPECT_NE(nullptr, uncompressibleHostMemAlloc); EXPECT_EQ(AllocationType::BUFFER_HOST_MEMORY, uncompressibleHostMemAlloc->getAllocationType()); - EXPECT_TRUE(MemoryPool::isSystemMemoryPool(uncompressibleHostMemAlloc->getMemoryPool())); + EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(uncompressibleHostMemAlloc->getMemoryPool())); retVal = clEnqueueMemcpyINTEL(pCmdQ, true, compressedDeviceMemAllocPtr, writePattern, bufferSize, 0, nullptr, nullptr); EXPECT_EQ(CL_SUCCESS, retVal); @@ -549,7 +549,7 @@ XE_HP_CORE_TEST_F(StatelessCompressionInSBAWithBCS, givenUncompressibleBufferInH auto uncompressibleBufferInHostMemory = std::unique_ptr(Buffer::create(context.get(), CL_MEM_FORCE_HOST_MEMORY_INTEL, bufferSize, nullptr, retVal)); auto uncompressibleAllocationInHostMemory = uncompressibleBufferInHostMemory->getGraphicsAllocation(tileDevices[0]->getRootDeviceIndex()); EXPECT_EQ(AllocationType::BUFFER_HOST_MEMORY, uncompressibleAllocationInHostMemory->getAllocationType()); - EXPECT_TRUE(MemoryPool::isSystemMemoryPool(uncompressibleAllocationInHostMemory->getMemoryPool())); + EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(uncompressibleAllocationInHostMemory->getMemoryPool())); retVal = commandQueues[0][0]->enqueueWriteBuffer(compressedBuffer.get(), CL_FALSE, 0, bufferSize, writePattern, nullptr, 0, nullptr, nullptr); ASSERT_EQ(CL_SUCCESS, retVal); diff --git a/opencl/test/unit_test/aub_tests/xe_hpg_core/aub_tests_stateless_compression_in_sba_xe_hpg_core.cpp b/opencl/test/unit_test/aub_tests/xe_hpg_core/aub_tests_stateless_compression_in_sba_xe_hpg_core.cpp index 89c77998bd..9880fc70b2 100644 --- a/opencl/test/unit_test/aub_tests/xe_hpg_core/aub_tests_stateless_compression_in_sba_xe_hpg_core.cpp +++ b/opencl/test/unit_test/aub_tests/xe_hpg_core/aub_tests_stateless_compression_in_sba_xe_hpg_core.cpp @@ -172,7 +172,7 @@ XE_HPG_CORETEST_P(XeHpgCoreStatelessCompressionInSBA, givenUncompressibleBufferI auto uncompressibleBufferInHostMemory = std::unique_ptr(Buffer::create(context, CL_MEM_FORCE_HOST_MEMORY_INTEL, bufferSize, nullptr, retVal)); auto uncompressibleAllocationInHostMemory = uncompressibleBufferInHostMemory->getGraphicsAllocation(device->getRootDeviceIndex()); EXPECT_EQ(AllocationType::BUFFER_HOST_MEMORY, uncompressibleAllocationInHostMemory->getAllocationType()); - EXPECT_TRUE(MemoryPool::isSystemMemoryPool(uncompressibleAllocationInHostMemory->getMemoryPool())); + EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(uncompressibleAllocationInHostMemory->getMemoryPool())); retVal = pCmdQ->enqueueWriteBuffer(compressedBuffer.get(), CL_FALSE, 0, bufferSize, writePattern, nullptr, 0, nullptr, nullptr); ASSERT_EQ(CL_SUCCESS, retVal); @@ -222,7 +222,7 @@ XE_HPG_CORETEST_P(XeHpgCoreStatelessCompressionInSBA, givenUncompressibleHostMem auto uncompressibleHostMemAlloc = context->getSVMAllocsManager()->getSVMAllocs()->get(uncompressibleHostMemAllocPtr)->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex()); EXPECT_NE(nullptr, uncompressibleHostMemAlloc); EXPECT_EQ(AllocationType::BUFFER_HOST_MEMORY, uncompressibleHostMemAlloc->getAllocationType()); - EXPECT_TRUE(MemoryPool::isSystemMemoryPool(uncompressibleHostMemAlloc->getMemoryPool())); + EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(uncompressibleHostMemAlloc->getMemoryPool())); retVal = clEnqueueMemcpyINTEL(pCmdQ, true, compressedDeviceMemAllocPtr, writePattern, bufferSize, 0, nullptr, nullptr); EXPECT_EQ(CL_SUCCESS, retVal); @@ -554,7 +554,7 @@ XE_HPG_CORETEST_F(XeHpgCoreStatelessCompressionInSBAWithBCS, givenUncompressible auto uncompressibleBufferInHostMemory = std::unique_ptr(Buffer::create(context.get(), CL_MEM_FORCE_HOST_MEMORY_INTEL, bufferSize, nullptr, retVal)); auto uncompressibleAllocationInHostMemory = uncompressibleBufferInHostMemory->getGraphicsAllocation(tileDevices[0]->getRootDeviceIndex()); EXPECT_EQ(AllocationType::BUFFER_HOST_MEMORY, uncompressibleAllocationInHostMemory->getAllocationType()); - EXPECT_TRUE(MemoryPool::isSystemMemoryPool(uncompressibleAllocationInHostMemory->getMemoryPool())); + EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(uncompressibleAllocationInHostMemory->getMemoryPool())); retVal = commandQueues[0][0]->enqueueWriteBuffer(compressedBuffer.get(), CL_FALSE, 0, bufferSize, writePattern, nullptr, 0, nullptr, nullptr); ASSERT_EQ(CL_SUCCESS, retVal); diff --git a/opencl/test/unit_test/mem_obj/buffer_tests.cpp b/opencl/test/unit_test/mem_obj/buffer_tests.cpp index b570ad3613..22633027c6 100644 --- a/opencl/test/unit_test/mem_obj/buffer_tests.cpp +++ b/opencl/test/unit_test/mem_obj/buffer_tests.cpp @@ -354,7 +354,7 @@ TEST(Buffer, givenNullptrPassedToBufferCreateWhenNoSharedContextOrCompressedBuff std::unique_ptr buffer(Buffer::create(&ctx, flags, MemoryConstants::pageSize, nullptr, retVal)); ASSERT_NE(nullptr, buffer.get()); - if (MemoryPool::isSystemMemoryPool(buffer->getGraphicsAllocation(device->getRootDeviceIndex())->getMemoryPool())) { + if (MemoryPoolHelper::isSystemMemoryPool(buffer->getGraphicsAllocation(device->getRootDeviceIndex())->getMemoryPool())) { EXPECT_EQ(AllocationType::BUFFER_HOST_MEMORY, buffer->getGraphicsAllocation(device->getRootDeviceIndex())->getAllocationType()); } else { EXPECT_EQ(AllocationType::BUFFER, buffer->getGraphicsAllocation(device->getRootDeviceIndex())->getAllocationType()); @@ -690,7 +690,7 @@ TEST_F(CompressedBuffersTests, givenBufferNotCompressedAllocationAndNoHostPtrWhe buffer.reset(Buffer::create(context.get(), 0, bufferSize, nullptr, retVal)); auto allocation = buffer->getGraphicsAllocation(device->getRootDeviceIndex()); EXPECT_TRUE(buffer->isMemObjZeroCopy()); - if (MemoryPool::isSystemMemoryPool(allocation->getMemoryPool())) { + if (MemoryPoolHelper::isSystemMemoryPool(allocation->getMemoryPool())) { EXPECT_EQ(allocation->getAllocationType(), AllocationType::BUFFER_HOST_MEMORY); } else { EXPECT_EQ(allocation->getAllocationType(), AllocationType::BUFFER); @@ -965,7 +965,7 @@ TEST_P(NoHostPtr, WhenGettingAllocationTypeThenCorrectBufferTypeIsReturned) { ASSERT_NE(nullptr, buffer); auto allocation = buffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()); - if (MemoryPool::isSystemMemoryPool(allocation->getMemoryPool())) { + if (MemoryPoolHelper::isSystemMemoryPool(allocation->getMemoryPool())) { EXPECT_EQ(allocation->getAllocationType(), AllocationType::BUFFER_HOST_MEMORY); } else { EXPECT_EQ(allocation->getAllocationType(), AllocationType::BUFFER); @@ -2017,8 +2017,8 @@ TEST_F(MultiRootDeviceBufferTest, WhenBufferIsCreatedThenBufferMultiGraphicsAllo std::unique_ptr buffer1(Buffer::create(context.get(), 0, MemoryConstants::pageSize, nullptr, retVal)); - EXPECT_TRUE(MemoryPool::isSystemMemoryPool(buffer1->getMultiGraphicsAllocation().getGraphicsAllocation(1u)->getMemoryPool())); - EXPECT_TRUE(MemoryPool::isSystemMemoryPool(buffer1->getMultiGraphicsAllocation().getGraphicsAllocation(2u)->getMemoryPool())); + EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(buffer1->getMultiGraphicsAllocation().getGraphicsAllocation(1u)->getMemoryPool())); + EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(buffer1->getMultiGraphicsAllocation().getGraphicsAllocation(2u)->getMemoryPool())); } TEST(MultiRootDeviceBufferTest2, WhenBufferIsCreatedThenSecondAndSubsequentAllocationsAreCreatedFromExisitingStorage) { diff --git a/opencl/test/unit_test/mem_obj/buffer_tests_xehp_and_later.cpp b/opencl/test/unit_test/mem_obj/buffer_tests_xehp_and_later.cpp index 0f971d74a6..4a4bf5225d 100644 --- a/opencl/test/unit_test/mem_obj/buffer_tests_xehp_and_later.cpp +++ b/opencl/test/unit_test/mem_obj/buffer_tests_xehp_and_later.cpp @@ -80,7 +80,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPAndLaterBufferTests, givenBufferAllocationInDev gmm->isCompressionEnabled = true; allocation->setDefaultGmm(gmm); - EXPECT_TRUE(!MemoryPool::isSystemMemoryPool(allocation->getMemoryPool())); + EXPECT_TRUE(!MemoryPoolHelper::isSystemMemoryPool(allocation->getMemoryPool())); RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState; @@ -110,7 +110,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPAndLaterBufferTests, givenBufferAllocationInHos retVal)); EXPECT_EQ(CL_SUCCESS, retVal); - EXPECT_TRUE(MemoryPool::isSystemMemoryPool(buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getMemoryPool())); + EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getMemoryPool())); RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState; diff --git a/opencl/test/unit_test/os_interface/linux/drm_command_stream_tests_2.cpp b/opencl/test/unit_test/os_interface/linux/drm_command_stream_tests_2.cpp index 0e555305e9..9badda5fb7 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_command_stream_tests_2.cpp +++ b/opencl/test/unit_test/os_interface/linux/drm_command_stream_tests_2.cpp @@ -846,7 +846,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenDrmCommandStreamReceiverWh } struct MockDrmAllocationBindBO : public DrmAllocation { - MockDrmAllocationBindBO(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObjects &bos, void *ptrIn, uint64_t gpuAddress, size_t sizeIn, MemoryPool::Type pool) + MockDrmAllocationBindBO(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObjects &bos, void *ptrIn, uint64_t gpuAddress, size_t sizeIn, MemoryPool pool) : DrmAllocation(rootDeviceIndex, allocationType, bos, ptrIn, gpuAddress, sizeIn, pool) { } @@ -855,7 +855,7 @@ struct MockDrmAllocationBindBO : public DrmAllocation { }; struct MockDrmAllocationBindBOs : public DrmAllocation { - MockDrmAllocationBindBOs(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObjects &bos, void *ptrIn, uint64_t gpuAddress, size_t sizeIn, MemoryPool::Type pool) + MockDrmAllocationBindBOs(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObjects &bos, void *ptrIn, uint64_t gpuAddress, size_t sizeIn, MemoryPool pool) : DrmAllocation(rootDeviceIndex, allocationType, bos, ptrIn, gpuAddress, sizeIn, pool) { } diff --git a/opencl/test/unit_test/os_interface/linux/file_logger_linux_tests.cpp b/opencl/test/unit_test/os_interface/linux/file_logger_linux_tests.cpp index cac2bc9987..c16c259618 100644 --- a/opencl/test/unit_test/os_interface/linux/file_logger_linux_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/file_logger_linux_tests.cpp @@ -44,7 +44,7 @@ TEST(FileLogger, GivenLogAllocationMemoryPoolFlagThenLogsCorrectInfo) { threadIDCheck << " ThreadID: " << thisThread; std::stringstream memoryPoolCheck; - memoryPoolCheck << " MemoryPool: " << allocation.getMemoryPool(); + memoryPoolCheck << " MemoryPool: " << getMemoryPoolString(&allocation); std::stringstream gpuAddressCheck; gpuAddressCheck << " GPU address: 0x" << std::hex << allocation.getGpuAddress(); @@ -96,7 +96,7 @@ TEST(FileLogger, givenLogAllocationStdoutWhenLogAllocationThenLogToStdoutInstead threadIDCheck << " ThreadID: " << thisThread; std::stringstream memoryPoolCheck; - memoryPoolCheck << " MemoryPool: " << allocation.getMemoryPool(); + memoryPoolCheck << " MemoryPool: " << getMemoryPoolString(&allocation); std::stringstream gpuAddressCheck; gpuAddressCheck << " GPU address: 0x" << std::hex << allocation.getGpuAddress(); @@ -135,7 +135,7 @@ TEST(FileLogger, GivenDrmAllocationWithoutBOThenNoHandleLogged) { threadIDCheck << " ThreadID: " << thisThread; std::stringstream memoryPoolCheck; - memoryPoolCheck << " MemoryPool: " << allocation.getMemoryPool(); + memoryPoolCheck << " MemoryPool: " << getMemoryPoolString(&allocation); if (fileLogger.wasFileCreated(fileLogger.getLogFileName())) { auto str = fileLogger.getFileString(fileLogger.getLogFileName()); @@ -166,7 +166,7 @@ TEST(FileLogger, GivenLogAllocationMemoryPoolFlagSetFalseThenAllocationIsNotLogg threadIDCheck << " ThreadID: " << thisThread; std::stringstream memoryPoolCheck; - memoryPoolCheck << " MemoryPool: " << allocation.getMemoryPool(); + memoryPoolCheck << " MemoryPool: " << getMemoryPoolString(&allocation); if (fileLogger.wasFileCreated(fileLogger.getLogFileName())) { auto str = fileLogger.getFileString(fileLogger.getLogFileName()); diff --git a/opencl/test/unit_test/os_interface/windows/file_logger_win_tests.cpp b/opencl/test/unit_test/os_interface/windows/file_logger_win_tests.cpp index 1698e7750e..ab13e7a096 100644 --- a/opencl/test/unit_test/os_interface/windows/file_logger_win_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/file_logger_win_tests.cpp @@ -43,7 +43,7 @@ TEST_F(FileLoggerTests, GivenLogAllocationMemoryPoolFlagThenLogsCorrectInfo) { threadIDCheck << " ThreadID: " << thisThread; std::stringstream memoryPoolCheck; - memoryPoolCheck << " MemoryPool: " << allocation.getMemoryPool(); + memoryPoolCheck << " MemoryPool: " << getMemoryPoolString(&allocation); std::stringstream gpuAddressCheck; gpuAddressCheck << " GPU address: 0x" << std::hex << allocation.getGpuAddress(); @@ -88,7 +88,7 @@ TEST_F(FileLoggerTests, GivenLogAllocationMemoryPoolFlagSetFalseThenAllocationIs threadIDCheck << " ThreadID: " << thisThread; std::stringstream memoryPoolCheck; - memoryPoolCheck << " MemoryPool: " << allocation.getMemoryPool(); + memoryPoolCheck << " MemoryPool: " << getMemoryPoolString(&allocation); if (fileLogger.wasFileCreated(fileLogger.getLogFileName())) { auto str = fileLogger.getFileString(fileLogger.getLogFileName()); diff --git a/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_allocate_in_device_pool_tests.cpp b/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_allocate_in_device_pool_tests.cpp index 0e69a41a75..29daa46667 100644 --- a/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_allocate_in_device_pool_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_allocate_in_device_pool_tests.cpp @@ -368,7 +368,7 @@ TEST_F(WddmMemoryManagerTest, givenLocalMemoryAllocationWhenCpuPointerNotMeetRes auto allocation = static_cast(memoryManager->allocateGraphicsMemoryWithProperties({mockRootDeviceIndex, size, AllocationType::BUFFER, mockDeviceBitfield}, cpuPtr)); ASSERT_NE(nullptr, allocation); - EXPECT_FALSE(MemoryPool::isSystemMemoryPool(allocation->getMemoryPool())); + EXPECT_FALSE(MemoryPoolHelper::isSystemMemoryPool(allocation->getMemoryPool())); if (is32bit && this->executionEnvironment->rootDeviceEnvironments[allocation->getRootDeviceIndex()]->isFullRangeSvm()) { EXPECT_NE(nullptr, allocation->getReservedAddressPtr()); EXPECT_EQ(alignUp(size, MemoryConstants::pageSize64k) + 2 * MemoryConstants::megaByte, allocation->getReservedAddressSize()); diff --git a/opencl/test/unit_test/utilities/file_logger_tests.cpp b/opencl/test/unit_test/utilities/file_logger_tests.cpp index af41bce0cf..a117ab1aa5 100644 --- a/opencl/test/unit_test/utilities/file_logger_tests.cpp +++ b/opencl/test/unit_test/utilities/file_logger_tests.cpp @@ -1034,3 +1034,35 @@ TEST(AllocationTypeLoggingSingle, givenLogAllocationTypeWhenLoggingAllocationThe EXPECT_FALSE(true); } } + +struct MemoryPoolTestCase { + MemoryPool pool; + const char *str; +}; + +MemoryPoolTestCase memoryPoolValues[] = { + {MemoryPool::MemoryNull, "MemoryNull"}, + {MemoryPool::LocalMemory, "LocalMemory"}, + {MemoryPool::System4KBPages, "System4KBPages"}, + {MemoryPool::System4KBPagesWith32BitGpuAddressing, "System4KBPagesWith32BitGpuAddressing"}, + {MemoryPool::System64KBPages, "System64KBPages"}, + {MemoryPool::System64KBPagesWith32BitGpuAddressing, "System64KBPagesWith32BitGpuAddressing"}, + {MemoryPool::SystemCpuInaccessible, "SystemCpuInaccessible"}}; + +class MemoryPoolLogging : public ::testing::TestWithParam {}; + +TEST_P(MemoryPoolLogging, givenGraphicsMemoryPoolWhenConvertingToStringThenCorrectStringIsReturned) { + std::string testFile = "testfile"; + DebugVariables flags; + FullyEnabledFileLogger fileLogger(testFile, flags); + auto input = GetParam(); + + GraphicsAllocation graphicsAllocation(0, AllocationType::UNKNOWN, nullptr, 0, 0, input.pool, MemoryManager::maxOsContextCount); + auto result = getMemoryPoolString(&graphicsAllocation); + + EXPECT_STREQ(result, input.str); +} + +INSTANTIATE_TEST_CASE_P(AllMemoryPooles, + MemoryPoolLogging, + ::testing::ValuesIn(memoryPoolValues)); diff --git a/opencl/test/unit_test/xe_hp_core/copy_engine_tests_xe_hp_core.cpp b/opencl/test/unit_test/xe_hp_core/copy_engine_tests_xe_hp_core.cpp index 7c64490986..49f984c1ff 100644 --- a/opencl/test/unit_test/xe_hp_core/copy_engine_tests_xe_hp_core.cpp +++ b/opencl/test/unit_test/xe_hp_core/copy_engine_tests_xe_hp_core.cpp @@ -336,9 +336,9 @@ XE_HP_CORE_TEST_F(BlitXE_HP_CORETests, givenBufferWhenProgrammingBltCommandThenS cl_int retVal = CL_SUCCESS; auto bufferInSystemPool = clUniquePtr(Buffer::create(&context, CL_MEM_FORCE_HOST_MEMORY_INTEL, 2048, nullptr, retVal)); - EXPECT_TRUE(MemoryPool::isSystemMemoryPool(bufferInSystemPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); + EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(bufferInSystemPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); auto bufferInLocalPool = clUniquePtr(Buffer::create(&context, CL_MEM_READ_WRITE, 2048, nullptr, retVal)); - EXPECT_FALSE(MemoryPool::isSystemMemoryPool(bufferInLocalPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); + EXPECT_FALSE(MemoryPoolHelper::isSystemMemoryPool(bufferInLocalPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); { auto blitProperties = BlitProperties::constructPropertiesForCopy(bufferInSystemPool->getGraphicsAllocation(clDevice->getRootDeviceIndex()), @@ -390,9 +390,9 @@ XE_HP_CORE_TEST_F(BlitXE_HP_CORETests, givenBufferWhenProgrammingBltCommandThenS cl_int retVal = CL_SUCCESS; auto bufferInSystemPool = clUniquePtr(Buffer::create(&context, CL_MEM_FORCE_HOST_MEMORY_INTEL, 2048, nullptr, retVal)); - EXPECT_TRUE(MemoryPool::isSystemMemoryPool(bufferInSystemPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); + EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(bufferInSystemPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); auto bufferInLocalPool = clUniquePtr(Buffer::create(&context, CL_MEM_READ_WRITE, 2048, nullptr, retVal)); - EXPECT_FALSE(MemoryPool::isSystemMemoryPool(bufferInLocalPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); + EXPECT_FALSE(MemoryPoolHelper::isSystemMemoryPool(bufferInLocalPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); { auto blitProperties = BlitProperties::constructPropertiesForCopy(bufferInSystemPool->getGraphicsAllocation(clDevice->getRootDeviceIndex()), @@ -448,9 +448,9 @@ XE_HP_CORE_TEST_F(BlitXE_HP_CORETests, givenBufferWhenProgrammingBltCommandThenS cl_int retVal = CL_SUCCESS; auto bufferInSystemPool = clUniquePtr(Buffer::create(&context, CL_MEM_FORCE_HOST_MEMORY_INTEL, 2048, nullptr, retVal)); - EXPECT_TRUE(MemoryPool::isSystemMemoryPool(bufferInSystemPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); + EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(bufferInSystemPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); auto bufferInLocalPool = clUniquePtr(Buffer::create(&context, CL_MEM_READ_WRITE, 2048, nullptr, retVal)); - EXPECT_FALSE(MemoryPool::isSystemMemoryPool(bufferInLocalPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); + EXPECT_FALSE(MemoryPoolHelper::isSystemMemoryPool(bufferInLocalPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); DebugManager.flags.OverrideBlitterTargetMemory.set(0u); { @@ -519,9 +519,9 @@ XE_HP_CORE_TEST_F(BlitXE_HP_CORETests, givenBufferWhenProgrammingBltCommandAndRe cl_int retVal = CL_SUCCESS; auto bufferInSystemPool = clUniquePtr(Buffer::create(&context, CL_MEM_FORCE_HOST_MEMORY_INTEL, 2048, nullptr, retVal)); - EXPECT_TRUE(MemoryPool::isSystemMemoryPool(bufferInSystemPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); + EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(bufferInSystemPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); auto bufferInLocalPool = clUniquePtr(Buffer::create(&context, CL_MEM_READ_WRITE, 2048, nullptr, retVal)); - EXPECT_FALSE(MemoryPool::isSystemMemoryPool(bufferInLocalPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); + EXPECT_FALSE(MemoryPoolHelper::isSystemMemoryPool(bufferInLocalPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); { auto blitProperties = BlitProperties::constructPropertiesForCopy(bufferInSystemPool->getGraphicsAllocation(clDevice->getRootDeviceIndex()), diff --git a/opencl/test/unit_test/xe_hpc_core/pvc/command_stream_receiver_hw_tests_pvc.cpp b/opencl/test/unit_test/xe_hpc_core/pvc/command_stream_receiver_hw_tests_pvc.cpp index 1dfe9ccbdb..316dee5d80 100644 --- a/opencl/test/unit_test/xe_hpc_core/pvc/command_stream_receiver_hw_tests_pvc.cpp +++ b/opencl/test/unit_test/xe_hpc_core/pvc/command_stream_receiver_hw_tests_pvc.cpp @@ -161,7 +161,7 @@ PVCTEST_F(PVcBcsTests, givenBufferInDeviceMemoryWhenStatelessCompressionIsEnable EXPECT_EQ(CL_SUCCESS, retVal); auto allocation = buffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()); - EXPECT_TRUE(!MemoryPool::isSystemMemoryPool(allocation->getMemoryPool())); + EXPECT_TRUE(!MemoryPoolHelper::isSystemMemoryPool(allocation->getMemoryPool())); auto blitProperties = BlitProperties::constructPropertiesForCopy(allocation, allocation, 0, 0, {BlitterConstants::maxBlitWidth - 1, 1, 1}, 0, 0, 0, 0, &clearColorAlloc); @@ -190,7 +190,7 @@ PVCTEST_F(PVcBcsTests, givenBufferInSystemMemoryWhenStatelessCompressionIsEnable EXPECT_EQ(CL_SUCCESS, retVal); auto allocation = buffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()); - EXPECT_TRUE(MemoryPool::isSystemMemoryPool(allocation->getMemoryPool())); + EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(allocation->getMemoryPool())); auto blitProperties = BlitProperties::constructPropertiesForCopy(allocation, allocation, 0, 0, {BlitterConstants::maxBlitWidth - 1, 1, 1}, 0, 0, 0, 0, &clearColorAlloc); diff --git a/opencl/test/unit_test/xe_hpg_core/copy_engine_tests_xe_hpg_core.cpp b/opencl/test/unit_test/xe_hpg_core/copy_engine_tests_xe_hpg_core.cpp index 79ce391aa3..3b6b38475d 100644 --- a/opencl/test/unit_test/xe_hpg_core/copy_engine_tests_xe_hpg_core.cpp +++ b/opencl/test/unit_test/xe_hpg_core/copy_engine_tests_xe_hpg_core.cpp @@ -176,9 +176,9 @@ XE_HPG_CORETEST_F(BlitXeHpgCoreTests, givenBufferWhenProgrammingBltCommandThenSe cl_int retVal = CL_SUCCESS; auto bufferInSystemPool = clUniquePtr(Buffer::create(&context, CL_MEM_FORCE_HOST_MEMORY_INTEL, 2048, nullptr, retVal)); - EXPECT_TRUE(MemoryPool::isSystemMemoryPool(bufferInSystemPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); + EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(bufferInSystemPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); auto bufferInLocalPool = clUniquePtr(Buffer::create(&context, CL_MEM_READ_WRITE, 2048, nullptr, retVal)); - EXPECT_FALSE(MemoryPool::isSystemMemoryPool(bufferInLocalPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); + EXPECT_FALSE(MemoryPoolHelper::isSystemMemoryPool(bufferInLocalPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); { auto blitProperties = BlitProperties::constructPropertiesForCopy(bufferInSystemPool->getGraphicsAllocation(clDevice->getRootDeviceIndex()), @@ -227,9 +227,9 @@ XE_HPG_CORETEST_F(BlitXeHpgCoreTests, givenBufferWhenProgrammingBltCommandThenSe cl_int retVal = CL_SUCCESS; auto bufferInSystemPool = clUniquePtr(Buffer::create(&context, CL_MEM_FORCE_HOST_MEMORY_INTEL, 2048, nullptr, retVal)); - EXPECT_TRUE(MemoryPool::isSystemMemoryPool(bufferInSystemPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); + EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(bufferInSystemPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); auto bufferInLocalPool = clUniquePtr(Buffer::create(&context, CL_MEM_READ_WRITE, 2048, nullptr, retVal)); - EXPECT_FALSE(MemoryPool::isSystemMemoryPool(bufferInLocalPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); + EXPECT_FALSE(MemoryPoolHelper::isSystemMemoryPool(bufferInLocalPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); { auto blitProperties = BlitProperties::constructPropertiesForCopy(bufferInSystemPool->getGraphicsAllocation(clDevice->getRootDeviceIndex()), @@ -278,9 +278,9 @@ XE_HPG_CORETEST_F(BlitXeHpgCoreTests, givenBufferWhenProgrammingBltCommandThenSe cl_int retVal = CL_SUCCESS; auto bufferInSystemPool = clUniquePtr(Buffer::create(&context, CL_MEM_FORCE_HOST_MEMORY_INTEL, 2048, nullptr, retVal)); - EXPECT_TRUE(MemoryPool::isSystemMemoryPool(bufferInSystemPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); + EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(bufferInSystemPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); auto bufferInLocalPool = clUniquePtr(Buffer::create(&context, CL_MEM_READ_WRITE, 2048, nullptr, retVal)); - EXPECT_FALSE(MemoryPool::isSystemMemoryPool(bufferInLocalPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); + EXPECT_FALSE(MemoryPoolHelper::isSystemMemoryPool(bufferInLocalPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); DebugManager.flags.OverrideBlitterTargetMemory.set(0u); { @@ -350,9 +350,9 @@ XE_HPG_CORETEST_F(BlitXeHpgCoreTests, givenBufferWhenProgrammingBltCommandAndRev cl_int retVal = CL_SUCCESS; auto bufferInSystemPool = clUniquePtr(Buffer::create(&context, CL_MEM_FORCE_HOST_MEMORY_INTEL, 2048, nullptr, retVal)); - EXPECT_TRUE(MemoryPool::isSystemMemoryPool(bufferInSystemPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); + EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(bufferInSystemPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); auto bufferInLocalPool = clUniquePtr(Buffer::create(&context, CL_MEM_READ_WRITE, 2048, nullptr, retVal)); - EXPECT_FALSE(MemoryPool::isSystemMemoryPool(bufferInLocalPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); + EXPECT_FALSE(MemoryPoolHelper::isSystemMemoryPool(bufferInLocalPool->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getMemoryPool())); { auto blitProperties = BlitProperties::constructPropertiesForCopy(bufferInSystemPool->getGraphicsAllocation(clDevice->getRootDeviceIndex()), diff --git a/shared/source/command_container/command_encoder_xehp_and_later.inl b/shared/source/command_container/command_encoder_xehp_and_later.inl index 623d7c1e42..af85b0fed6 100644 --- a/shared/source/command_container/command_encoder_xehp_and_later.inl +++ b/shared/source/command_container/command_encoder_xehp_and_later.inl @@ -638,7 +638,7 @@ void EncodeSurfaceState::encodeExtraBufferParams(EncodeSurfaceStateArgs } if (DebugManager.flags.EnableStatelessCompressionWithUnifiedMemory.get()) { - if (args.allocation && !MemoryPool::isSystemMemoryPool(args.allocation->getMemoryPool())) { + if (args.allocation && !MemoryPoolHelper::isSystemMemoryPool(args.allocation->getMemoryPool())) { setCoherencyType(surfaceState, R_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT); setBufferAuxParamsForCCS(surfaceState); compressionFormat = DebugManager.flags.FormatForStatelessCompressionWithUnifiedMemory.get(); diff --git a/shared/source/helpers/blit_commands_helper_xehp_and_later.inl b/shared/source/helpers/blit_commands_helper_xehp_and_later.inl index 6e8d99d355..cbba7bc7bb 100644 --- a/shared/source/helpers/blit_commands_helper_xehp_and_later.inl +++ b/shared/source/helpers/blit_commands_helper_xehp_and_later.inl @@ -63,10 +63,10 @@ void BlitCommandsHelper::appendBlitCommandsBlockCopy(const BlitProper blitCmd.setSourceCompressionFormat(compressionFormat); } - if (MemoryPool::isSystemMemoryPool(blitProperties.dstAllocation->getMemoryPool())) { + if (MemoryPoolHelper::isSystemMemoryPool(blitProperties.dstAllocation->getMemoryPool())) { blitCmd.setDestinationTargetMemory(XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM); } - if (MemoryPool::isSystemMemoryPool(blitProperties.srcAllocation->getMemoryPool())) { + if (MemoryPoolHelper::isSystemMemoryPool(blitProperties.srcAllocation->getMemoryPool())) { blitCmd.setSourceTargetMemory(XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM); } @@ -136,7 +136,7 @@ void BlitCommandsHelper::appendBlitCommandsForFillBuffer(NEO::Graphic blitCmd.setDestinationCompressionFormat(compressionFormat); } - if (MemoryPool::isSystemMemoryPool(dstAlloc->getMemoryPool())) { + if (MemoryPoolHelper::isSystemMemoryPool(dstAlloc->getMemoryPool())) { blitCmd.setDestinationTargetMemory(XY_COLOR_BLT::DESTINATION_TARGET_MEMORY::DESTINATION_TARGET_MEMORY_SYSTEM_MEM); } diff --git a/shared/source/memory_manager/graphics_allocation.cpp b/shared/source/memory_manager/graphics_allocation.cpp index f18919bc84..1fd583c219 100644 --- a/shared/source/memory_manager/graphics_allocation.cpp +++ b/shared/source/memory_manager/graphics_allocation.cpp @@ -21,7 +21,7 @@ void GraphicsAllocation::setAllocationType(AllocationType allocationType) { } GraphicsAllocation::GraphicsAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, void *cpuPtrIn, uint64_t canonizedGpuAddress, - uint64_t baseAddress, size_t sizeIn, MemoryPool::Type pool, size_t maxOsContextCount) + uint64_t baseAddress, size_t sizeIn, MemoryPool pool, size_t maxOsContextCount) : rootDeviceIndex(rootDeviceIndex), gpuBaseAddress(baseAddress), gpuAddress(canonizedGpuAddress), @@ -35,7 +35,7 @@ GraphicsAllocation::GraphicsAllocation(uint32_t rootDeviceIndex, size_t numGmms, } GraphicsAllocation::GraphicsAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, - osHandle sharedHandleIn, MemoryPool::Type pool, size_t maxOsContextCount) + osHandle sharedHandleIn, MemoryPool pool, size_t maxOsContextCount) : rootDeviceIndex(rootDeviceIndex), gpuAddress(GmmHelper::canonize(castToUint64(cpuPtrIn))), size(sizeIn), diff --git a/shared/source/memory_manager/graphics_allocation.h b/shared/source/memory_manager/graphics_allocation.h index c60cbba85f..1d324f3c0b 100644 --- a/shared/source/memory_manager/graphics_allocation.h +++ b/shared/source/memory_manager/graphics_allocation.h @@ -67,18 +67,18 @@ class GraphicsAllocation : public IDNode { GraphicsAllocation(const GraphicsAllocation &) = delete; GraphicsAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, - uint64_t gpuAddress, uint64_t baseAddress, size_t sizeIn, MemoryPool::Type pool, size_t maxOsContextCount) + uint64_t gpuAddress, uint64_t baseAddress, size_t sizeIn, MemoryPool pool, size_t maxOsContextCount) : GraphicsAllocation(rootDeviceIndex, 1, allocationType, cpuPtrIn, gpuAddress, baseAddress, sizeIn, pool, maxOsContextCount) {} GraphicsAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, - size_t sizeIn, osHandle sharedHandleIn, MemoryPool::Type pool, size_t maxOsContextCount) + size_t sizeIn, osHandle sharedHandleIn, MemoryPool pool, size_t maxOsContextCount) : GraphicsAllocation(rootDeviceIndex, 1, allocationType, cpuPtrIn, sizeIn, sharedHandleIn, pool, maxOsContextCount) {} GraphicsAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, void *cpuPtrIn, - uint64_t canonizedGpuAddress, uint64_t baseAddress, size_t sizeIn, MemoryPool::Type pool, size_t maxOsContextCount); + uint64_t canonizedGpuAddress, uint64_t baseAddress, size_t sizeIn, MemoryPool pool, size_t maxOsContextCount); GraphicsAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, void *cpuPtrIn, - size_t sizeIn, osHandle sharedHandleIn, MemoryPool::Type pool, size_t maxOsContextCount); + size_t sizeIn, osHandle sharedHandleIn, MemoryPool pool, size_t maxOsContextCount); uint32_t getRootDeviceIndex() const { return rootDeviceIndex; } void *getUnderlyingBuffer() const { return cpuPtr; } @@ -152,7 +152,7 @@ class GraphicsAllocation : public IDNode { void setAllocationType(AllocationType allocationType); AllocationType getAllocationType() const { return allocationType; } - MemoryPool::Type getMemoryPool() const { return memoryPool; } + MemoryPool getMemoryPool() const { return memoryPool; } bool isUsed() const { return registeredContextsNum > 0; } bool isUsedByManyOsContexts() const { return registeredContextsNum > 1u; } @@ -326,7 +326,7 @@ class GraphicsAllocation : public IDNode { void *cpuPtr = nullptr; void *lockedPtr = nullptr; - MemoryPool::Type memoryPool = MemoryPool::MemoryNull; + MemoryPool memoryPool = MemoryPool::MemoryNull; AllocationType allocationType = AllocationType::UNKNOWN; StackVec usageInfos; diff --git a/shared/source/memory_manager/memory_pool.h b/shared/source/memory_manager/memory_pool.h index c6bea9e5f3..378259a31c 100644 --- a/shared/source/memory_manager/memory_pool.h +++ b/shared/source/memory_manager/memory_pool.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2020 Intel Corporation + * Copyright (C) 2018-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -7,24 +7,26 @@ #pragma once -#include "shared/source/helpers/extendable_enum.h" +namespace NEO { -namespace MemoryPool { -struct Type : ExtendableEnum { - constexpr Type(uint32_t val) : ExtendableEnum(val) {} +enum class MemoryPool { + MemoryNull, + System4KBPages, + System64KBPages, + System4KBPagesWith32BitGpuAddressing, + System64KBPagesWith32BitGpuAddressing, + SystemCpuInaccessible, + LocalMemory, }; -constexpr Type MemoryNull{0}; -constexpr Type System4KBPages{1}; -constexpr Type System64KBPages{2}; -constexpr Type System4KBPagesWith32BitGpuAddressing{3}; -constexpr Type System64KBPagesWith32BitGpuAddressing{4}; -constexpr Type SystemCpuInaccessible{5}; -constexpr Type LocalMemory{6}; -inline bool isSystemMemoryPool(Type pool) { - return pool == System4KBPages || - pool == System64KBPages || - pool == System4KBPagesWith32BitGpuAddressing || - pool == System64KBPagesWith32BitGpuAddressing; +namespace MemoryPoolHelper { + +inline bool isSystemMemoryPool(MemoryPool pool) { + return pool == MemoryPool::System4KBPages || + pool == MemoryPool::System64KBPages || + pool == MemoryPool::System4KBPagesWith32BitGpuAddressing || + pool == MemoryPool::System64KBPagesWith32BitGpuAddressing; } -} // namespace MemoryPool + +} // namespace MemoryPoolHelper +} // namespace NEO diff --git a/shared/source/memory_manager/os_agnostic_memory_manager.cpp b/shared/source/memory_manager/os_agnostic_memory_manager.cpp index 573b247a41..fdf65a5657 100644 --- a/shared/source/memory_manager/os_agnostic_memory_manager.cpp +++ b/shared/source/memory_manager/os_agnostic_memory_manager.cpp @@ -420,7 +420,7 @@ void OsAgnosticMemoryManager::releaseReservedCpuAddressRange(void *reserved, siz MemoryAllocation *OsAgnosticMemoryManager::createMemoryAllocation(AllocationType allocationType, void *driverAllocatedCpuPointer, void *pMem, uint64_t gpuAddress, size_t memSize, uint64_t count, - MemoryPool::Type pool, uint32_t rootDeviceIndex, bool uncacheable, + MemoryPool pool, uint32_t rootDeviceIndex, bool uncacheable, bool flushL3Required, bool requireSpecificBitness) { auto gmmHelper = getGmmHelper(rootDeviceIndex); if (!isLimitedRange(rootDeviceIndex)) { @@ -554,7 +554,7 @@ double OsAgnosticMemoryManager::getPercentOfGlobalMemoryAvailable(uint32_t rootD return 0.8; } -void MemoryAllocation::overrideMemoryPool(MemoryPool::Type pool) { +void MemoryAllocation::overrideMemoryPool(MemoryPool pool) { if (DebugManager.flags.AUBDumpForceAllToLocalMemory.get()) { this->memoryPool = MemoryPool::LocalMemory; return; diff --git a/shared/source/memory_manager/os_agnostic_memory_manager.h b/shared/source/memory_manager/os_agnostic_memory_manager.h index d4db0cc856..697b17c581 100644 --- a/shared/source/memory_manager/os_agnostic_memory_manager.h +++ b/shared/source/memory_manager/os_agnostic_memory_manager.h @@ -19,28 +19,28 @@ class MemoryAllocation : public GraphicsAllocation { const bool uncacheable; MemoryAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress, size_t sizeIn, - MemoryPool::Type pool, size_t maxOsContextCount) + MemoryPool pool, size_t maxOsContextCount) : MemoryAllocation(rootDeviceIndex, 1, allocationType, cpuPtrIn, gpuAddress, baseAddress, sizeIn, pool, maxOsContextCount) {} MemoryAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, void *cpuPtrIn, uint64_t canonizedGpuAddress, uint64_t baseAddress, size_t sizeIn, - MemoryPool::Type pool, size_t maxOsContextCount) + MemoryPool pool, size_t maxOsContextCount) : GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, cpuPtrIn, canonizedGpuAddress, baseAddress, sizeIn, pool, maxOsContextCount), id(0), uncacheable(false) {} - MemoryAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, MemoryPool::Type pool, size_t maxOsContextCount) + MemoryAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, MemoryPool pool, size_t maxOsContextCount) : MemoryAllocation(rootDeviceIndex, 1, allocationType, cpuPtrIn, sizeIn, sharedHandleIn, pool, maxOsContextCount) {} - MemoryAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, MemoryPool::Type pool, size_t maxOsContextCount) + MemoryAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, MemoryPool pool, size_t maxOsContextCount) : GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, cpuPtrIn, sizeIn, sharedHandleIn, pool, maxOsContextCount), id(0), uncacheable(false) {} MemoryAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *driverAllocatedCpuPointer, void *pMem, uint64_t canonizedGpuAddress, size_t memSize, - uint64_t count, MemoryPool::Type pool, bool uncacheable, bool flushL3Required, size_t maxOsContextCount) + uint64_t count, MemoryPool pool, bool uncacheable, bool flushL3Required, size_t maxOsContextCount) : MemoryAllocation(rootDeviceIndex, 1, allocationType, driverAllocatedCpuPointer, pMem, canonizedGpuAddress, memSize, count, pool, uncacheable, flushL3Required, maxOsContextCount) {} MemoryAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, void *driverAllocatedCpuPointer, void *pMem, uint64_t canonizedGpuAddress, size_t memSize, - uint64_t count, MemoryPool::Type pool, bool uncacheable, bool flushL3Required, size_t maxOsContextCount) + uint64_t count, MemoryPool pool, bool uncacheable, bool flushL3Required, size_t maxOsContextCount) : GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, pMem, canonizedGpuAddress, 0u, memSize, pool, maxOsContextCount), id(count), uncacheable(uncacheable) { @@ -49,7 +49,7 @@ class MemoryAllocation : public GraphicsAllocation { allocationInfo.flags.flushL3Required = flushL3Required; } - void overrideMemoryPool(MemoryPool::Type pool); + void overrideMemoryPool(MemoryPool pool); void clearUsageInfo() { for (auto &info : usageInfos) { @@ -109,7 +109,7 @@ class OsAgnosticMemoryManager : public MemoryManager { GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) override; GraphicsAllocation *allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) override; MemoryAllocation *createMemoryAllocation(AllocationType allocationType, void *driverAllocatedCpuPointer, void *pMem, uint64_t gpuAddress, size_t memSize, - uint64_t count, MemoryPool::Type pool, uint32_t rootDeviceIndex, bool uncacheable, bool flushL3Required, bool requireSpecificBitness); + uint64_t count, MemoryPool pool, uint32_t rootDeviceIndex, bool uncacheable, bool flushL3Required, bool requireSpecificBitness); bool fakeBigAllocations = false; private: diff --git a/shared/source/os_interface/linux/drm_allocation.h b/shared/source/os_interface/linux/drm_allocation.h index a78d4c5845..9de71e2747 100644 --- a/shared/source/os_interface/linux/drm_allocation.h +++ b/shared/source/os_interface/linux/drm_allocation.h @@ -33,26 +33,26 @@ class DrmAllocation : public GraphicsAllocation { MemoryUnmapFunction unmapFunction; }; - DrmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObject *bo, void *ptrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool::Type pool) + DrmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObject *bo, void *ptrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool pool) : DrmAllocation(rootDeviceIndex, 1, allocationType, bo, ptrIn, sizeIn, sharedHandle, pool) {} - DrmAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, BufferObject *bo, void *ptrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool::Type pool) + DrmAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, BufferObject *bo, void *ptrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool pool) : GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, ptrIn, sizeIn, sharedHandle, pool, MemoryManager::maxOsContextCount), bufferObjects(EngineLimits::maxHandleCount) { bufferObjects[0] = bo; } - DrmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObject *bo, void *ptrIn, uint64_t canonizedGpuAddress, size_t sizeIn, MemoryPool::Type pool) + DrmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObject *bo, void *ptrIn, uint64_t canonizedGpuAddress, size_t sizeIn, MemoryPool pool) : DrmAllocation(rootDeviceIndex, 1, allocationType, bo, ptrIn, canonizedGpuAddress, sizeIn, pool) {} - DrmAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, BufferObject *bo, void *ptrIn, uint64_t canonizedGpuAddress, size_t sizeIn, MemoryPool::Type pool) + DrmAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, BufferObject *bo, void *ptrIn, uint64_t canonizedGpuAddress, size_t sizeIn, MemoryPool pool) : GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, ptrIn, canonizedGpuAddress, 0, sizeIn, pool, MemoryManager::maxOsContextCount), bufferObjects(EngineLimits::maxHandleCount) { bufferObjects[0] = bo; } - DrmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObjects &bos, void *ptrIn, uint64_t canonizedGpuAddress, size_t sizeIn, MemoryPool::Type pool) + DrmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObjects &bos, void *ptrIn, uint64_t canonizedGpuAddress, size_t sizeIn, MemoryPool pool) : DrmAllocation(rootDeviceIndex, 1, allocationType, bos, ptrIn, canonizedGpuAddress, sizeIn, pool) {} - DrmAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, BufferObjects &bos, void *ptrIn, uint64_t canonizedGpuAddress, size_t sizeIn, MemoryPool::Type pool) + DrmAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, BufferObjects &bos, void *ptrIn, uint64_t canonizedGpuAddress, size_t sizeIn, MemoryPool pool) : GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, ptrIn, canonizedGpuAddress, 0, sizeIn, pool, MemoryManager::maxOsContextCount), bufferObjects(bos) { } diff --git a/shared/source/os_interface/linux/drm_memory_manager.cpp b/shared/source/os_interface/linux/drm_memory_manager.cpp index 44cc6ae14a..181fcefacf 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.cpp +++ b/shared/source/os_interface/linux/drm_memory_manager.cpp @@ -1303,7 +1303,7 @@ bool DrmMemoryManager::copyMemoryToAllocation(GraphicsAllocation *graphicsAlloca return copyMemoryToAllocationBanks(graphicsAllocation, destinationOffset, memoryToCopy, sizeToCopy, maxNBitValue(graphicsAllocation->storageInfo.getNumBanks())); } bool DrmMemoryManager::copyMemoryToAllocationBanks(GraphicsAllocation *graphicsAllocation, size_t destinationOffset, const void *memoryToCopy, size_t sizeToCopy, DeviceBitfield handleMask) { - if (MemoryPool::isSystemMemoryPool(graphicsAllocation->getMemoryPool())) { + if (MemoryPoolHelper::isSystemMemoryPool(graphicsAllocation->getMemoryPool())) { return false; } auto drmAllocation = static_cast(graphicsAllocation); diff --git a/shared/source/os_interface/windows/wddm_allocation.h b/shared/source/os_interface/windows/wddm_allocation.h index 71e8377dca..eb0c237f47 100644 --- a/shared/source/os_interface/windows/wddm_allocation.h +++ b/shared/source/os_interface/windows/wddm_allocation.h @@ -24,11 +24,11 @@ constexpr size_t trimListUnusedPosition = std::numeric_limits::max(); class WddmAllocation : public GraphicsAllocation { public: - WddmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, uint64_t canonizedAddress, size_t sizeIn, void *reservedAddr, MemoryPool::Type pool, uint32_t shareable, size_t maxOsContextCount) + WddmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, uint64_t canonizedAddress, size_t sizeIn, void *reservedAddr, MemoryPool pool, uint32_t shareable, size_t maxOsContextCount) : WddmAllocation(rootDeviceIndex, 1, allocationType, cpuPtrIn, canonizedAddress, sizeIn, reservedAddr, pool, shareable, maxOsContextCount) {} WddmAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, void *cpuPtrIn, uint64_t canonizedAddress, size_t sizeIn, - void *reservedAddr, MemoryPool::Type pool, uint32_t shareable, size_t maxOsContextCount) + void *reservedAddr, MemoryPool pool, uint32_t shareable, size_t maxOsContextCount) : GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, cpuPtrIn, canonizedAddress, 0llu, sizeIn, pool, maxOsContextCount), shareable(shareable), trimCandidateListPositions(maxOsContextCount, trimListUnusedPosition) { reservedAddressRangeInfo.addressPtr = reservedAddr; @@ -36,11 +36,11 @@ class WddmAllocation : public GraphicsAllocation { handles.resize(gmms.size()); } - WddmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool::Type pool, size_t maxOsContextCount) + WddmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool pool, size_t maxOsContextCount) : WddmAllocation(rootDeviceIndex, 1, allocationType, cpuPtrIn, sizeIn, sharedHandle, pool, maxOsContextCount) {} WddmAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, - osHandle sharedHandle, MemoryPool::Type pool, size_t maxOsContextCount) + osHandle sharedHandle, MemoryPool pool, size_t maxOsContextCount) : GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, cpuPtrIn, sizeIn, sharedHandle, pool, maxOsContextCount), trimCandidateListPositions(maxOsContextCount, trimListUnusedPosition) { handles.resize(gmms.size()); diff --git a/shared/source/os_interface/windows/wddm_memory_manager.cpp b/shared/source/os_interface/windows/wddm_memory_manager.cpp index 577ab1d32c..503a01ebbd 100644 --- a/shared/source/os_interface/windows/wddm_memory_manager.cpp +++ b/shared/source/os_interface/windows/wddm_memory_manager.cpp @@ -925,7 +925,7 @@ bool WddmMemoryManager::copyMemoryToAllocation(GraphicsAllocation *graphicsAlloc } bool WddmMemoryManager::copyMemoryToAllocationBanks(GraphicsAllocation *graphicsAllocation, size_t destinationOffset, const void *memoryToCopy, size_t sizeToCopy, DeviceBitfield handleMask) { - if (MemoryPool::isSystemMemoryPool(graphicsAllocation->getMemoryPool())) { + if (MemoryPoolHelper::isSystemMemoryPool(graphicsAllocation->getMemoryPool())) { return false; } auto &wddm = getWddm(graphicsAllocation->getRootDeviceIndex()); diff --git a/shared/source/utilities/logger.cpp b/shared/source/utilities/logger.cpp index 43d767b758..7cb57ddf7f 100644 --- a/shared/source/utilities/logger.cpp +++ b/shared/source/utilities/logger.cpp @@ -95,7 +95,7 @@ void FileLogger::logAllocation(GraphicsAllocation const *graphicsAll ss << " ThreadID: " << thisThread; ss << " AllocationType: " << getAllocationTypeString(graphicsAllocation); - ss << " MemoryPool: " << graphicsAllocation->getMemoryPool(); + ss << " MemoryPool: " << getMemoryPoolString(graphicsAllocation); ss << " Root device index: " << graphicsAllocation->getRootDeviceIndex(); ss << " GPU address: 0x" << std::hex << graphicsAllocation->getGpuAddress() << " - 0x" << std::hex << graphicsAllocation->getGpuAddress() + graphicsAllocation->getUnderlyingBufferSize() - 1; @@ -233,6 +233,30 @@ const char *getAllocationTypeString(GraphicsAllocation const *graphicsAllocation } } +const char *getMemoryPoolString(GraphicsAllocation const *graphicsAllocation) { + auto pool = graphicsAllocation->getMemoryPool(); + + switch (pool) { + case MemoryPool::MemoryNull: + return "MemoryNull"; + case MemoryPool::System4KBPages: + return "System4KBPages"; + case MemoryPool::System64KBPages: + return "System64KBPages"; + case MemoryPool::System4KBPagesWith32BitGpuAddressing: + return "System4KBPagesWith32BitGpuAddressing"; + case MemoryPool::System64KBPagesWith32BitGpuAddressing: + return "System64KBPagesWith32BitGpuAddressing"; + case MemoryPool::SystemCpuInaccessible: + return "SystemCpuInaccessible"; + case MemoryPool::LocalMemory: + return "LocalMemory"; + } + + UNRECOVERABLE_IF(true); + return "ILLEGAL_VALUE"; +} + template class FileLogger; template class FileLogger; template class FileLogger; diff --git a/shared/source/utilities/logger.h b/shared/source/utilities/logger.h index 7f9fbdb7d5..fbae8f4884 100644 --- a/shared/source/utilities/logger.h +++ b/shared/source/utilities/logger.h @@ -22,6 +22,7 @@ struct MultiDispatchInfo; class GraphicsAllocation; const char *getAllocationTypeString(GraphicsAllocation const *graphicsAllocation); +const char *getMemoryPoolString(GraphicsAllocation const *graphicsAllocation); template class FileLogger { diff --git a/shared/source/xe_hpc_core/command_stream_receiver_hw_xe_hpc_core.cpp b/shared/source/xe_hpc_core/command_stream_receiver_hw_xe_hpc_core.cpp index dad644b06b..dc5664287a 100644 --- a/shared/source/xe_hpc_core/command_stream_receiver_hw_xe_hpc_core.cpp +++ b/shared/source/xe_hpc_core/command_stream_receiver_hw_xe_hpc_core.cpp @@ -96,11 +96,11 @@ void BlitCommandsHelper::appendBlitCommandsMemCopy(const BlitProperties } if (DebugManager.flags.EnableStatelessCompressionWithUnifiedMemory.get()) { - if (!MemoryPool::isSystemMemoryPool(srcAllocation->getMemoryPool())) { + if (!MemoryPoolHelper::isSystemMemoryPool(srcAllocation->getMemoryPool())) { blitCmd.setSourceCompressible(MEM_COPY::SOURCE_COMPRESSIBLE::SOURCE_COMPRESSIBLE_COMPRESSIBLE); blitCmd.setCompressionFormat(DebugManager.flags.FormatForStatelessCompressionWithUnifiedMemory.get()); } - if (!MemoryPool::isSystemMemoryPool(dstAllocation->getMemoryPool())) { + if (!MemoryPoolHelper::isSystemMemoryPool(dstAllocation->getMemoryPool())) { blitCmd.setDestinationCompressible(MEM_COPY::DESTINATION_COMPRESSIBLE::DESTINATION_COMPRESSIBLE_COMPRESSIBLE); blitCmd.setCompressionFormat(DebugManager.flags.FormatForStatelessCompressionWithUnifiedMemory.get()); } @@ -136,7 +136,7 @@ void BlitCommandsHelper::dispatchBlitMemoryFill<1>(NEO::GraphicsAllocati blitCmd.setCompressionFormat40(compressionFormat); } if (DebugManager.flags.EnableStatelessCompressionWithUnifiedMemory.get()) { - if (!MemoryPool::isSystemMemoryPool(dstAlloc->getMemoryPool())) { + if (!MemoryPoolHelper::isSystemMemoryPool(dstAlloc->getMemoryPool())) { blitCmd.setDestinationCompressible(MEM_SET::DESTINATION_COMPRESSIBLE::DESTINATION_COMPRESSIBLE_COMPRESSIBLE); blitCmd.setCompressionFormat40(DebugManager.flags.FormatForStatelessCompressionWithUnifiedMemory.get()); } diff --git a/shared/test/common/mocks/linux/mock_drm_allocation.h b/shared/test/common/mocks/linux/mock_drm_allocation.h index 3359a48490..a3f6b9f1e1 100644 --- a/shared/test/common/mocks/linux/mock_drm_allocation.h +++ b/shared/test/common/mocks/linux/mock_drm_allocation.h @@ -41,7 +41,7 @@ class MockDrmAllocation : public DrmAllocation { using DrmAllocation::memoryPool; using DrmAllocation::registeredBoBindHandles; - MockDrmAllocation(AllocationType allocationType, MemoryPool::Type pool) : DrmAllocation(0, allocationType, nullptr, nullptr, 0, static_cast(0), pool) { + MockDrmAllocation(AllocationType allocationType, MemoryPool pool) : DrmAllocation(0, allocationType, nullptr, nullptr, 0, static_cast(0), pool) { } void registerBOBindExtHandle(Drm *drm) override { diff --git a/shared/test/common/mocks/mock_graphics_allocation.h b/shared/test/common/mocks/mock_graphics_allocation.h index 57c7abb277..373782da21 100644 --- a/shared/test/common/mocks/mock_graphics_allocation.h +++ b/shared/test/common/mocks/mock_graphics_allocation.h @@ -46,7 +46,7 @@ class MockGraphicsAllocation : public MemoryAllocation { } } - void overrideMemoryPool(MemoryPool::Type pool) { + void overrideMemoryPool(MemoryPool pool) { this->memoryPool = pool; } }; diff --git a/shared/test/unit_test/command_stream/command_stream_receiver_simulated_tests.cpp b/shared/test/unit_test/command_stream/command_stream_receiver_simulated_tests.cpp index 9e99e6b8a7..b4492bb024 100644 --- a/shared/test/unit_test/command_stream/command_stream_receiver_simulated_tests.cpp +++ b/shared/test/unit_test/command_stream/command_stream_receiver_simulated_tests.cpp @@ -530,7 +530,7 @@ HWTEST_F(CommandStreamSimulatedTests, givenSpecificMemoryPoolAllocationWhenWrite int dummy = 1; - MemoryPool::Type poolsWith4kPages[] = { + MemoryPool poolsWith4kPages[] = { MemoryPool::System4KBPages, MemoryPool::System4KBPagesWith32BitGpuAddressing, MemoryPool::SystemCpuInaccessible}; @@ -563,7 +563,7 @@ HWTEST_F(CommandStreamSimulatedTests, givenSpecificMemoryPoolAllocationWhenWrite } } - MemoryPool::Type poolsWith64kPages[] = { + MemoryPool poolsWith64kPages[] = { MemoryPool::System64KBPages, MemoryPool::System64KBPagesWith32BitGpuAddressing, MemoryPool::LocalMemory}; diff --git a/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp b/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp index 1f41e94930..fc85adfaec 100644 --- a/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp +++ b/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp @@ -1111,7 +1111,7 @@ TEST(CommandStreamReceiverSimpleTest, givenCommandStreamReceiverWhenItIsDestroye bool destructorCalled = false; int gpuTag = 0; - auto mockGraphicsAllocation = new MockGraphicsAllocationWithDestructorTracing(0, AllocationType::UNKNOWN, &gpuTag, 0llu, 0llu, 1u, MemoryPool::MemoryNull); + auto mockGraphicsAllocation = new MockGraphicsAllocationWithDestructorTracing(0, AllocationType::UNKNOWN, &gpuTag, 0llu, 0llu, 1u, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount); mockGraphicsAllocation->destructorCalled = &destructorCalled; MockExecutionEnvironment executionEnvironment(defaultHwInfo.get()); auto csr = std::make_unique(executionEnvironment, 0, 1); diff --git a/shared/test/unit_test/memory_manager/graphics_allocation_tests.cpp b/shared/test/unit_test/memory_manager/graphics_allocation_tests.cpp index 944c3982b4..1cb2a369d9 100644 --- a/shared/test/unit_test/memory_manager/graphics_allocation_tests.cpp +++ b/shared/test/unit_test/memory_manager/graphics_allocation_tests.cpp @@ -229,10 +229,10 @@ TEST(GraphicsAllocationTest, givenDefaultGraphicsAllocationWhenGettingNumHandles TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenQueryingUsedPageSizeThenCorrectSizeForMemoryPoolUsedIsReturned) { - MemoryPool::Type page4kPools[] = {MemoryPool::MemoryNull, - MemoryPool::System4KBPages, - MemoryPool::System4KBPagesWith32BitGpuAddressing, - MemoryPool::SystemCpuInaccessible}; + MemoryPool page4kPools[] = {MemoryPool::MemoryNull, + MemoryPool::System4KBPages, + MemoryPool::System4KBPagesWith32BitGpuAddressing, + MemoryPool::SystemCpuInaccessible}; for (auto pool : page4kPools) { MockGraphicsAllocation graphicsAllocation(0, AllocationType::UNKNOWN, nullptr, 0u, 0u, static_cast(1), pool, MemoryManager::maxOsContextCount); @@ -240,9 +240,9 @@ TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenQueryingUsedPageSizeThen EXPECT_EQ(MemoryConstants::pageSize, graphicsAllocation.getUsedPageSize()); } - MemoryPool::Type page64kPools[] = {MemoryPool::System64KBPages, - MemoryPool::System64KBPagesWith32BitGpuAddressing, - MemoryPool::LocalMemory}; + MemoryPool page64kPools[] = {MemoryPool::System64KBPages, + MemoryPool::System64KBPagesWith32BitGpuAddressing, + MemoryPool::LocalMemory}; for (auto pool : page64kPools) { MockGraphicsAllocation graphicsAllocation(0, AllocationType::UNKNOWN, nullptr, 0u, 0u, 0, pool, MemoryManager::maxOsContextCount); @@ -475,4 +475,4 @@ HWTEST_F(GraphicsAllocationTests, givenGraphicsAllocationAllocTaskCountLowerThan graphicsAllocation.hostPtrTaskCountAssignment = 1; graphicsAllocation.prepareHostPtrForResidency(&csr); EXPECT_EQ(graphicsAllocation.hostPtrTaskCountAssignment, 0u); -} \ No newline at end of file +} diff --git a/shared/test/unit_test/memory_manager/memory_pool_tests.cpp b/shared/test/unit_test/memory_manager/memory_pool_tests.cpp index 8523b1b28e..515c06e854 100644 --- a/shared/test/unit_test/memory_manager/memory_pool_tests.cpp +++ b/shared/test/unit_test/memory_manager/memory_pool_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2021 Intel Corporation + * Copyright (C) 2018-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -10,14 +10,14 @@ #include "gtest/gtest.h" TEST(MemoryPool, givenSystemMemoryPoolTypesWhenIsSystemMemoryPoolIsCalledThenTrueIsReturned) { - EXPECT_TRUE(MemoryPool::isSystemMemoryPool(MemoryPool::System4KBPages)); - EXPECT_TRUE(MemoryPool::isSystemMemoryPool(MemoryPool::System4KBPagesWith32BitGpuAddressing)); - EXPECT_TRUE(MemoryPool::isSystemMemoryPool(MemoryPool::System64KBPages)); - EXPECT_TRUE(MemoryPool::isSystemMemoryPool(MemoryPool::System64KBPagesWith32BitGpuAddressing)); + EXPECT_TRUE(NEO::MemoryPoolHelper::isSystemMemoryPool(NEO::MemoryPool::System4KBPages)); + EXPECT_TRUE(NEO::MemoryPoolHelper::isSystemMemoryPool(NEO::MemoryPool::System4KBPagesWith32BitGpuAddressing)); + EXPECT_TRUE(NEO::MemoryPoolHelper::isSystemMemoryPool(NEO::MemoryPool::System64KBPages)); + EXPECT_TRUE(NEO::MemoryPoolHelper::isSystemMemoryPool(NEO::MemoryPool::System64KBPagesWith32BitGpuAddressing)); } TEST(MemoryPool, givenNonSystemMemoryPoolTypesWhenIsSystemMemoryPoolIsCalledThenFalseIsReturned) { - EXPECT_FALSE(MemoryPool::isSystemMemoryPool(MemoryPool::MemoryNull)); - EXPECT_FALSE(MemoryPool::isSystemMemoryPool(MemoryPool::SystemCpuInaccessible)); - EXPECT_FALSE(MemoryPool::isSystemMemoryPool(MemoryPool::LocalMemory)); + EXPECT_FALSE(NEO::MemoryPoolHelper::isSystemMemoryPool(NEO::MemoryPool::MemoryNull)); + EXPECT_FALSE(NEO::MemoryPoolHelper::isSystemMemoryPool(NEO::MemoryPool::SystemCpuInaccessible)); + EXPECT_FALSE(NEO::MemoryPoolHelper::isSystemMemoryPool(NEO::MemoryPool::LocalMemory)); } diff --git a/shared/test/unit_test/os_interface/linux/drm_residency_handler_prelim_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_residency_handler_prelim_tests.cpp index 1a5f26feb2..bab5d7e6bf 100644 --- a/shared/test/unit_test/os_interface/linux/drm_residency_handler_prelim_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_residency_handler_prelim_tests.cpp @@ -384,7 +384,7 @@ TEST_F(DrmMemoryOperationsHandlerBindTest, givenEvictImplFailsThenEvictWithinOsC TEST_F(DrmMemoryOperationsHandlerBindTest, givenMakeBOsResidentFailsThenMakeResidentWithinOsContextReturnsError) { struct MockDrmAllocationBOsResident : public DrmAllocation { - MockDrmAllocationBOsResident(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObjects &bos, void *ptrIn, uint64_t gpuAddress, size_t sizeIn, MemoryPool::Type pool) + MockDrmAllocationBOsResident(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObjects &bos, void *ptrIn, uint64_t gpuAddress, size_t sizeIn, MemoryPool pool) : DrmAllocation(rootDeviceIndex, allocationType, bos, ptrIn, gpuAddress, sizeIn, pool) { }