From a95198521ed577bf403adaeda3d15d5836262aef Mon Sep 17 00:00:00 2001 From: Bartosz Dunajski Date: Fri, 4 Feb 2022 13:50:19 +0000 Subject: [PATCH] Initial implementation of CacheSettingsHelper Signed-off-by: Bartosz Dunajski --- .../unit_tests/sources/driver/test_driver.cpp | 2 +- .../unit_tests/sources/image/test_image.cpp | 2 +- .../unit_test/built_ins/built_in_tests.cpp | 4 +- .../command_queue/blit_enqueue_tests.cpp | 2 +- .../read_write_buffer_cpu_copy.cpp | 2 +- .../context/driver_diagnostics_tests.cpp | 4 +- .../unit_test/gen12lp/image_tests_gen12lp.inl | 2 +- .../unit_test/gmm_helper/gmm_helper_tests.cpp | 123 +++++++++++------- .../unit_test/helpers/hw_helper_tests.cpp | 12 +- .../kernel/kernel_arg_buffer_tests.cpp | 4 +- .../mem_obj/buffer_set_arg_tests.cpp | 2 +- .../test/unit_test/mem_obj/buffer_tests.cpp | 4 +- .../mem_obj/buffer_tests_xehp_and_later.cpp | 2 +- .../unit_test/mem_obj/image_set_arg_tests.cpp | 10 +- opencl/test/unit_test/mem_obj/image_tests.cpp | 2 +- .../mem_obj/image_tests_xehp_and_later.cpp | 6 +- .../test/unit_test/mem_obj/mem_obj_tests.cpp | 4 +- .../memory_manager/memory_manager_tests.cpp | 8 +- .../migraton_controller_tests.cpp | 4 +- opencl/test/unit_test/mocks/mock_buffer.h | 2 +- .../linux/drm_memory_manager_tests.cpp | 2 +- .../os_interface/windows/wddm20_tests.cpp | 10 +- .../windows/wddm_kmdaf_listener_tests.cpp | 8 +- .../windows/wddm_memory_manager_tests.cpp | 48 +++---- .../gl/windows/gl_reused_buffers_tests.cpp | 2 +- .../sharings/gl/windows/gl_sharing_tests.cpp | 2 +- .../test_cmds_programming_xe_hpg_core.cpp | 8 +- shared/source/gmm_helper/CMakeLists.txt | 4 +- .../gmm_helper/cache_settings_helper.cpp | 28 ++++ .../source/gmm_helper/cache_settings_helper.h | 17 +++ shared/source/gmm_helper/gmm.cpp | 13 +- shared/source/gmm_helper/gmm.h | 3 +- .../os_agnostic_memory_manager.cpp | 10 +- .../os_interface/linux/drm_memory_manager.cpp | 9 +- .../windows/wddm_memory_manager.cpp | 30 +++-- ...allocator_multi_device_fixture_windows.cpp | 2 +- shared/test/common/mocks/mock_gmm.h | 2 +- .../aub_command_stream_receiver_2_tests.cpp | 6 +- ...ommand_stream_receiver_simulated_tests.cpp | 4 +- .../windows/wddm_shared_allocations_test.cpp | 2 +- .../os_interface/windows/wddm_tests.cpp | 2 +- 41 files changed, 250 insertions(+), 163 deletions(-) create mode 100644 shared/source/gmm_helper/cache_settings_helper.cpp create mode 100644 shared/source/gmm_helper/cache_settings_helper.h diff --git a/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp b/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp index efe7c6eead..4b7f558c3a 100644 --- a/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp +++ b/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp @@ -160,7 +160,7 @@ class MemoryManagerNTHandleMock : public NEO::OsAgnosticMemoryManager { rootDeviceIndex, false, false, false); graphicsAllocation->setSharedHandle(static_cast(reinterpret_cast(handle))); graphicsAllocation->set32BitAllocation(false); - graphicsAllocation->setDefaultGmm(new Gmm(executionEnvironment.rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, 1, 0, false, false, {}, true)); + graphicsAllocation->setDefaultGmm(new Gmm(executionEnvironment.rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); return graphicsAllocation; } }; diff --git a/level_zero/core/test/unit_tests/sources/image/test_image.cpp b/level_zero/core/test/unit_tests/sources/image/test_image.cpp index 08a1b9239f..720fdf4234 100644 --- a/level_zero/core/test/unit_tests/sources/image/test_image.cpp +++ b/level_zero/core/test/unit_tests/sources/image/test_image.cpp @@ -363,7 +363,7 @@ class MemoryManagerNTHandleMock : public NEO::OsAgnosticMemoryManager { rootDeviceIndex, false, false, false); graphicsAllocation->setSharedHandle(static_cast(reinterpret_cast(handle))); graphicsAllocation->set32BitAllocation(false); - graphicsAllocation->setDefaultGmm(new Gmm(executionEnvironment.rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, 1, 0, false, false, {}, true)); + graphicsAllocation->setDefaultGmm(new Gmm(executionEnvironment.rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); return graphicsAllocation; } }; diff --git a/opencl/test/unit_test/built_ins/built_in_tests.cpp b/opencl/test/unit_test/built_ins/built_in_tests.cpp index f2657255f6..076846d313 100644 --- a/opencl/test/unit_test/built_ins/built_in_tests.cpp +++ b/opencl/test/unit_test/built_ins/built_in_tests.cpp @@ -633,7 +633,7 @@ HWTEST2_P(AuxBuiltInTests, givenAuxToNonAuxTranslationWhenSettingSurfaceStateThe std::unique_ptr buffer = nullptr; std::unique_ptr gfxAllocation = nullptr; - auto gmm = std::unique_ptr(new Gmm(pDevice->getGmmClientContext(), nullptr, 1, 0, false, false, {}, true)); + auto gmm = std::unique_ptr(new Gmm(pDevice->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); gmm->isCompressionEnabled = true; if (kernelObjType == MockKernelObjForAuxTranslation::Type::MEM_OBJ) { @@ -688,7 +688,7 @@ HWTEST2_P(AuxBuiltInTests, givenNonAuxToAuxTranslationWhenSettingSurfaceStateThe builtinOpParams.auxTranslationDirection = AuxTranslationDirection::NonAuxToAux; MockKernelObjForAuxTranslation mockKernelObjForAuxTranslation(kernelObjType); - auto gmm = std::make_unique(pDevice->getGmmClientContext(), nullptr, 1, 0, false, false, StorageInfo{}, true); + auto gmm = std::make_unique(pDevice->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, StorageInfo{}, true); gmm->isCompressionEnabled = true; if (kernelObjType == MockKernelObjForAuxTranslation::Type::MEM_OBJ) { mockKernelObjForAuxTranslation.mockBuffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex())->setDefaultGmm(gmm.release()); diff --git a/opencl/test/unit_test/command_queue/blit_enqueue_tests.cpp b/opencl/test/unit_test/command_queue/blit_enqueue_tests.cpp index 6a787294bb..fff4d2b604 100644 --- a/opencl/test/unit_test/command_queue/blit_enqueue_tests.cpp +++ b/opencl/test/unit_test/command_queue/blit_enqueue_tests.cpp @@ -165,7 +165,7 @@ struct BlitEnqueueTests : public ::testing::Test { if (compressed && !graphicsAllocation->getDefaultGmm()) { auto clientContext = device->getRootDeviceEnvironment().getGmmClientContext(); - graphicsAllocation->setDefaultGmm(new Gmm(clientContext, nullptr, 0, 0, false, false, {}, true)); + graphicsAllocation->setDefaultGmm(new Gmm(clientContext, nullptr, 0, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); } if (graphicsAllocation->getDefaultGmm()) { diff --git a/opencl/test/unit_test/command_queue/read_write_buffer_cpu_copy.cpp b/opencl/test/unit_test/command_queue/read_write_buffer_cpu_copy.cpp index 75af24e974..a7cdf50ab9 100644 --- a/opencl/test/unit_test/command_queue/read_write_buffer_cpu_copy.cpp +++ b/opencl/test/unit_test/command_queue/read_write_buffer_cpu_copy.cpp @@ -24,7 +24,7 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, givenCompressedGmmWhenAskingForCpuOperation cl_int retVal; auto rootDeviceIndex = context->getDevice(0)->getRootDeviceIndex(); std::unique_ptr buffer(Buffer::create(context, CL_MEM_READ_WRITE, 1, nullptr, retVal)); - auto gmm = new Gmm(pDevice->getGmmClientContext(), nullptr, 1, 0, false, false, {}, true); + auto gmm = new Gmm(pDevice->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); gmm->isCompressionEnabled = false; auto allocation = buffer->getGraphicsAllocation(rootDeviceIndex); allocation->setDefaultGmm(gmm); diff --git a/opencl/test/unit_test/context/driver_diagnostics_tests.cpp b/opencl/test/unit_test/context/driver_diagnostics_tests.cpp index 4ea9c1d141..99b4a7666a 100644 --- a/opencl/test/unit_test/context/driver_diagnostics_tests.cpp +++ b/opencl/test/unit_test/context/driver_diagnostics_tests.cpp @@ -745,7 +745,7 @@ HWTEST_F(PerformanceHintTest, givenCompressedImageWhenItsCreatedThenProperPerfor auto mockBuffer = std::unique_ptr(new MockBuffer()); StorageInfo info; size_t t = 4; - auto gmm = new Gmm(device->getGmmClientContext(), static_cast(nullptr), t, 0, false, true, info, true); + auto gmm = new Gmm(device->getGmmClientContext(), static_cast(nullptr), t, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, true, info, true); gmm->isCompressionEnabled = true; auto graphicsAllocation = mockBuffer->getGraphicsAllocation(device->getRootDeviceIndex()); @@ -815,7 +815,7 @@ TEST_F(PerformanceHintTest, givenUncompressedImageWhenItsCreatedThenProperPerfor auto mockBuffer = std::unique_ptr(new MockBuffer()); StorageInfo info; size_t t = 4; - auto gmm = new Gmm(device->getGmmClientContext(), (const void *)nullptr, t, 0, false, true, info, true); + auto gmm = new Gmm(device->getGmmClientContext(), (const void *)nullptr, t, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, true, info, true); gmm->isCompressionEnabled = false; mockBuffer->getGraphicsAllocation(device->getRootDeviceIndex())->setDefaultGmm(gmm); diff --git a/opencl/test/unit_test/gen12lp/image_tests_gen12lp.inl b/opencl/test/unit_test/gen12lp/image_tests_gen12lp.inl index b2abf50c2e..6bff47ef83 100644 --- a/opencl/test/unit_test/gen12lp/image_tests_gen12lp.inl +++ b/opencl/test/unit_test/gen12lp/image_tests_gen12lp.inl @@ -94,7 +94,7 @@ GEN12LPTEST_F(ImageClearColorFixture, givenMcsAllocationWhenSetArgIsCalledWithUn auto surfaceState = FamilyType::cmdInitRenderSurfaceState; auto imageHw = static_cast *>(image.get()); - mcsAlloc->setDefaultGmm(new Gmm(context->getDevice(0)->getGmmClientContext(), nullptr, 1, 0, false, false, {}, true)); + mcsAlloc->setDefaultGmm(new Gmm(context->getDevice(0)->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); surfaceState.setSurfaceBaseAddress(0xABCDEF1000); imageHw->setMcsSurfaceInfo(msi); imageHw->setMcsAllocation(mcsAlloc); diff --git a/opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp b/opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp index cfdfde7a0e..7f679245ae 100644 --- a/opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp +++ b/opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp @@ -7,6 +7,7 @@ #include "shared/source/execution_environment/execution_environment.h" #include "shared/source/execution_environment/root_device_environment.h" +#include "shared/source/gmm_helper/cache_settings_helper.h" #include "shared/source/gmm_helper/client_context/gmm_client_context.h" #include "shared/source/gmm_helper/gmm.h" #include "shared/source/gmm_helper/gmm_helper.h" @@ -75,7 +76,7 @@ TEST(GmmGlTests, givenGmmWhenAskedforCubeFaceIndexThenProperValueIsReturned) { TEST_F(GmmTests, WhenGmmIsCreatedThenAllResourceAreCreated) { std::unique_ptr mm(new MemoryManagerCreate(false, false, *executionEnvironment)); void *pSysMem = mm->allocateSystemMemory(4096, 4096); - std::unique_ptr gmm(new Gmm(getGmmClientContext(), pSysMem, 4096, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(getGmmClientContext(), pSysMem, 4096, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); ASSERT_TRUE(gmm->gmmResourceInfo.get() != nullptr); @@ -90,7 +91,7 @@ TEST_F(GmmTests, GivenUncacheableWhenGmmIsCreatedThenAllResourceAreCreated) { std::unique_ptr mm(new MemoryManagerCreate(false, false, *executionEnvironment)); void *pSysMem = mm->allocateSystemMemory(4096, 4096); - std::unique_ptr gmm(new Gmm(getGmmClientContext(), pSysMem, 4096, 0, true, false, {}, true)); + std::unique_ptr gmm(new Gmm(getGmmClientContext(), pSysMem, 4096, 0, GMM_RESOURCE_USAGE_OCL_BUFFER_CSR_UC, false, {}, true)); ASSERT_TRUE(gmm->gmmResourceInfo.get() != nullptr); @@ -107,7 +108,7 @@ TEST_F(GmmTests, givenHostPointerWithHighestBitSetWhenGmmIsCreatedThenItHasTheSa auto address = reinterpret_cast(addressWithHighestBitSet); auto expectedAddress = castToUint64(address); - std::unique_ptr gmm(new Gmm(getGmmClientContext(), address, 4096, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(getGmmClientContext(), address, 4096, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); EXPECT_EQ(gmm->resourceParams.pExistingSysMem, expectedAddress); } @@ -117,7 +118,7 @@ TEST_F(GmmTests, GivenBufferSizeLargerThenMaxPitchWhenAskedForGmmCreationThenGmm MemoryManager *mm = new MemoryManagerCreate(false, false, *executionEnvironment); void *pSysMem = mm->allocateSystemMemory(4096, 4096); - auto gmmRes = new Gmm(getGmmClientContext(), pSysMem, maxSize, 0, false, false, {}, true); + auto gmmRes = new Gmm(getGmmClientContext(), pSysMem, maxSize, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); ASSERT_TRUE(gmmRes->gmmResourceInfo.get() != nullptr); @@ -131,7 +132,7 @@ TEST_F(GmmTests, GivenBufferSizeLargerThenMaxPitchWhenAskedForGmmCreationThenGmm TEST_F(GmmTests, givenGmmCreatedFromExistingGmmThenHelperDoesNotReleaseParentGmm) { auto size = 4096u; void *incomingPtr = (void *)0x1000; - auto gmmRes = new Gmm(getGmmClientContext(), incomingPtr, size, 0, false, false, {}, true); + auto gmmRes = new Gmm(getGmmClientContext(), incomingPtr, size, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); auto gmmRes2 = new Gmm(getGmmClientContext(), gmmRes->gmmResourceInfo->peekGmmResourceInfo()); // copy is being made @@ -209,27 +210,27 @@ TEST_F(GmmTests, WhenQueryingImgParamsThenCorrectValuesAreReturned) { TEST_F(GmmTests, givenWidthWhenCreatingResourceThenSetWidth64Field) { const void *dummyPtr = reinterpret_cast(0x123); size_t allocationSize = std::numeric_limits::max(); - Gmm gmm(getGmmClientContext(), dummyPtr, allocationSize, 0, false, false, {}, true); + Gmm gmm(getGmmClientContext(), dummyPtr, allocationSize, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); EXPECT_EQ(static_cast(allocationSize), gmm.resourceParams.BaseWidth64); } TEST_F(GmmTests, givenNullptrWhenGmmConstructorIsCalledThenNoGfxMemoryIsProperlySet) { void *pSysMem = nullptr; - std::unique_ptr gmm(new Gmm(getGmmClientContext(), pSysMem, 4096, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(getGmmClientContext(), pSysMem, 4096, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); EXPECT_EQ(gmm->resourceParams.NoGfxMemory, 1u); } HWTEST_F(GmmTests, givenGmmWithForceLocalMemThenNonLocalIsSetToFalse) { void *pSysMem = nullptr; - std::unique_ptr gmm(new Gmm(getGmmClientContext(), pSysMem, 4096, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(getGmmClientContext(), pSysMem, 4096, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); EXPECT_EQ(gmm->resourceParams.Flags.Info.NonLocalOnly, 0u); } TEST_F(GmmTests, givenPtrWhenGmmConstructorIsCalledThenNoGfxMemoryIsProperlySet) { void *pSysMem = reinterpret_cast(0x1111); - std::unique_ptr gmm(new Gmm(getGmmClientContext(), pSysMem, 4096, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(getGmmClientContext(), pSysMem, 4096, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); EXPECT_EQ(gmm->resourceParams.NoGfxMemory, 0u); } @@ -490,7 +491,7 @@ struct GmmMediaCompressedTests : public GmmTests { void SetUp() override { GmmTests::SetUp(); StorageInfo info; - gmm = std::make_unique(getGmmClientContext(), nullptr, 4, 0, false, true, info, true); + gmm = std::make_unique(getGmmClientContext(), nullptr, 4, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, true, info, true); flags = gmm->gmmResourceInfo->getResourceFlags(); flags->Gpu.CCS = true; flags->Gpu.UnifiedAuxSurface = true; @@ -750,7 +751,7 @@ TEST_F(GmmTests, GivenPlaneWhenCopyingResourceBltThenResourceIsCopiedCorrectly) } TEST_F(GmmTests, givenAllValidFlagsWhenAskedForUnifiedAuxTranslationCapabilityThenReturnTrue) { - auto gmm = std::unique_ptr(new Gmm(getGmmClientContext(), nullptr, 1, 0, false, false, {}, true)); + auto gmm = std::unique_ptr(new Gmm(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); auto mockResource = reinterpret_cast(gmm->gmmResourceInfo.get()); mockResource->setUnifiedAuxTranslationCapable(); @@ -763,12 +764,12 @@ TEST_F(GmmTests, givenAllValidFlagsWhenAskedForUnifiedAuxTranslationCapabilityTh TEST_F(GmmTests, givenAlignmentValueWhenConstructingGmmThenSetAlignmentInResourceCreateObject) { const uint32_t alignment = 8096; - Gmm gmm{getGmmClientContext(), nullptr, 1, alignment, false, false, {}, true}; + Gmm gmm{getGmmClientContext(), nullptr, 1, alignment, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true}; EXPECT_EQ(alignment, gmm.resourceParams.BaseAlignment); } TEST_F(GmmTests, givenInvalidFlagsSetWhenAskedForUnifiedAuxTranslationCapabilityThenReturnFalse) { - auto gmm = std::unique_ptr(new Gmm(getGmmClientContext(), nullptr, 1, 0, false, false, {}, true)); + auto gmm = std::unique_ptr(new Gmm(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); auto mockResource = reinterpret_cast(gmm->gmmResourceInfo.get()); mockResource->mockResourceCreateParams.Flags.Gpu.CCS = 0; @@ -787,14 +788,14 @@ TEST_F(GmmTests, givenInvalidFlagsSetWhenAskedForUnifiedAuxTranslationCapability TEST_F(GmmTests, whenLargePagesAreImplicitlyAllowedThenEnableOptimizationPadding) { size_t allocationSize = 128; - Gmm gmm(getGmmClientContext(), nullptr, allocationSize, 0, false, false, {}, true); + Gmm gmm(getGmmClientContext(), nullptr, allocationSize, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); EXPECT_FALSE(gmm.resourceParams.Flags.Info.NoOptimizationPadding); } TEST_F(GmmTests, whenLargePagesAreExplicitlyAllowedAndUserPtrIsNullThenAllowOptimizationPadding) { size_t allocationSize = 128; bool allowLargePages = true; - Gmm gmm(getGmmClientContext(), nullptr, allocationSize, 0, false, false, {}, allowLargePages); + Gmm gmm(getGmmClientContext(), nullptr, allocationSize, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, allowLargePages); EXPECT_FALSE(gmm.resourceParams.Flags.Info.NoOptimizationPadding); } @@ -802,14 +803,14 @@ TEST_F(GmmTests, whenLargePagesAreExplicitlyDisallowedButUserPtrIsNotNullThenAll const void *dummyPtr = reinterpret_cast(0x123); size_t allocationSize = 128; bool allowLargePages = false; - Gmm gmm(getGmmClientContext(), dummyPtr, allocationSize, 0, false, false, {}, allowLargePages); + Gmm gmm(getGmmClientContext(), dummyPtr, allocationSize, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, allowLargePages); EXPECT_FALSE(gmm.resourceParams.Flags.Info.NoOptimizationPadding); } TEST_F(GmmTests, whenLargePagesAreExplicitlyDisallowedAndUserPtrIsNullThenDisableOptimizationPadding) { size_t allocationSize = 128; bool allowLargePages = false; - Gmm gmm(getGmmClientContext(), nullptr, allocationSize, 0, false, false, {}, allowLargePages); + Gmm gmm(getGmmClientContext(), nullptr, allocationSize, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, allowLargePages); EXPECT_TRUE(gmm.resourceParams.Flags.Info.NoOptimizationPadding); } @@ -817,14 +818,14 @@ TEST_F(GmmTests, givenSizeIsMisallignedTo64kbWhenForceDisablingLargePagesThenSiz const void *dummyPtr = reinterpret_cast(0x123); size_t allocationSize = 256U; bool allowLargePages = false; - Gmm gmm(getGmmClientContext(), dummyPtr, allocationSize, 0, false, false, {}, allowLargePages); + Gmm gmm(getGmmClientContext(), dummyPtr, allocationSize, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, allowLargePages); EXPECT_EQ(allocationSize, gmm.resourceParams.BaseWidth64); } TEST_F(GmmTests, givenSizeIsAllignedTo64kbWhenForceDisablingLargePagesThenSizeIsAlteredToBreak64kbAlignment) { size_t allocationSize = MemoryConstants::pageSize64k; bool allowLargePages = false; - Gmm gmm(getGmmClientContext(), nullptr, allocationSize, 0, false, false, {}, allowLargePages); + Gmm gmm(getGmmClientContext(), nullptr, allocationSize, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, allowLargePages); EXPECT_EQ(allocationSize + MemoryConstants::pageSize, gmm.resourceParams.BaseWidth64); } @@ -833,6 +834,36 @@ TEST(GmmTest, givenHwInfoWhenDeviceIsCreatedThenSetThisHwInfoToGmmHelper) { EXPECT_EQ(&device->getHardwareInfo(), device->getGmmHelper()->getHardwareInfo()); } +TEST(GmmTest, givenAllocationTypeWhenGettingUsageTypeThenReturnCorrectValue) { + for (uint32_t i = 0; i < static_cast(AllocationType::COUNT); i++) { + auto allocationType = static_cast(i); + + for (auto forceUncached : {true, false}) { + auto usage = CacheSettingsHelper::getGmmUsageType(allocationType, forceUncached); + + if (allocationType == AllocationType::IMAGE) { + if (forceUncached) { + EXPECT_EQ(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED, usage); + } else { + EXPECT_EQ(GMM_RESOURCE_USAGE_OCL_IMAGE, usage); + } + } else if (allocationType == AllocationType::PREEMPTION) { + if (forceUncached) { + EXPECT_EQ(GMM_RESOURCE_USAGE_OCL_BUFFER_CSR_UC, usage); + } else { + EXPECT_EQ(GMM_RESOURCE_USAGE_OCL_BUFFER, usage); + } + } else { + if (forceUncached) { + EXPECT_EQ(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED, usage); + } else { + EXPECT_EQ(GMM_RESOURCE_USAGE_OCL_BUFFER, usage); + } + } + } + } +} + TEST_F(GmmTests, whenResourceIsCreatedThenHandleItsOwnership) { struct MyMockResourecInfo : public GmmResourceInfo { using GmmResourceInfo::resourceInfo; @@ -864,12 +895,12 @@ TEST_F(GmmTests, whenResourceIsCreatedThenHandleItsOwnership) { using GmmEnvironmentTest = MockExecutionEnvironmentGmmFixtureTest; TEST_F(GmmEnvironmentTest, givenGmmWithNotSetMCSInResourceInfoGpuFlagsWhenCallHasMultisampleControlSurfaceThenReturnFalse) { - auto gmm = std::unique_ptr(new Gmm(getGmmClientContext(), nullptr, 1, 0, false, false, {}, true)); + auto gmm = std::unique_ptr(new Gmm(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); EXPECT_FALSE(gmm->hasMultisampleControlSurface()); } TEST_F(GmmEnvironmentTest, givenGmmWithSetMCSInResourceInfoGpuFlagsWhenCallhasMultisampleControlSurfaceThenReturnTrue) { - auto gmm = std::unique_ptr(new Gmm(getGmmClientContext(), nullptr, 1, 0, false, false, {}, true)); + auto gmm = std::unique_ptr(new Gmm(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); auto mockResource = reinterpret_cast(gmm->gmmResourceInfo.get()); mockResource->setMultisampleControlSurface(); EXPECT_TRUE(gmm->hasMultisampleControlSurface()); @@ -985,7 +1016,7 @@ struct GmmCompressionTests : public MockExecutionEnvironmentGmmFixtureTest { }; TEST_F(GmmCompressionTests, givenEnabledAndNotPreferredE2ECWhenApplyingForBuffersThenDontSetValidFlags) { - std::unique_ptr gmm(new Gmm(getGmmClientContext(), nullptr, 1, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); gmm->resourceParams = {}; localPlatformDevice->capabilityTable.ftrRenderCompressedBuffers = true; @@ -998,7 +1029,7 @@ TEST_F(GmmCompressionTests, givenEnabledAndNotPreferredE2ECWhenApplyingForBuffer } TEST_F(GmmCompressionTests, givenDisabledAndPreferredE2ECWhenApplyingForBuffersThenDontSetValidFlags) { - std::unique_ptr gmm(new Gmm(getGmmClientContext(), nullptr, 1, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); gmm->resourceParams = {}; localPlatformDevice->capabilityTable.ftrRenderCompressedBuffers = false; @@ -1164,18 +1195,18 @@ TEST_F(GmmCompressionTests, givenPackedYuvFormatWhenQueryingThenDisallow) { } } HWTEST_F(GmmCompressionTests, whenConstructedWithPreferCompressionFlagThenApplyAuxFlags) { - Gmm gmm1(getGmmClientContext(), nullptr, 1, 0, false, false, {}, true); + Gmm gmm1(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); EXPECT_EQ(0u, gmm1.resourceParams.Flags.Info.RenderCompressed); - Gmm gmm2(getGmmClientContext(), nullptr, 1, 0, false, false, {}, true); + Gmm gmm2(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); EXPECT_EQ(0u, gmm2.resourceParams.Flags.Info.RenderCompressed); - Gmm gmm3(getGmmClientContext(), nullptr, 1, 0, false, true, {}, true); + Gmm gmm3(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, true, {}, true); EXPECT_EQ(1u, gmm3.resourceParams.Flags.Info.RenderCompressed); } TEST_F(GmmCompressionTests, givenMediaCompressedImageApplyAuxFlagsForImageThenSetFlagsToCompressed) { - MockGmm gmm(getGmmClientContext(), nullptr, 1, 0, false, false, {}, true); + MockGmm gmm(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); gmm.resourceParams.Flags.Info.MediaCompressed = true; gmm.resourceParams.Flags.Info.RenderCompressed = false; gmm.setupImageResourceParams(imgInfo, true); @@ -1184,7 +1215,7 @@ TEST_F(GmmCompressionTests, givenMediaCompressedImageApplyAuxFlagsForImageThenSe } TEST_F(GmmCompressionTests, givenRenderCompressedImageApplyAuxFlagsForImageThenSetFlagsToCompressed) { - MockGmm gmm(getGmmClientContext(), nullptr, 1, 0, false, false, {}, true); + MockGmm gmm(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); gmm.resourceParams.Flags.Info.MediaCompressed = false; gmm.resourceParams.Flags.Info.RenderCompressed = true; gmm.setupImageResourceParams(imgInfo, true); @@ -1193,7 +1224,7 @@ TEST_F(GmmCompressionTests, givenRenderCompressedImageApplyAuxFlagsForImageThenS } HWTEST_F(GmmCompressionTests, givenEnabledAndPreferredE2ECWhenApplyingForBuffersThenSetValidFlags) { - std::unique_ptr gmm(new Gmm(getGmmClientContext(), nullptr, 1, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); gmm->resourceParams = {}; localPlatformDevice->capabilityTable.ftrRenderCompressedBuffers = true; @@ -1207,7 +1238,7 @@ HWTEST_F(GmmCompressionTests, givenEnabledAndPreferredE2ECWhenApplyingForBuffers HWTEST_F(GmmCompressionTests, givenDisabledE2ECAndEnabledDebugFlagWhenApplyingForBuffersThenSetValidFlags) { DebugManagerStateRestore restore; - Gmm gmm(getGmmClientContext(), nullptr, 1, 0, false, false, {}, true); + Gmm gmm(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); gmm.resourceParams = {}; DebugManager.flags.RenderCompressedBuffersEnabled.set(1); @@ -1253,7 +1284,7 @@ struct MultiTileGmmTests : GmmLocalMemoryTests { }; TEST_F(GmmLocalMemoryTests, givenFtrLocalMemoryWhenUseSystemMemoryIsTrueThenNonLocalOnlyFlagIsSetAndLocalOnlyCleared) { - auto gmm = std::make_unique(getGmmClientContext(), nullptr, 1, 0, false, false, StorageInfo{}, true); + auto gmm = std::make_unique(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, StorageInfo{}, true); EXPECT_EQ(1u, gmm->resourceParams.Flags.Info.NonLocalOnly); EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.LocalOnly); } @@ -1262,7 +1293,7 @@ TEST_F(GmmLocalMemoryTests, givenFtrLocalMemoryWhenUsingLocalMemoryAndAllocation StorageInfo storageInfo{}; storageInfo.isLockable = true; storageInfo.memoryBanks.set(1); - auto gmm = std::make_unique(getGmmClientContext(), nullptr, 1, 0, false, false, storageInfo, true); + auto gmm = std::make_unique(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true); EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.NonLocalOnly); EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.LocalOnly); EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.NotLockable); @@ -1272,7 +1303,7 @@ TEST_F(GmmLocalMemoryTests, givenFtrLocalMemoryWhenUsingLocalMemoryFalseAndAlloc StorageInfo storageInfo{}; storageInfo.isLockable = false; storageInfo.memoryBanks.set(1); - auto gmm = std::make_unique(getGmmClientContext(), nullptr, 1, 0, false, false, storageInfo, true); + auto gmm = std::make_unique(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true); EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.NonLocalOnly); EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.LocalOnly); EXPECT_EQ(1u, gmm->resourceParams.Flags.Info.NotLockable); @@ -1284,7 +1315,7 @@ TEST_F(GmmLocalMemoryTests, givenLocalMemoryAndNotLockableAllocationAndStorageIn storageInfo.isLockable = false; storageInfo.memoryBanks.set(1); - auto gmm = std::make_unique(getGmmClientContext(), nullptr, 1, 0, false, false, storageInfo, true); + auto gmm = std::make_unique(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true); EXPECT_EQ(1u, gmm->resourceParams.Flags.Info.LocalOnly); EXPECT_EQ(1u, gmm->resourceParams.Flags.Info.NotLockable); @@ -1300,7 +1331,7 @@ TEST_F(GmmLocalMemoryTests, givenLocalMemoryAndStorageInfoWithLocalOnlyRequiredW for (auto csrMode = static_cast(CommandStreamReceiverType::CSR_HW); csrMode < static_cast(CommandStreamReceiverType::CSR_TYPES_NUM); csrMode++) { DebugManager.flags.SetCommandStreamReceiver.set(csrMode); - auto gmm = std::make_unique(getGmmClientContext(), nullptr, 1, 0, false, false, storageInfo, true); + auto gmm = std::make_unique(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true); EXPECT_EQ(1u, gmm->resourceParams.Flags.Info.LocalOnly); EXPECT_EQ(1u, gmm->resourceParams.Flags.Info.NotLockable); } @@ -1309,7 +1340,7 @@ TEST_F(GmmLocalMemoryTests, givenLocalMemoryAndStorageInfoWithLocalOnlyRequiredW TEST_F(GmmLocalMemoryTests, givenSystemMemoryAndStorageInfoWithLocalOnlyRequiredWhenPreparingFlagsForGmmThenLocalOnlyIsNotSet) { StorageInfo storageInfo{}; storageInfo.localOnlyRequired = true; - auto gmm = std::make_unique(getGmmClientContext(), nullptr, 1, 0, false, false, storageInfo, true); + auto gmm = std::make_unique(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true); EXPECT_EQ(1u, gmm->resourceParams.Flags.Info.NonLocalOnly); EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.LocalOnly); } @@ -1317,7 +1348,7 @@ TEST_F(GmmLocalMemoryTests, givenSystemMemoryAndStorageInfoWithLocalOnlyRequired TEST_F(GmmLocalMemoryTests, givenLocalMemoryAndStorageInfoWithoutLocalOnlyRequiredWhenPreparingFlagsForGmmThenLocalOnlyIsNotSet) { StorageInfo storageInfo{}; storageInfo.localOnlyRequired = false; - auto gmm = std::make_unique(getGmmClientContext(), nullptr, 1, 0, false, false, storageInfo, true); + auto gmm = std::make_unique(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true); EXPECT_EQ(1u, gmm->resourceParams.Flags.Info.NonLocalOnly); EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.LocalOnly); } @@ -1329,7 +1360,7 @@ TEST_F(GmmLocalMemoryTests, givenFtrLocalMemoryAndCompressionEnabledWhenUsingLoc storageInfo.isLockable = false; storageInfo.memoryBanks.set(1); - auto gmm = std::make_unique(getGmmClientContext(), nullptr, 1, 0, false, true, storageInfo, true); + auto gmm = std::make_unique(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, true, storageInfo, true); EXPECT_TRUE(gmm->isCompressionEnabled); EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.NonLocalOnly); EXPECT_EQ(1u, gmm->resourceParams.Flags.Info.LocalOnly); @@ -1343,7 +1374,7 @@ TEST_F(GmmLocalMemoryTests, givenFtrLocalMemoryWhenUseSystemMemoryIsFalseAndAllo StorageInfo storageInfo{}; storageInfo.memoryBanks.set(1); storageInfo.isLockable = false; - auto gmm = std::make_unique(getGmmClientContext(), nullptr, 1, 0, false, false, storageInfo, true); + auto gmm = std::make_unique(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true); EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.NonLocalOnly); EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.LocalOnly); EXPECT_EQ(1u, gmm->resourceParams.Flags.Info.NotLockable); @@ -1447,7 +1478,7 @@ TEST_F(MultiTileGmmTests, givenMultiTileAllocationWhenGmmIsCreatedWithEmptyMempo StorageInfo storageInfo; storageInfo.memoryBanks = 0; - Gmm gmm(getGmmClientContext(), nullptr, 1, 0, false, false, storageInfo, true); + Gmm gmm(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true); EXPECT_EQ(1u, gmm.resourceParams.MultiTileArch.Enable); EXPECT_EQ(0u, gmm.resourceParams.MultiTileArch.TileInstanced); @@ -1458,7 +1489,7 @@ TEST_F(MultiTileGmmTests, givenMultiTileAllocationWithoutCloningWhenGmmIsCreated storageInfo.memoryBanks = 1; storageInfo.cloningOfPageTables = false; - Gmm gmm(getGmmClientContext(), nullptr, 1, 0, false, false, storageInfo, true); + Gmm gmm(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true); EXPECT_EQ(1u, gmm.resourceParams.MultiTileArch.Enable); EXPECT_EQ(1u, gmm.resourceParams.MultiTileArch.GpuVaMappingSet); @@ -1470,7 +1501,7 @@ TEST_F(MultiTileGmmTests, givenMultiTileAllocationWithoutCloningWhenGmmIsCreated TEST_F(MultiTileGmmTests, givenMultiTileWhenGmmIsCreatedWithNonLocalMemoryThenMultitileArchIsPropertlyFilled) { StorageInfo storageInfo; - Gmm gmm(getGmmClientContext(), nullptr, 1, 0, false, false, storageInfo, true); + Gmm gmm(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true); EXPECT_EQ(1u, gmm.resourceParams.MultiTileArch.Enable); EXPECT_EQ(customTileMask, gmm.resourceParams.MultiTileArch.GpuVaMappingSet); @@ -1484,7 +1515,7 @@ TEST_F(MultiTileGmmTests, givenMultiTileWhenGmmIsCreatedWithSpecificMemoryBanksT storageInfo.memoryBanks = 1u; storageInfo.cloningOfPageTables = false; - Gmm gmm(getGmmClientContext(), nullptr, 1, 0, false, false, storageInfo, true); + Gmm gmm(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true); EXPECT_EQ(1u, gmm.resourceParams.MultiTileArch.Enable); EXPECT_EQ(storageInfo.memoryBanks, gmm.resourceParams.MultiTileArch.LocalMemPreferredSet); @@ -1499,7 +1530,7 @@ TEST_F(MultiTileGmmTests, givenMultiTileWhenGmmIsCreatedWithCloningEnabledThenGp storageInfo.cloningOfPageTables = true; storageInfo.pageTablesVisibility = 3u; - Gmm gmm(getGmmClientContext(), nullptr, 1, 0, false, false, storageInfo, true); + Gmm gmm(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true); EXPECT_EQ(1u, gmm.resourceParams.MultiTileArch.Enable); EXPECT_EQ(storageInfo.memoryBanks, gmm.resourceParams.MultiTileArch.LocalMemPreferredSet); @@ -1514,7 +1545,7 @@ TEST_F(MultiTileGmmTests, whenAllocationIsTileInstancedWithoutClonningPageTables storageInfo.tileInstanced = true; storageInfo.memoryBanks = 2u; - Gmm gmm(getGmmClientContext(), nullptr, 1, 0, false, false, storageInfo, true); + Gmm gmm(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true); EXPECT_EQ(1u, gmm.resourceParams.MultiTileArch.Enable); EXPECT_EQ(1u, gmm.resourceParams.MultiTileArch.TileInstanced); @@ -1525,7 +1556,7 @@ TEST_F(MultiTileGmmTests, whenAllocationIsTileInstancedWithClonningPageTablesThe storageInfo.cloningOfPageTables = true; storageInfo.tileInstanced = true; - Gmm gmm(getGmmClientContext(), nullptr, 1, 0, false, false, storageInfo, true); + Gmm gmm(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true); EXPECT_EQ(1u, gmm.resourceParams.MultiTileArch.Enable); EXPECT_EQ(0u, gmm.resourceParams.MultiTileArch.TileInstanced); diff --git a/opencl/test/unit_test/helpers/hw_helper_tests.cpp b/opencl/test/unit_test/helpers/hw_helper_tests.cpp index f0b1c6c088..21815cc046 100644 --- a/opencl/test/unit_test/helpers/hw_helper_tests.cpp +++ b/opencl/test/unit_test/helpers/hw_helper_tests.cpp @@ -480,7 +480,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenAllocationProvidedThenU size_t allocSize = size; length.Length = static_cast(allocSize - 1); GraphicsAllocation allocation(0, AllocationType::UNKNOWN, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull, 0u); - allocation.setDefaultGmm(new Gmm(pDevice->getGmmClientContext(), allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), 0, false, false, {}, true)); + allocation.setDefaultGmm(new Gmm(pDevice->getGmmClientContext(), allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER; helper.setRenderSurfaceStateForBuffer(rootDeviceEnvironment, stateBuffer, size, addr, 0, pitch, &allocation, false, type, true, false); EXPECT_EQ(length.SurfaceState.Depth + 1u, state->getDepth()); @@ -517,7 +517,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmAndAllocationCompres uint64_t gpuAddr = 0x4000u; size_t allocSize = size; GraphicsAllocation allocation(0, AllocationType::BUFFER, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull, 0u); - allocation.setDefaultGmm(new Gmm(rootDeviceEnvironment.getGmmClientContext(), allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), 0, false, false, {}, true)); + allocation.setDefaultGmm(new Gmm(rootDeviceEnvironment.getGmmClientContext(), allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); allocation.getDefaultGmm()->isCompressionEnabled = true; SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER; helper.setRenderSurfaceStateForBuffer(rootDeviceEnvironment, stateBuffer, size, addr, 0, pitch, &allocation, false, type, false, false); @@ -549,7 +549,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmCompressionDisabledA uint64_t gpuAddr = 0x4000u; size_t allocSize = size; GraphicsAllocation allocation(0, AllocationType::BUFFER, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull, 1); - allocation.setDefaultGmm(new Gmm(rootDeviceEnvironment.getGmmClientContext(), allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), 0, false, false, {}, true)); + allocation.setDefaultGmm(new Gmm(rootDeviceEnvironment.getGmmClientContext(), allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER; helper.setRenderSurfaceStateForBuffer(rootDeviceEnvironment, stateBuffer, size, addr, 0, pitch, &allocation, false, type, false, false); EXPECT_EQ(UnitTestHelper::getCoherencyTypeSupported(RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT), state->getCoherencyType()); @@ -582,7 +582,7 @@ HWTEST_F(HwHelperTest, givenOverrideMocsIndexForScratchSpaceWhenSurfaceStateIsPr uint64_t gpuAddr = 0x4000u; size_t allocSize = size; GraphicsAllocation allocation(0, AllocationType::BUFFER, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull, 1); - allocation.setDefaultGmm(new Gmm(rootDeviceEnvironment.getGmmClientContext(), allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), 0, false, false, {}, true)); + allocation.setDefaultGmm(new Gmm(rootDeviceEnvironment.getGmmClientContext(), allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER; helper.setRenderSurfaceStateForBuffer(rootDeviceEnvironment, stateBuffer, size, addr, 0, pitch, &allocation, false, type, false, false); @@ -614,7 +614,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmAndAllocationCompres uint64_t gpuAddr = 0x4000u; size_t allocSize = size; GraphicsAllocation allocation(0, AllocationType::BUFFER, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull, 1u); - allocation.setDefaultGmm(new Gmm(rootDeviceEnvironment.getGmmClientContext(), allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), 0, false, false, {}, true)); + allocation.setDefaultGmm(new Gmm(rootDeviceEnvironment.getGmmClientContext(), allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); allocation.getDefaultGmm()->isCompressionEnabled = true; SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER; helper.setRenderSurfaceStateForBuffer(rootDeviceEnvironment, stateBuffer, size, addr, 0, pitch, &allocation, false, type, true, false); @@ -1025,7 +1025,7 @@ HWTEST_F(HwHelperTest, givenNotLockableAllocationWhenGettingIsBlitCopyRequiredFo EXPECT_FALSE(GraphicsAllocation::isLockable(graphicsAllocation.getAllocationType())); graphicsAllocation.overrideMemoryPool(MemoryPool::LocalMemory); - MockGmm mockGmm(pDevice->getGmmClientContext(), nullptr, 100, 100, false, false, {}, true); + MockGmm mockGmm(pDevice->getGmmClientContext(), nullptr, 100, 100, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); mockGmm.resourceParams.Flags.Info.NotLockable = true; graphicsAllocation.setDefaultGmm(&mockGmm); diff --git a/opencl/test/unit_test/kernel/kernel_arg_buffer_tests.cpp b/opencl/test/unit_test/kernel/kernel_arg_buffer_tests.cpp index ca1ac00c22..fb2d9d9b60 100644 --- a/opencl/test/unit_test/kernel/kernel_arg_buffer_tests.cpp +++ b/opencl/test/unit_test/kernel/kernel_arg_buffer_tests.cpp @@ -657,7 +657,7 @@ TEST_F(KernelArgBufferTest, givenSetUnifiedMemoryExecInfoOnKernelWithIndirectSta {AllocationType::BUFFER_HOST_MEMORY, false}, {AllocationType::SVM_GPU, true}}}; - auto gmm = std::make_unique(pDevice->getRootDeviceEnvironment().getGmmClientContext(), nullptr, 0, 0, false, false, StorageInfo{}, true); + auto gmm = std::make_unique(pDevice->getRootDeviceEnvironment().getGmmClientContext(), nullptr, 0, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, StorageInfo{}, true); MockGraphicsAllocation gfxAllocation; gfxAllocation.setDefaultGmm(gmm.get()); @@ -698,7 +698,7 @@ TEST_F(KernelArgBufferTest, givenSVMAllocsManagerWithCompressedSVMAllocationsWhe {AllocationType::BUFFER_HOST_MEMORY, false}, {AllocationType::SVM_GPU, true}}}; - auto gmm = std::make_unique(pDevice->getRootDeviceEnvironment().getGmmClientContext(), nullptr, 0, 0, false, false, StorageInfo{}, true); + auto gmm = std::make_unique(pDevice->getRootDeviceEnvironment().getGmmClientContext(), nullptr, 0, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, StorageInfo{}, true); MockGraphicsAllocation gfxAllocation; gfxAllocation.setDefaultGmm(gmm.get()); diff --git a/opencl/test/unit_test/mem_obj/buffer_set_arg_tests.cpp b/opencl/test/unit_test/mem_obj/buffer_set_arg_tests.cpp index 3b3cbb159e..656953b833 100644 --- a/opencl/test/unit_test/mem_obj/buffer_set_arg_tests.cpp +++ b/opencl/test/unit_test/mem_obj/buffer_set_arg_tests.cpp @@ -165,7 +165,7 @@ HWTEST_F(BufferSetArgTest, givenNonPureStatefulArgWhenCompressedBufferIsSetThenS pKernelInfo->argAsPtr(0).bindful = 0; auto graphicsAllocation = buffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()); - graphicsAllocation->setDefaultGmm(new Gmm(pDevice->getGmmClientContext(), graphicsAllocation->getUnderlyingBuffer(), buffer->getSize(), 0, false, false, {}, true)); + graphicsAllocation->setDefaultGmm(new Gmm(pDevice->getGmmClientContext(), graphicsAllocation->getUnderlyingBuffer(), buffer->getSize(), 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); graphicsAllocation->getDefaultGmm()->isCompressionEnabled = true; cl_mem clMem = buffer; diff --git a/opencl/test/unit_test/mem_obj/buffer_tests.cpp b/opencl/test/unit_test/mem_obj/buffer_tests.cpp index 72209fb89e..8c6c674e1d 100644 --- a/opencl/test/unit_test/mem_obj/buffer_tests.cpp +++ b/opencl/test/unit_test/mem_obj/buffer_tests.cpp @@ -1712,7 +1712,7 @@ HWTEST_F(BufferSetSurfaceTests, givenCompressedGmmResourceWhenSurfaceStateIsProg std::unique_ptr buffer(Buffer::create(&context, CL_MEM_READ_WRITE, 1, nullptr, retVal)); auto graphicsAllocation = buffer->getGraphicsAllocation(rootDeviceIndex); - auto gmm = new Gmm(context.getDevice(0)->getGmmClientContext(), nullptr, 1, 0, false, false, {}, true); + auto gmm = new Gmm(context.getDevice(0)->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); graphicsAllocation->setDefaultGmm(gmm); gmm->isCompressionEnabled = true; @@ -1733,7 +1733,7 @@ HWTEST_F(BufferSetSurfaceTests, givenNonCompressedGmmResourceWhenSurfaceStateIsP auto retVal = CL_SUCCESS; std::unique_ptr buffer(Buffer::create(&context, CL_MEM_READ_WRITE, 1, nullptr, retVal)); - auto gmm = new Gmm(context.getDevice(0)->getGmmClientContext(), nullptr, 1, 0, false, false, {}, true); + auto gmm = new Gmm(context.getDevice(0)->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); buffer->getGraphicsAllocation(rootDeviceIndex)->setDefaultGmm(gmm); gmm->isCompressionEnabled = false; 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 7571d457bc..a317fe66ca 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 @@ -33,7 +33,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPAndLaterBufferTests, givenDebugFlagSetWhenProgr uint32_t defaultCompressionFormat = gmmContext->getSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT::GMM_FORMAT_GENERIC_8BIT); auto retVal = CL_SUCCESS; - auto gmm = new Gmm(context.getDevice(0)->getGmmHelper()->getClientContext(), nullptr, 1, 0, false, false, {}, true); + auto gmm = new Gmm(context.getDevice(0)->getGmmHelper()->getClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); gmm->isCompressionEnabled = true; auto buffer = std::unique_ptr(Buffer::create(&context, CL_MEM_READ_WRITE, 1, nullptr, retVal)); diff --git a/opencl/test/unit_test/mem_obj/image_set_arg_tests.cpp b/opencl/test/unit_test/mem_obj/image_set_arg_tests.cpp index ca69c0647f..e3ea65c074 100644 --- a/opencl/test/unit_test/mem_obj/image_set_arg_tests.cpp +++ b/opencl/test/unit_test/mem_obj/image_set_arg_tests.cpp @@ -514,7 +514,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithoutUnifiedAuxC typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE; McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), MemoryConstants::pageSize}); - mcsAlloc->setDefaultGmm(new Gmm(pDevice->getGmmClientContext(), nullptr, 1, 0, false, false, {}, true)); + mcsAlloc->setDefaultGmm(new Gmm(pDevice->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); cl_image_desc imgDesc = Image2dDefaults::imageDesc; imgDesc.num_samples = 8; @@ -613,7 +613,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationAndCompressionWhenSetArgOnMultisampl typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE; McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), MemoryConstants::pageSize}); - mcsAlloc->setDefaultGmm(new Gmm(pDevice->getGmmClientContext(), nullptr, 1, 0, false, false, {}, true)); + mcsAlloc->setDefaultGmm(new Gmm(pDevice->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); cl_image_desc imgDesc = Image2dDefaults::imageDesc; imgDesc.num_samples = 8; @@ -676,7 +676,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithUnifiedAuxCapa McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), MemoryConstants::pageSize}); - mcsAlloc->setDefaultGmm(new Gmm(pDevice->getGmmClientContext(), nullptr, 1, 0, false, false, {}, true)); + mcsAlloc->setDefaultGmm(new Gmm(pDevice->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); cl_image_desc imgDesc = Image2dDefaults::imageDesc; imgDesc.num_samples = 8; @@ -708,7 +708,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithUnifiedAuxCapa McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), MemoryConstants::pageSize}); - mcsAlloc->setDefaultGmm(new Gmm(pDevice->getGmmClientContext(), nullptr, 1, 0, false, false, {}, true)); + mcsAlloc->setDefaultGmm(new Gmm(pDevice->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); cl_image_desc imgDesc = Image2dDefaults::imageDesc; imgDesc.num_samples = 8; @@ -737,7 +737,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithUnifiedAuxCapa McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), MemoryConstants::pageSize}); - mcsAlloc->setDefaultGmm(new Gmm(pDevice->getGmmClientContext(), nullptr, 1, 0, false, false, {}, true)); + mcsAlloc->setDefaultGmm(new Gmm(pDevice->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); cl_image_desc imgDesc = Image2dDefaults::imageDesc; imgDesc.num_samples = 8; diff --git a/opencl/test/unit_test/mem_obj/image_tests.cpp b/opencl/test/unit_test/mem_obj/image_tests.cpp index 38981d7eb1..ac726dbc53 100644 --- a/opencl/test/unit_test/mem_obj/image_tests.cpp +++ b/opencl/test/unit_test/mem_obj/image_tests.cpp @@ -1699,7 +1699,7 @@ HWTEST_F(ImageTransformTest, givenSurfaceBaseAddressAndUnifiedSurfaceWhenSetUnif MockContext context; auto image = std::unique_ptr(ImageHelper::create(&context)); auto surfaceState = FamilyType::cmdInitRenderSurfaceState; - auto gmm = std::unique_ptr(new Gmm(context.getDevice(0)->getGmmClientContext(), nullptr, 1, 0, false, false, {}, true)); + auto gmm = std::unique_ptr(new Gmm(context.getDevice(0)->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); uint64_t surfBsaseAddress = 0xABCDEF1000; surfaceState.setSurfaceBaseAddress(surfBsaseAddress); auto mockResource = reinterpret_cast(gmm->gmmResourceInfo.get()); diff --git a/opencl/test/unit_test/mem_obj/image_tests_xehp_and_later.cpp b/opencl/test/unit_test/mem_obj/image_tests_xehp_and_later.cpp index 7758db6743..6510ce54e6 100644 --- a/opencl/test/unit_test/mem_obj/image_tests_xehp_and_later.cpp +++ b/opencl/test/unit_test/mem_obj/image_tests_xehp_and_later.cpp @@ -89,7 +89,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPAndLaterImageTests, givenCompressionWhenAppendi imageDesc.mem_object = clCreateBuffer(&context, CL_MEM_READ_WRITE, 128 * 256 * 4, nullptr, &retVal); - auto gmm = new Gmm(context.getDevice(0)->getGmmHelper()->getClientContext(), nullptr, 1, 0, false, false, {}, true); + auto gmm = new Gmm(context.getDevice(0)->getGmmHelper()->getClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); gmm->isCompressionEnabled = true; auto buffer = castToObject(imageDesc.mem_object); @@ -130,7 +130,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPAndLaterImageTests, givenImageFromBufferWhenSet imageDesc.mem_object = clCreateBuffer(&context, CL_MEM_READ_WRITE, 128 * 256 * 4, nullptr, &retVal); - auto gmm = new Gmm(context.getDevice(0)->getGmmHelper()->getClientContext(), nullptr, 1, 0, false, false, {}, true); + auto gmm = new Gmm(context.getDevice(0)->getGmmHelper()->getClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); gmm->isCompressionEnabled = true; auto buffer = castToObject(imageDesc.mem_object); @@ -173,7 +173,7 @@ HWTEST2_F(XeHPAndLaterImageTests, givenMcsAllocationWhenSetArgIsCalledWithUnifie auto surfaceState = FamilyType::cmdInitRenderSurfaceState; auto imageHw = static_cast *>(image.get()); - mcsAlloc->setDefaultGmm(new Gmm(context.getDevice(0)->getRootDeviceEnvironment().getGmmClientContext(), nullptr, 1, 0, false, false, {}, true)); + mcsAlloc->setDefaultGmm(new Gmm(context.getDevice(0)->getRootDeviceEnvironment().getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); surfaceState.setSurfaceBaseAddress(0xABCDEF1000); imageHw->setMcsSurfaceInfo(msi); imageHw->setMcsAllocation(mcsAlloc); diff --git a/opencl/test/unit_test/mem_obj/mem_obj_tests.cpp b/opencl/test/unit_test/mem_obj/mem_obj_tests.cpp index 71bf235d62..a0593d56ae 100644 --- a/opencl/test/unit_test/mem_obj/mem_obj_tests.cpp +++ b/opencl/test/unit_test/mem_obj/mem_obj_tests.cpp @@ -313,7 +313,7 @@ TEST(MemObj, givenCompressedGmmWhenAskingForMappingOnCpuThenDisallow) { context.memoryManager = &memoryManager; auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{context.getDevice(0)->getRootDeviceIndex(), MemoryConstants::pageSize}); - allocation->setDefaultGmm(new Gmm(context.getDevice(0)->getGmmClientContext(), nullptr, 1, 0, false, false, {}, true)); + allocation->setDefaultGmm(new Gmm(context.getDevice(0)->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); auto memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(CL_MEM_READ_WRITE, 0, 0, &context.getDevice(0)->getDevice()); MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_READ_WRITE, 0, 1, allocation->getUnderlyingBuffer(), nullptr, GraphicsAllocationHelper::toMultiGraphicsAllocation(allocation), false, false, false); @@ -347,7 +347,7 @@ TEST(MemObj, givenNonCpuAccessibleMemoryWhenAskingForMappingOnCpuThenDisallow) { context.memoryManager = &memoryManager; auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{context.getDevice(0)->getRootDeviceIndex(), MemoryConstants::pageSize}); - allocation->setDefaultGmm(new Gmm(context.getDevice(0)->getGmmClientContext(), nullptr, 1, 0, false, false, {}, true)); + allocation->setDefaultGmm(new Gmm(context.getDevice(0)->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); auto memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(CL_MEM_READ_WRITE, 0, 0, &context.getDevice(0)->getDevice()); MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_READ_WRITE, 0, 1, allocation->getUnderlyingBuffer(), nullptr, GraphicsAllocationHelper::toMultiGraphicsAllocation(allocation), false, false, false); diff --git a/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp b/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp index 16f50edde0..afca3c3136 100644 --- a/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp +++ b/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp @@ -975,7 +975,7 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerAndUnifiedAuxCapableAlloc executionEnvironment.initGmm(); OsAgnosticMemoryManager memoryManager(executionEnvironment); - auto gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, 123, 0, false, false, {}, true); + auto gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, 123, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{0, MemoryConstants::pageSize}); allocation->setDefaultGmm(gmm); @@ -1849,7 +1849,7 @@ TEST(MemoryManager, givenShareableWhenAllocatingGraphicsMemoryThenAllocateSharea } TEST_F(MemoryAllocatorTest, GivenSizeWhenGmmIsCreatedThenNonNullPointerIsReturned) { - Gmm *gmm = new Gmm(device->getGmmClientContext(), nullptr, 65536, 0, false, false, {}, true); + Gmm *gmm = new Gmm(device->getGmmClientContext(), nullptr, 65536, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); EXPECT_NE(nullptr, gmm); delete gmm; } @@ -2608,7 +2608,7 @@ TEST_F(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAlloca TEST_F(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithoutPtrAndResourceIs64KSuitableThenStandard64kHeapIsUsed) { GraphicsAllocation allocation{0, AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; auto rootDeviceEnvironment = platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0].get(); - auto gmm = std::make_unique(rootDeviceEnvironment->getGmmClientContext(), nullptr, 0, 0, false, false, StorageInfo{}, true); + auto gmm = std::make_unique(rootDeviceEnvironment->getGmmClientContext(), nullptr, 0, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, StorageInfo{}, true); auto resourceInfo = static_cast(gmm->gmmResourceInfo.get()); resourceInfo->is64KBPageSuitableValue = true; allocation.setDefaultGmm(gmm.get()); @@ -2618,7 +2618,7 @@ TEST_F(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAlloca TEST_F(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithoutPtrAndResourceIsNot64KSuitableThenStandardHeapIsUsed) { GraphicsAllocation allocation{0, AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; auto rootDeviceEnvironment = platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0].get(); - auto gmm = std::make_unique(rootDeviceEnvironment->getGmmClientContext(), nullptr, 0, 0, false, false, StorageInfo{}, true); + auto gmm = std::make_unique(rootDeviceEnvironment->getGmmClientContext(), nullptr, 0, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, StorageInfo{}, true); auto resourceInfo = static_cast(gmm->gmmResourceInfo.get()); resourceInfo->is64KBPageSuitableValue = false; allocation.setDefaultGmm(gmm.get()); diff --git a/opencl/test/unit_test/memory_manager/migraton_controller_tests.cpp b/opencl/test/unit_test/memory_manager/migraton_controller_tests.cpp index 9a50cbdaf5..bc33c26e3d 100644 --- a/opencl/test/unit_test/memory_manager/migraton_controller_tests.cpp +++ b/opencl/test/unit_test/memory_manager/migraton_controller_tests.cpp @@ -98,8 +98,8 @@ TEST_F(MigrationControllerTests, givenNotLockableBufferAllocationWithDefinedLoca auto srcAllocation = pBuffer->getMultiGraphicsAllocation().getGraphicsAllocation(0); auto dstAllocation = pBuffer->getMultiGraphicsAllocation().getGraphicsAllocation(1); - auto gmm0 = new Gmm(context.getDevice(0)->getGmmClientContext(), nullptr, 1, 0, false, false, {}, true); - auto gmm1 = new Gmm(context.getDevice(1)->getGmmClientContext(), nullptr, 1, 0, false, false, {}, true); + auto gmm0 = new Gmm(context.getDevice(0)->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); + auto gmm1 = new Gmm(context.getDevice(1)->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); srcAllocation->setDefaultGmm(gmm0); dstAllocation->setDefaultGmm(gmm1); diff --git a/opencl/test/unit_test/mocks/mock_buffer.h b/opencl/test/unit_test/mocks/mock_buffer.h index 52b67373f0..c2c68fb976 100644 --- a/opencl/test/unit_test/mocks/mock_buffer.h +++ b/opencl/test/unit_test/mocks/mock_buffer.h @@ -52,7 +52,7 @@ class MockBuffer : public MockBufferStorage, public Buffer { static void setAllocationType(GraphicsAllocation *graphicsAllocation, GmmClientContext *gmmClientContext, bool compressed) { if (compressed && !graphicsAllocation->getDefaultGmm()) { - graphicsAllocation->setDefaultGmm(new Gmm(gmmClientContext, nullptr, 0, 0, false, compressed, {}, true)); + graphicsAllocation->setDefaultGmm(new Gmm(gmmClientContext, nullptr, 0, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, compressed, {}, true)); } if (graphicsAllocation->getDefaultGmm()) { diff --git a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp index ccefcd135e..82f4c460af 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp @@ -2774,7 +2774,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndUnifiedAuxCapableAllocation mock->ioctl_expected.gemWait = 1; mock->ioctl_expected.gemClose = 1; - auto gmm = new Gmm(rootDeviceEnvironment->getGmmClientContext(), nullptr, 123, 0, false, false, {}, true); + auto gmm = new Gmm(rootDeviceEnvironment->getGmmClientContext(), nullptr, 123, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{rootDeviceIndex, MemoryConstants::pageSize}); allocation->setDefaultGmm(gmm); diff --git a/opencl/test/unit_test/os_interface/windows/wddm20_tests.cpp b/opencl/test/unit_test/os_interface/windows/wddm20_tests.cpp index e610fb216c..4dca19ad14 100644 --- a/opencl/test/unit_test/os_interface/windows/wddm20_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/wddm20_tests.cpp @@ -56,7 +56,7 @@ Gmm *getGmm(void *ptr, size_t size, GmmClientContext *clientContext) { size_t alignedSize = alignSizeWholePage(ptr, size); void *alignedPtr = alignUp(ptr, 4096); - Gmm *gmm = new Gmm(clientContext, alignedPtr, alignedSize, 0, false, false, {}, true); + Gmm *gmm = new Gmm(clientContext, alignedPtr, alignedSize, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); EXPECT_NE(gmm->gmmResourceInfo.get(), nullptr); return gmm; } @@ -87,7 +87,7 @@ TEST_F(Wddm20Tests, GivenExisitingContextWhenInitializingWddmThenCreateContextRe } TEST_F(Wddm20Tests, givenNullPageTableManagerAndCompressedResourceWhenMappingGpuVaThenDontUpdateAuxTable) { - auto gmm = std::unique_ptr(new Gmm(getGmmClientContext(), nullptr, 1, 0, false, false, {}, true)); + auto gmm = std::unique_ptr(new Gmm(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); auto mockGmmRes = reinterpret_cast(gmm->gmmResourceInfo.get()); mockGmmRes->setUnifiedAuxTranslationCapable(); @@ -497,7 +497,7 @@ TEST_F(Wddm20Tests, WhenMakingResidentAndEvictingThenReturnIsCorrect) { TEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocationFromSharedHandleIsCalledThenGraphicsAllocationWithSharedPropertiesIsCreated) { void *pSysMem = (void *)0x1000; - std::unique_ptr gmm(new Gmm(getGmmClientContext(), pSysMem, 4096u, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(getGmmClientContext(), pSysMem, 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); auto status = setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); EXPECT_EQ(0u, status); @@ -534,7 +534,7 @@ TEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocationF TEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocationFromSharedHandleIsCalledThenMapGpuVaWithCpuPtrDepensOnBitness) { void *pSysMem = (void *)0x1000; - std::unique_ptr gmm(new Gmm(getGmmClientContext(), pSysMem, 4096u, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(getGmmClientContext(), pSysMem, 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); auto status = setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); EXPECT_EQ(0u, status); @@ -830,7 +830,7 @@ TEST_F(Wddm20Tests, whenCreateAllocation64kFailsThenReturnFalse) { gdi->createAllocation2 = FailingCreateAllocation::mockCreateAllocation2; void *fakePtr = reinterpret_cast(0x123); - auto gmm = std::make_unique(rootDeviceEnvironment->getGmmClientContext(), fakePtr, 100, 0, false, false, StorageInfo{}, true); + auto gmm = std::make_unique(rootDeviceEnvironment->getGmmClientContext(), fakePtr, 100, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, StorageInfo{}, true); WddmAllocation allocation(0, AllocationType::UNKNOWN, fakePtr, 100, nullptr, MemoryPool::MemoryNull, 0u, 1u); allocation.setDefaultGmm(gmm.get()); diff --git a/opencl/test/unit_test/os_interface/windows/wddm_kmdaf_listener_tests.cpp b/opencl/test/unit_test/os_interface/windows/wddm_kmdaf_listener_tests.cpp index 9d12d953ef..3c95f4749b 100644 --- a/opencl/test/unit_test/os_interface/windows/wddm_kmdaf_listener_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/wddm_kmdaf_listener_tests.cpp @@ -84,7 +84,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenUnlockResourceIsCalledThenKmDafListen TEST_F(WddmKmDafListenerTest, givenWddmWhenMapGpuVirtualAddressIsCalledThenKmDafListenerNotifyMapGpuVAIsFedWithCorrectParams) { uint64_t gpuPtr = 0u; - auto gmm = std::make_unique(rootDeviceEnvironment->getGmmClientContext(), nullptr, 1, 0, false, false, StorageInfo{}, true); + auto gmm = std::make_unique(rootDeviceEnvironment->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, StorageInfo{}, true); wddmWithKmDafMock->mapGpuVirtualAddress(gmm.get(), ALLOCATION_HANDLE, wddmWithKmDafMock->getGfxPartition().Standard.Base, wddmWithKmDafMock->getGfxPartition().Standard.Limit, 0u, gpuPtr); @@ -137,7 +137,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenEvictIsCalledThenKmDafListenerNotifyE } TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocationIsCalledThenKmDafListenerNotifyWriteTargetIsFedWithCorrectParams) { - auto gmm = std::make_unique(rootDeviceEnvironment->getGmmClientContext(), nullptr, 1, 0, false, false, StorageInfo{}, true); + auto gmm = std::make_unique(rootDeviceEnvironment->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, StorageInfo{}, true); auto handle = 0u; auto resourceHandle = 0u; auto ptr = reinterpret_cast(0x10000); @@ -152,7 +152,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocationIsCalledThenKmDafList } TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocation64IsCalledThenKmDafListenerNotifyWriteTargetIsFedWithCorrectParams) { - auto gmm = std::make_unique(rootDeviceEnvironment->getGmmClientContext(), nullptr, 1, 0, false, false, StorageInfo{}, true); + auto gmm = std::make_unique(rootDeviceEnvironment->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, StorageInfo{}, true); auto handle = 0u; wddmWithKmDafMock->createAllocation(gmm.get(), handle); @@ -167,7 +167,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocation64IsCalledThenKmDafLi TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocationsAndMapGpuVaIsCalledThenKmDafListenerNotifyWriteTargetAndMapGpuVAIsFedWithCorrectParams) { OsHandleStorage storage; OsHandleWin osHandle; - auto gmm = std::unique_ptr(new Gmm(rootDeviceEnvironment->getGmmClientContext(), nullptr, 1, 0, false, false, {}, true)); + auto gmm = std::unique_ptr(new Gmm(rootDeviceEnvironment->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); storage.fragmentStorageData[0].osHandleStorage = &osHandle; storage.fragmentStorageData[0].fragmentSize = 100; static_cast(storage.fragmentStorageData[0].osHandleStorage)->gmm = gmm.get(); diff --git a/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp b/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp index 27f2352f8e..445e0ad2b9 100644 --- a/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp @@ -302,7 +302,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWhenCreateAllocationFromHa memoryManager.reset(new MockWddmMemoryManager(false, false, *executionEnvironment)); auto osHandle = 1u; gdi->getQueryResourceInfoArgOut().NumAllocations = 1; - std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), nullptr, 0, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), nullptr, 0, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); D3DDDI_OPENALLOCATIONINFO allocationInfo; allocationInfo.pPrivateDriverData = gmm->gmmResourceInfo->peekHandle(); @@ -322,7 +322,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenAllocationPropertiesWhenCreateAllocatio memoryManager.reset(new MockWddmMemoryManager(false, false, *executionEnvironment)); auto osHandle = 1u; gdi->getQueryResourceInfoArgOut().NumAllocations = 1; - std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), nullptr, 0, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), nullptr, 0, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); D3DDDI_OPENALLOCATIONINFO allocationInfo; allocationInfo.pPrivateDriverData = gmm->gmmResourceInfo->peekHandle(); @@ -348,7 +348,7 @@ TEST_F(WddmMemoryManagerSimpleTest, whenCreateAllocationFromHandleAndMapCallFail memoryManager.reset(new MockWddmMemoryManager(false, false, *executionEnvironment)); auto osHandle = 1u; gdi->getQueryResourceInfoArgOut().NumAllocations = 1; - auto gmm = std::make_unique(rootDeviceEnvironment->getGmmClientContext(), nullptr, 0, 0, false, false, StorageInfo{}, true); + auto gmm = std::make_unique(rootDeviceEnvironment->getGmmClientContext(), nullptr, 0, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, StorageInfo{}, true); D3DDDI_OPENALLOCATIONINFO allocationInfo; allocationInfo.pPrivateDriverData = gmm->gmmResourceInfo->peekHandle(); @@ -607,7 +607,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromSharedHandleIs auto osHandle = 1u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); AllocationProperties properties(0, false, 4096u, AllocationType::SHARED_BUFFER, false, false, mockDeviceBitfield); @@ -623,7 +623,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromSharedHandleIs TEST_F(WddmMemoryManagerSimpleTest, whenAllocationCreatedFromSharedHandleIsDestroyedThenDestroyAllocationFromGdiIsNotInvoked) { gdi->getQueryResourceInfoArgOut().NumAllocations = 1; - std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), nullptr, 0, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), nullptr, 0, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); D3DDDI_OPENALLOCATIONINFO allocationInfo; allocationInfo.pPrivateDriverData = gmm->gmmResourceInfo->peekHandle(); @@ -650,7 +650,7 @@ TEST_F(WddmMemoryManagerSimpleTest, whenAllocationCreatedFromSharedHandleIsDestr TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromNTHandleIsCalledThenNonNullGraphicsAllocationIsReturned) { void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); auto *gpuAllocation = memoryManager->createGraphicsAllocationFromNTHandle(reinterpret_cast(1), 0, AllocationType::SHARED_IMAGE); @@ -682,7 +682,7 @@ TEST_F(WddmMemoryManagerTest, GivenForce32bitAddressingAndRequireSpecificBitness auto osHandle = 1u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); memoryManager->setForce32BitAllocations(true); @@ -705,7 +705,7 @@ TEST_F(WddmMemoryManagerTest, GivenForce32bitAddressingAndNotRequiredSpecificBit auto osHandle = 1u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); memoryManager->setForce32BitAllocations(true); @@ -727,7 +727,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenFreeAllocFromSharedHandl auto osHandle = 1u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); AllocationProperties properties(0, false, 4096u, AllocationType::SHARED_BUFFER, false, false, 0); @@ -749,7 +749,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerSizeZeroWhenCreateFromShared auto size = 4096u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, size, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, size, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); AllocationProperties properties(0, false, size, AllocationType::SHARED_BUFFER, false, false, 0); @@ -825,7 +825,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromSharedHandleFa auto size = 4096u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, size, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, size, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); wddm->failOpenSharedHandle = true; @@ -1154,7 +1154,7 @@ TEST_F(WddmMemoryManagerTest, GivenThreeOsHandlesWhenAskedForDestroyAllocationsT osHandle0->handle = ALLOCATION_HANDLE; storage.fragmentStorageData[0].freeTheFragment = true; - osHandle0->gmm = new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, 0, false, false, {}, true); + osHandle0->gmm = new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); storage.fragmentStorageData[1].osHandleStorage = osHandle1; osHandle1->handle = ALLOCATION_HANDLE; @@ -1165,7 +1165,7 @@ TEST_F(WddmMemoryManagerTest, GivenThreeOsHandlesWhenAskedForDestroyAllocationsT storage.fragmentStorageData[2].osHandleStorage = osHandle2; osHandle2->handle = ALLOCATION_HANDLE; storage.fragmentStorageData[2].freeTheFragment = true; - osHandle2->gmm = new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, 0, false, false, {}, true); + osHandle2->gmm = new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); storage.fragmentStorageData[2].residency = new ResidencyData(maxOsContextCount); memoryManager->cleanOsHandles(storage, 0); @@ -1213,7 +1213,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCpuMemNotMeetRestriction TEST_F(WddmMemoryManagerTest, givenManagerWithDisabledDeferredDeleterWhenMapGpuVaFailThenFailToCreateAllocation) { void *ptr = reinterpret_cast(0x1000); size_t size = 0x1000; - std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), ptr, size, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), ptr, size, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); memoryManager->setDeferredDeleter(nullptr); setMapGpuVaFailConfigFcn(0, 1); @@ -1227,7 +1227,7 @@ TEST_F(WddmMemoryManagerTest, givenManagerWithDisabledDeferredDeleterWhenMapGpuV TEST_F(WddmMemoryManagerTest, givenManagerWithEnabledDeferredDeleterWhenFirstMapGpuVaFailSecondAfterDrainSuccessThenCreateAllocation) { void *ptr = reinterpret_cast(0x10000); size_t size = 0x1000; - std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), ptr, size, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), ptr, size, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); MockDeferredDeleter *deleter = new MockDeferredDeleter; memoryManager->setDeferredDeleter(deleter); @@ -1243,7 +1243,7 @@ TEST_F(WddmMemoryManagerTest, givenManagerWithEnabledDeferredDeleterWhenFirstMap TEST_F(WddmMemoryManagerTest, givenManagerWithEnabledDeferredDeleterWhenFirstAndMapGpuVaFailSecondAfterDrainFailThenFailToCreateAllocation) { void *ptr = reinterpret_cast(0x1000); size_t size = 0x1000; - std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), ptr, size, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), ptr, size, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); MockDeferredDeleter *deleter = new MockDeferredDeleter; memoryManager->setDeferredDeleter(deleter); @@ -1413,7 +1413,7 @@ TEST_F(BufferWithWddmMemory, givenFragmentsThatAreNotInOrderWhenGraphicsAllocati handleStorage.fragmentStorageData[0].residency = new ResidencyData(maxOsContextCount); handleStorage.fragmentStorageData[0].freeTheFragment = true; auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get(); - osHandle->gmm = new Gmm(rootDeviceEnvironment->getGmmClientContext(), ptr, size, 0, false, false, {}, true); + osHandle->gmm = new Gmm(rootDeviceEnvironment->getGmmClientContext(), ptr, size, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); handleStorage.fragmentCount = 1; FragmentStorage fragment = {}; @@ -1451,7 +1451,7 @@ TEST_F(BufferWithWddmMemory, givenFragmentsThatAreNotInOrderWhenGraphicsAllocati handleStorage.fragmentStorageData[0].residency = new ResidencyData(maxOsContextCount); handleStorage.fragmentStorageData[0].freeTheFragment = true; auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get(); - osHandle->gmm = new Gmm(rootDeviceEnvironment->getGmmClientContext(), ptr, size, 0, false, false, {}, true); + osHandle->gmm = new Gmm(rootDeviceEnvironment->getGmmClientContext(), ptr, size, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); handleStorage.fragmentCount = 1; FragmentStorage fragment = {}; @@ -1883,7 +1883,7 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationWhenMappedGpuVaAndPag GTEST_SKIP(); } auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[1].get(); - std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); gmm->isCompressionEnabled = true; D3DGPU_VIRTUAL_ADDRESS gpuVa = 0; WddmMock wddm(*executionEnvironment->rootDeviceEnvironments[1].get()); @@ -1915,7 +1915,7 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationWhenMappedGpuVaAndPag GTEST_SKIP(); } auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[1].get(); - std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); gmm->isCompressionEnabled = true; D3DGPU_VIRTUAL_ADDRESS gpuVa = 0; WddmMock wddm(*executionEnvironment->rootDeviceEnvironments[1].get()); @@ -2016,7 +2016,7 @@ TEST_F(MockWddmMemoryManagerTest, givenNonCompressedAllocationWhenReleaseingThen TEST_F(MockWddmMemoryManagerTest, givenNonCompressedAllocationWhenMappedGpuVaThenDontMapAuxVa) { auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[1].get(); - std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); gmm->isCompressionEnabled = false; D3DGPU_VIRTUAL_ADDRESS gpuVa = 0; WddmMock wddm(*rootDeviceEnvironment); @@ -2042,7 +2042,7 @@ TEST_F(MockWddmMemoryManagerTest, givenNonCompressedAllocationWhenMappedGpuVaThe TEST_F(MockWddmMemoryManagerTest, givenFailingAllocationWhenMappedGpuVaThenReturnFalse) { auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[1].get(); - std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, 0, false, false, {}, true)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); gmm->isCompressionEnabled = false; D3DGPU_VIRTUAL_ADDRESS gpuVa = 0; WddmMock wddm(*rootDeviceEnvironment); @@ -2071,7 +2071,7 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedFlagSetWhenInternalIsUnsetThenD engine.commandStreamReceiver->pageTableManager.reset(mockMngr); } - auto myGmm = new Gmm(rootDeviceEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, 0, false, false, {}, true); + auto myGmm = new Gmm(rootDeviceEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); myGmm->isCompressionEnabled = false; myGmm->gmmResourceInfo->getResourceFlags()->Info.RenderCompressed = 1; @@ -2108,7 +2108,7 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedFlagSetWhenInternalIsSetThenUpd engine.commandStreamReceiver->pageTableManager.reset(mockMngr); } - auto myGmm = new Gmm(rootDeviceEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, 0, false, false, {}, true); + auto myGmm = new Gmm(rootDeviceEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); myGmm->isCompressionEnabled = true; myGmm->gmmResourceInfo->getResourceFlags()->Info.RenderCompressed = 1; diff --git a/opencl/test/unit_test/sharings/gl/windows/gl_reused_buffers_tests.cpp b/opencl/test/unit_test/sharings/gl/windows/gl_reused_buffers_tests.cpp index fc23e243b7..ac3461793e 100644 --- a/opencl/test/unit_test/sharings/gl/windows/gl_reused_buffers_tests.cpp +++ b/opencl/test/unit_test/sharings/gl/windows/gl_reused_buffers_tests.cpp @@ -87,7 +87,7 @@ TEST_F(GlReusedBufferTests, givenMultipleBuffersWithReusedAllocationWhenReleasin TEST_F(GlReusedBufferTests, givenMultipleBuffersWithReusedAllocationWhenCreatingThenReuseGmmResourceToo) { std::unique_ptr glBuffer1(GlBuffer::createSharedGlBuffer(&context, CL_MEM_READ_WRITE, bufferId1, &retVal)); - glBuffer1->getGraphicsAllocation(rootDeviceIndex)->setDefaultGmm(new Gmm(context.getDevice(0)->getGmmClientContext(), (void *)0x100, 1, 0, false, false, {}, true)); + glBuffer1->getGraphicsAllocation(rootDeviceIndex)->setDefaultGmm(new Gmm(context.getDevice(0)->getGmmClientContext(), (void *)0x100, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true)); std::unique_ptr glBuffer2(GlBuffer::createSharedGlBuffer(&context, CL_MEM_READ_WRITE, bufferId1, &retVal)); diff --git a/opencl/test/unit_test/sharings/gl/windows/gl_sharing_tests.cpp b/opencl/test/unit_test/sharings/gl/windows/gl_sharing_tests.cpp index f8fdbb1445..3b600a1102 100644 --- a/opencl/test/unit_test/sharings/gl/windows/gl_sharing_tests.cpp +++ b/opencl/test/unit_test/sharings/gl/windows/gl_sharing_tests.cpp @@ -256,7 +256,7 @@ TEST_F(glSharingTests, givenClGLBufferWhenItIsAcquiredTwiceThenAcuqireIsNotCalle TEST_F(glSharingTests, givenClGLBufferWhenItIsCreatedAndGmmIsAvailableThenItIsUsedInGraphicsAllocation) { void *ptr = (void *)0x1000; auto rootDeviceIndex = context.getDevice(0)->getRootDeviceIndex(); - auto gmm = new Gmm(context.getDevice(0)->getGmmClientContext(), ptr, 4096u, 0, false, false, {}, true); + auto gmm = new Gmm(context.getDevice(0)->getGmmClientContext(), ptr, 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); mockGlSharing->m_bufferInfoOutput.pGmmResInfo = gmm->gmmResourceInfo->peekGmmResourceInfo(); mockGlSharing->uploadDataToBufferInfo(); diff --git a/opencl/test/unit_test/xe_hpg_core/test_cmds_programming_xe_hpg_core.cpp b/opencl/test/unit_test/xe_hpg_core/test_cmds_programming_xe_hpg_core.cpp index c1c74beb78..65e44923a8 100644 --- a/opencl/test/unit_test/xe_hpg_core/test_cmds_programming_xe_hpg_core.cpp +++ b/opencl/test/unit_test/xe_hpg_core/test_cmds_programming_xe_hpg_core.cpp @@ -167,7 +167,7 @@ XE_HPG_CORETEST_F(CmdsProgrammingTestsXeHpgCore, givenDecompressInL3ForImage2dFr imageDesc.mem_object = clCreateBuffer(&context, CL_MEM_READ_WRITE, imageDesc.image_height * imageDesc.image_width, nullptr, &retVal); - auto gmm = new Gmm(context.getDevice(0)->getGmmHelper()->getClientContext(), nullptr, 1, 0, false, false, {}, true); + auto gmm = new Gmm(context.getDevice(0)->getGmmHelper()->getClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); gmm->isCompressionEnabled = true; auto buffer = castToObject(imageDesc.mem_object); @@ -241,7 +241,7 @@ XE_HPG_CORETEST_F(CmdsProgrammingTestsXeHpgCore, givenDecompressInL3ForImage2dFr imageDesc.mem_object = clCreateBuffer(&context, CL_MEM_READ_WRITE, imageDesc.image_height * imageDesc.image_width, nullptr, &retVal); - auto gmm = new Gmm(context.getDevice(0)->getGmmHelper()->getClientContext(), nullptr, 1, 0, false, false, {}, true); + auto gmm = new Gmm(context.getDevice(0)->getGmmHelper()->getClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); gmm->isCompressionEnabled = true; auto buffer = castToObject(imageDesc.mem_object); @@ -284,7 +284,7 @@ XE_HPG_CORETEST_F(CmdsProgrammingTestsXeHpgCore, givenDecompressInL3ForImage2dFr imageDesc.mem_object = clCreateBuffer(&context, CL_MEM_READ_WRITE, imageDesc.image_height * imageDesc.image_width, nullptr, &retVal); - auto gmm = new Gmm(context.getDevice(0)->getGmmHelper()->getClientContext(), nullptr, 1, 0, false, false, {}, true); + auto gmm = new Gmm(context.getDevice(0)->getGmmHelper()->getClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); gmm->isCompressionEnabled = false; auto buffer = castToObject(imageDesc.mem_object); @@ -327,7 +327,7 @@ XE_HPG_CORETEST_F(CmdsProgrammingTestsXeHpgCore, givenDecompressInL3ForImage2dFr imageDesc.mem_object = clCreateBuffer(&context, CL_MEM_READ_WRITE, imageDesc.image_height * imageDesc.image_width, nullptr, &retVal); - auto gmm = new Gmm(context.getDevice(0)->getGmmHelper()->getClientContext(), nullptr, 1, 0, false, false, {}, true); + auto gmm = new Gmm(context.getDevice(0)->getGmmHelper()->getClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); gmm->isCompressionEnabled = true; gmm->gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = true; diff --git a/shared/source/gmm_helper/CMakeLists.txt b/shared/source/gmm_helper/CMakeLists.txt index 52aba1dc38..d7f59ddcaf 100644 --- a/shared/source/gmm_helper/CMakeLists.txt +++ b/shared/source/gmm_helper/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2019-2021 Intel Corporation +# Copyright (C) 2019-2022 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -9,6 +9,8 @@ set(NEO_CORE_GMM_HELPER ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}resource_info_${DRIVER_MODEL}.cpp ${CMAKE_CURRENT_SOURCE_DIR}/client_context/gmm_client_context.cpp ${CMAKE_CURRENT_SOURCE_DIR}/client_context/gmm_client_context.h + ${CMAKE_CURRENT_SOURCE_DIR}/cache_settings_helper.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/cache_settings_helper.h ${CMAKE_CURRENT_SOURCE_DIR}/gmm.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gmm.h ${CMAKE_CURRENT_SOURCE_DIR}/gmm_helper.cpp diff --git a/shared/source/gmm_helper/cache_settings_helper.cpp b/shared/source/gmm_helper/cache_settings_helper.cpp new file mode 100644 index 0000000000..962b53ddd0 --- /dev/null +++ b/shared/source/gmm_helper/cache_settings_helper.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/gmm_helper/cache_settings_helper.h" + +#include "shared/source/memory_manager/allocation_type.h" + +namespace NEO { + +namespace CacheSettingsHelper { +GMM_RESOURCE_USAGE_TYPE_ENUM getGmmUsageType(AllocationType allocationType, bool forceUncached) { + if (forceUncached) { + return (allocationType == AllocationType::PREEMPTION) ? GMM_RESOURCE_USAGE_OCL_BUFFER_CSR_UC + : GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED; + } + + if (allocationType == AllocationType::IMAGE) { + return GMM_RESOURCE_USAGE_OCL_IMAGE; + } + + return GMM_RESOURCE_USAGE_OCL_BUFFER; +} +} // namespace CacheSettingsHelper +} // namespace NEO \ No newline at end of file diff --git a/shared/source/gmm_helper/cache_settings_helper.h b/shared/source/gmm_helper/cache_settings_helper.h new file mode 100644 index 0000000000..dd82f47383 --- /dev/null +++ b/shared/source/gmm_helper/cache_settings_helper.h @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once +#include "shared/source/gmm_helper/gmm_lib.h" + +namespace NEO { +enum class AllocationType; + +namespace CacheSettingsHelper { +GMM_RESOURCE_USAGE_TYPE_ENUM getGmmUsageType(AllocationType allocationType, bool forceUncached); +} +} // namespace NEO \ No newline at end of file diff --git a/shared/source/gmm_helper/gmm.cpp b/shared/source/gmm_helper/gmm.cpp index d445058139..008da1edaa 100644 --- a/shared/source/gmm_helper/gmm.cpp +++ b/shared/source/gmm_helper/gmm.cpp @@ -7,6 +7,7 @@ #include "shared/source/gmm_helper/gmm.h" +#include "shared/source/gmm_helper/cache_settings_helper.h" #include "shared/source/gmm_helper/client_context/gmm_client_context.h" #include "shared/source/gmm_helper/gmm_helper.h" #include "shared/source/gmm_helper/resource_info.h" @@ -16,9 +17,11 @@ #include "shared/source/helpers/hw_info.h" #include "shared/source/helpers/ptr_math.h" #include "shared/source/helpers/surface_format_info.h" +#include "shared/source/memory_manager/allocation_type.h" namespace NEO { -Gmm::Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t alignedSize, size_t alignment, bool uncacheable, bool preferCompressed, StorageInfo storageInfo, bool allowLargePages) : clientContext(clientContext) { +Gmm::Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t alignedSize, size_t alignment, GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsage, + bool preferCompressed, StorageInfo storageInfo, bool allowLargePages) : clientContext(clientContext) { resourceParams.Type = RESOURCE_BUFFER; resourceParams.Format = GMM_FORMAT_GENERIC_8BIT; resourceParams.BaseWidth64 = static_cast(alignedSize); @@ -32,11 +35,7 @@ Gmm::Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t aligned } } - if (!uncacheable) { - resourceParams.Usage = GMM_RESOURCE_USAGE_OCL_BUFFER; - } else { - resourceParams.Usage = GMM_RESOURCE_USAGE_OCL_BUFFER_CSR_UC; - } + resourceParams.Usage = gmmResourceUsage; resourceParams.Flags.Info.Linear = 1; resourceParams.Flags.Info.Cacheable = 1; resourceParams.Flags.Gpu.Texture = 1; @@ -118,7 +117,7 @@ void Gmm::setupImageResourceParams(ImageInfo &imgInfo, bool preferCompressed) { resourceParams.NoGfxMemory = 1; // dont allocate, only query for params - resourceParams.Usage = GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_IMAGE; + resourceParams.Usage = CacheSettingsHelper::getGmmUsageType(AllocationType::IMAGE, false); resourceParams.Format = imgInfo.surfaceFormat->GMMSurfaceFormat; resourceParams.Flags.Gpu.Texture = 1; diff --git a/shared/source/gmm_helper/gmm.h b/shared/source/gmm_helper/gmm.h index 3da3616380..795c363fd8 100644 --- a/shared/source/gmm_helper/gmm.h +++ b/shared/source/gmm_helper/gmm.h @@ -25,7 +25,8 @@ class Gmm { virtual ~Gmm(); Gmm() = delete; Gmm(GmmClientContext *clientContext, ImageInfo &inputOutputImgInfo, StorageInfo storageInfo, bool preferCompressed); - Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t alignedSize, size_t alignment, bool uncacheable, bool preferCompressed, StorageInfo storageInfo, bool allowLargePages); + Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t alignedSize, size_t alignment, + GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsage, bool preferCompressed, StorageInfo storageInfo, bool allowLargePages); Gmm(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmm); void queryImageParams(ImageInfo &inputOutputImgInfo); diff --git a/shared/source/memory_manager/os_agnostic_memory_manager.cpp b/shared/source/memory_manager/os_agnostic_memory_manager.cpp index 8088df4dc8..096d516297 100644 --- a/shared/source/memory_manager/os_agnostic_memory_manager.cpp +++ b/shared/source/memory_manager/os_agnostic_memory_manager.cpp @@ -11,6 +11,7 @@ #include "shared/source/aub/aub_helper.h" #include "shared/source/execution_environment/execution_environment.h" #include "shared/source/execution_environment/root_device_environment.h" +#include "shared/source/gmm_helper/cache_settings_helper.h" #include "shared/source/gmm_helper/gmm.h" #include "shared/source/gmm_helper/gmm_helper.h" #include "shared/source/gmm_helper/resource_info.h" @@ -110,7 +111,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryWithAlignment allocationData.hostPtr, sizeAligned, alignment, - allocationData.flags.uncacheable, + CacheSettingsHelper::getGmmUsageType(memoryAllocation->getAllocationType(), !!allocationData.flags.uncacheable), true, allocationData.storageInfo, true); @@ -161,7 +162,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory64kb(const Al allocationData.hostPtr, allocationDataAlign.size, allocationDataAlign.alignment, - allocationData.flags.uncacheable, + CacheSettingsHelper::getGmmUsageType(memoryAllocation->getAllocationType(), !!allocationData.flags.uncacheable), allocationData.flags.preferCompressed, allocationData.storageInfo, true); memoryAllocation->setDefaultGmm(gmm.release()); @@ -348,7 +349,8 @@ void OsAgnosticMemoryManager::cleanOsHandles(OsHandleStorage &handleStorage, uin GraphicsAllocation *OsAgnosticMemoryManager::allocateMemoryByKMD(const AllocationData &allocationData) { auto gmm = std::make_unique(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), allocationData.hostPtr, - allocationData.size, 0u, false, allocationData.flags.preferCompressed, allocationData.storageInfo, true); + allocationData.size, 0u, CacheSettingsHelper::getGmmUsageType(allocationData.type, allocationData.flags.uncacheable), + allocationData.flags.preferCompressed, allocationData.storageInfo, true); GraphicsAllocation *alloc = nullptr; @@ -480,7 +482,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryInDevicePool( allocationData.hostPtr, sizeAligned64k, MemoryConstants::pageSize64k, - allocationData.flags.uncacheable, + CacheSettingsHelper::getGmmUsageType(allocationData.type, allocationData.flags.uncacheable), true, allocationData.storageInfo, true); diff --git a/shared/source/os_interface/linux/drm_memory_manager.cpp b/shared/source/os_interface/linux/drm_memory_manager.cpp index e6ef452d91..3f9b21632e 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.cpp +++ b/shared/source/os_interface/linux/drm_memory_manager.cpp @@ -10,6 +10,7 @@ #include "shared/source/command_stream/command_stream_receiver.h" #include "shared/source/execution_environment/execution_environment.h" #include "shared/source/execution_environment/root_device_environment.h" +#include "shared/source/gmm_helper/cache_settings_helper.h" #include "shared/source/gmm_helper/gmm.h" #include "shared/source/gmm_helper/gmm_helper.h" #include "shared/source/gmm_helper/resource_info.h" @@ -483,7 +484,7 @@ DrmAllocation *DrmMemoryManager::allocateGraphicsMemory64kb(const AllocationData GraphicsAllocation *DrmMemoryManager::allocateMemoryByKMD(const AllocationData &allocationData) { StorageInfo systemMemoryStorageInfo = {}; auto gmm = std::make_unique(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), allocationData.hostPtr, - allocationData.size, 0u, false, false, systemMemoryStorageInfo, true); + allocationData.size, 0u, CacheSettingsHelper::getGmmUsageType(allocationData.type, allocationData.flags.uncacheable), false, systemMemoryStorageInfo, true); size_t bufferSize = allocationData.size; uint64_t gpuRange = acquireGpuRange(bufferSize, allocationData.rootDeviceIndex, HeapIndex::HEAP_STANDARD64KB); @@ -1196,7 +1197,7 @@ void createColouredGmms(GmmClientContext *clientContext, DrmAllocation &allocati nullptr, currentSize, 0u, - false, + CacheSettingsHelper::getGmmUsageType(allocation.getAllocationType(), false), compression, limitedStorageInfo, true); @@ -1210,7 +1211,7 @@ void fillGmmsInAllocation(GmmClientContext *clientContext, DrmAllocation *alloca StorageInfo limitedStorageInfo = storageInfo; limitedStorageInfo.memoryBanks &= 1u << handleId; limitedStorageInfo.pageTablesVisibility &= 1u << handleId; - auto gmm = new Gmm(clientContext, nullptr, alignedSize, 0u, false, false, limitedStorageInfo, true); + auto gmm = new Gmm(clientContext, nullptr, alignedSize, 0u, CacheSettingsHelper::getGmmUsageType(allocation->getAllocationType(), false), false, limitedStorageInfo, true); allocation->setGmm(gmm, handleId); } } @@ -1279,7 +1280,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryInDevicePool(const A nullptr, sizeAligned, 0u, - allocationData.flags.uncacheable, + CacheSettingsHelper::getGmmUsageType(allocationData.type, !!allocationData.flags.uncacheable), allocationData.flags.preferCompressed, allocationData.storageInfo, true); diff --git a/shared/source/os_interface/windows/wddm_memory_manager.cpp b/shared/source/os_interface/windows/wddm_memory_manager.cpp index f1c8765d23..44f2e8417d 100644 --- a/shared/source/os_interface/windows/wddm_memory_manager.cpp +++ b/shared/source/os_interface/windows/wddm_memory_manager.cpp @@ -9,6 +9,7 @@ #include "shared/source/command_stream/command_stream_receiver_hw.h" #include "shared/source/execution_environment/root_device_environment.h" +#include "shared/source/gmm_helper/cache_settings_helper.h" #include "shared/source/gmm_helper/gmm.h" #include "shared/source/gmm_helper/gmm_helper.h" #include "shared/source/gmm_helper/page_table_mngr.h" @@ -71,7 +72,7 @@ GraphicsAllocation *WddmMemoryManager::allocateMemoryByKMD(const AllocationData } StorageInfo systemMemoryStorageInfo = {}; auto gmm = std::make_unique(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), allocationData.hostPtr, allocationData.size, 0u, - false, false, systemMemoryStorageInfo, true); + CacheSettingsHelper::getGmmUsageType(allocationData.type, !!allocationData.flags.uncacheable), false, systemMemoryStorageInfo, true); auto allocation = std::make_unique(allocationData.rootDeviceIndex, 1u, // numGmms allocationData.type, nullptr, allocationData.size, nullptr, @@ -122,7 +123,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryUsingKmdAndMapItToC auto gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), nullptr, sizeAligned, 0u, - allocationData.flags.uncacheable, + CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), !!allocationData.flags.uncacheable), allocationData.flags.preferCompressed, allocationData.storageInfo, allowLargePages); @@ -188,7 +189,8 @@ GraphicsAllocation *WddmMemoryManager::allocateHugeGraphicsMemory(const Allocati for (auto gmmId = 0u; gmmId < numGmms; ++gmmId) { auto size = sizeRemaining > chunkSize ? chunkSize : sizeRemaining; auto gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), - static_cast(alignedPtr) + gmmId * chunkSize, size, 0u, uncacheable, false, {}, true); + static_cast(alignedPtr) + gmmId * chunkSize, size, 0u, + CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), !!uncacheable), false, {}, true); wddmAllocation->setGmm(gmm, gmmId); sizeRemaining -= size; } @@ -242,7 +244,7 @@ GraphicsAllocation *WddmMemoryManager::allocateSystemMemoryAndCreateGraphicsAllo wddmAllocation->setDriverAllocatedCpuPtr(pSysMem); gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), pSysMem, sizeAligned, 0u, - allocationData.flags.uncacheable, allocationData.flags.preferCompressed, allocationData.storageInfo, true); + CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), !!allocationData.flags.uncacheable), allocationData.flags.preferCompressed, allocationData.storageInfo, true); wddmAllocation->setDefaultGmm(gmm); void *mapPtr = wddmAllocation->getAlignedCpuPtr(); @@ -286,7 +288,8 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr(co auto offsetInPage = ptrDiff(allocationData.hostPtr, alignedPtr); wddmAllocation->setAllocationOffset(offsetInPage); - auto gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), alignedPtr, alignedSize, 0u, false, false, {}, true); + auto gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), alignedPtr, alignedSize, 0u, + CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), !!allocationData.flags.uncacheable), false, {}, true); wddmAllocation->setDefaultGmm(gmm); @@ -322,7 +325,8 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithHostPtr(const A maxOsContextCount); allocation->setAllocationOffset(offset); - Gmm *gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), ptrAligned, sizeAligned, 0u, false, false, {}, true); + Gmm *gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), ptrAligned, sizeAligned, 0u, + CacheSettingsHelper::getGmmUsageType(allocation->getAllocationType(), !!allocationData.flags.uncacheable), false, {}, true); allocation->setDefaultGmm(gmm); if (createWddmAllocation(allocation, reserve)) { return allocation; @@ -366,7 +370,8 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemoryImpl(const All wddmAllocation->setAllocationOffset(offset); wddmAllocation->allocInFrontWindowPool = allocationData.flags.use32BitFrontWindow; - gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), ptrAligned, sizeAligned, 0u, false, false, {}, true); + gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), ptrAligned, sizeAligned, 0u, + CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), !!allocationData.flags.uncacheable), false, {}, true); wddmAllocation->setDefaultGmm(gmm); if (!createWddmAllocation(wddmAllocation.get(), nullptr)) { @@ -596,7 +601,8 @@ MemoryManager::AllocationStatus WddmMemoryManager::populateOsHandles(OsHandleSto handleStorage.fragmentStorageData[i].residency = new ResidencyData(maxOsContextCount); osHandle->gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getGmmClientContext(), handleStorage.fragmentStorageData[i].cpuPtr, - handleStorage.fragmentStorageData[i].fragmentSize, 0u, false, false, {}, true); + handleStorage.fragmentStorageData[i].fragmentSize, 0u, + CacheSettingsHelper::getGmmUsageType(AllocationType::EXTERNAL_HOST_PTR, false), false, {}, true); allocatedFragmentIndexes[allocatedFragmentsCounter] = i; allocatedFragmentsCounter++; } @@ -919,7 +925,7 @@ void createColouredGmms(GmmClientContext *clientContext, WddmAllocation &allocat nullptr, currentSize, 0u, - false, + CacheSettingsHelper::getGmmUsageType(allocation.getAllocationType(), false), compression, limitedStorageInfo, true); allocation.setGmm(gmm, handleId); @@ -931,7 +937,7 @@ void fillGmmsInAllocation(GmmClientContext *clientContext, WddmAllocation *alloc StorageInfo limitedStorageInfo = storageInfo; limitedStorageInfo.memoryBanks &= static_cast(1u << handleId); limitedStorageInfo.pageTablesVisibility &= static_cast(1u << handleId); - auto gmm = new Gmm(clientContext, nullptr, allocation->getAlignedSize(), 0u, false, false, limitedStorageInfo, true); + auto gmm = new Gmm(clientContext, nullptr, allocation->getAlignedSize(), 0u, CacheSettingsHelper::getGmmUsageType(allocation->getAllocationType(), false), false, limitedStorageInfo, true); allocation->setGmm(gmm, handleId); } } @@ -940,7 +946,7 @@ void splitGmmsInAllocation(GmmClientContext *clientContext, WddmAllocation *wddm auto sizeRemaining = wddmAllocation->getAlignedSize(); for (auto gmmId = 0u; gmmId < wddmAllocation->getNumGmms(); ++gmmId) { auto size = sizeRemaining > chunkSize ? chunkSize : sizeRemaining; - auto gmm = new Gmm(clientContext, nullptr, size, alignment, false, false, storageInfo, true); + auto gmm = new Gmm(clientContext, nullptr, size, alignment, CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), false), false, storageInfo, true); wddmAllocation->setGmm(gmm, gmmId); sizeRemaining -= size; } @@ -988,7 +994,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryInDevicePool(const nullptr, sizeAligned, alignment, - allocationData.flags.uncacheable, + CacheSettingsHelper::getGmmUsageType(allocationData.type, !!allocationData.flags.uncacheable), allocationData.flags.preferCompressed, allocationData.storageInfo, true); diff --git a/shared/test/common/fixtures/windows/memory_allocator_multi_device_fixture_windows.cpp b/shared/test/common/fixtures/windows/memory_allocator_multi_device_fixture_windows.cpp index 174d350b6f..d6ed15d5b9 100644 --- a/shared/test/common/fixtures/windows/memory_allocator_multi_device_fixture_windows.cpp +++ b/shared/test/common/fixtures/windows/memory_allocator_multi_device_fixture_windows.cpp @@ -24,7 +24,7 @@ void MemoryAllocatorMultiDeviceSystemSpecificFixture::SetUp(ExecutionEnvironment auto osEnvironment = new OsEnvironmentWin(); osEnvironment->gdi.reset(gdi); for (auto i = 0u; i < executionEnvironment.rootDeviceEnvironments.size(); i++) { - gmm = std::make_unique(executionEnvironment.rootDeviceEnvironments[i]->getGmmClientContext(), nullptr, 0, 0, false, false, StorageInfo{}, true); + gmm = std::make_unique(executionEnvironment.rootDeviceEnvironments[i]->getGmmClientContext(), nullptr, 0, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, StorageInfo{}, true); auto wddm = static_cast(executionEnvironment.rootDeviceEnvironments[i]->osInterface->getDriverModel()->as()); wddm->hwDeviceId = std::make_unique(ADAPTER_HANDLE, LUID{}, osEnvironment, std::make_unique()); wddm->callBaseMapGpuVa = false; diff --git a/shared/test/common/mocks/mock_gmm.h b/shared/test/common/mocks/mock_gmm.h index 72db7a39d0..df38131d99 100644 --- a/shared/test/common/mocks/mock_gmm.h +++ b/shared/test/common/mocks/mock_gmm.h @@ -23,7 +23,7 @@ class MockGmm : public Gmm { using Gmm::Gmm; using Gmm::setupImageResourceParams; - MockGmm(GmmClientContext *clientContext) : Gmm(clientContext, nullptr, 1, 0, false, false, {}, true){}; + MockGmm(GmmClientContext *clientContext) : Gmm(clientContext, nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true){}; static std::unique_ptr queryImgParams(GmmClientContext *clientContext, ImageInfo &imgInfo, bool preferCompression) { return std::unique_ptr(new Gmm(clientContext, imgInfo, {}, preferCompression)); diff --git a/shared/test/unit_test/command_stream/aub_command_stream_receiver_2_tests.cpp b/shared/test/unit_test/command_stream/aub_command_stream_receiver_2_tests.cpp index a5a733957d..c23a61e003 100644 --- a/shared/test/unit_test/command_stream/aub_command_stream_receiver_2_tests.cpp +++ b/shared/test/unit_test/command_stream/aub_command_stream_receiver_2_tests.cpp @@ -278,7 +278,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenNoCpuPtrAndNotLockableAllocationWhe allocation.overrideMemoryPool(MemoryPool::LocalMemory); aubExecutionEnvironment->executionEnvironment->rootDeviceEnvironments[0]->initGmm(); - MockGmm mockGmm(aubExecutionEnvironment->executionEnvironment->rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, initSize, initSize, false, false, {}, true); + MockGmm mockGmm(aubExecutionEnvironment->executionEnvironment->rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, initSize, initSize, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); mockGmm.resourceParams.Flags.Info.NotLockable = true; allocation.setDefaultGmm(&mockGmm); @@ -313,7 +313,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenNoCpuPtrAndLockableAllocationWhenGe allocation.overrideMemoryPool(MemoryPool::LocalMemory); aubExecutionEnvironment->executionEnvironment->rootDeviceEnvironments[0]->initGmm(); - MockGmm mockGmm(aubExecutionEnvironment->executionEnvironment->rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, initSize, initSize, false, false, {}, true); + MockGmm mockGmm(aubExecutionEnvironment->executionEnvironment->rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, initSize, initSize, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); mockGmm.resourceParams.Flags.Info.NotLockable = false; allocation.setDefaultGmm(&mockGmm); @@ -798,7 +798,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenWriteMe auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), MemoryConstants::pageSize}); aubCsr->setAubWritable(true, *gfxAllocation); - auto gmm = new Gmm(pDevice->getGmmClientContext(), nullptr, 1, 0, false, false, {}, true); + auto gmm = new Gmm(pDevice->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); gfxAllocation->setDefaultGmm(gmm); for (bool compressed : {false, true}) { 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 179170f0f3..7203bede2c 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 @@ -327,7 +327,7 @@ HWTEST_F(CommandStreamSimulatedTests, givenCompressedAllocationWhenCloningPageTa csr->setupContext(osContext); auto mockHardwareContext = static_cast(csr->hardwareContextController->hardwareContexts[0].get()); - MockGmm gmm(pDevice->executionEnvironment->rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, 1, 0, false, false, {}, true); + MockGmm gmm(pDevice->executionEnvironment->rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); gmm.isCompressionEnabled = true; int dummy = 1; @@ -386,7 +386,7 @@ HWTEST_F(CommandStreamSimulatedTests, givenCompressedTileInstancedAllocationWhen csr->multiOsContextCapable = true; - MockGmm gmm(pDevice->executionEnvironment->rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, 1, 0, false, false, {}, true); + MockGmm gmm(pDevice->executionEnvironment->rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true); gmm.isCompressionEnabled = true; int dummy = 1; diff --git a/shared/test/unit_test/os_interface/windows/wddm_shared_allocations_test.cpp b/shared/test/unit_test/os_interface/windows/wddm_shared_allocations_test.cpp index 170c13bbd5..a5384a01fb 100644 --- a/shared/test/unit_test/os_interface/windows/wddm_shared_allocations_test.cpp +++ b/shared/test/unit_test/os_interface/windows/wddm_shared_allocations_test.cpp @@ -68,7 +68,7 @@ TEST_F(WdmmSharedTests, WhenCreatingSharedAllocationAndGetNTHandleFailedThenAllo D3DKMT_HANDLE handle = 32u; D3DKMT_HANDLE resourceHandle = 32u; uint64_t ntHandle = 0u; - Gmm gmm(executionEnvironment->rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, 20, 0, false, true, {}, true); + Gmm gmm(executionEnvironment->rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, 20, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, true, {}, true); EXPECT_NE(STATUS_SUCCESS, wddm->createAllocation(nullptr, &gmm, handle, resourceHandle, &ntHandle)); EXPECT_EQ(wddm->destroyAllocationResult.called++, 1u); diff --git a/shared/test/unit_test/os_interface/windows/wddm_tests.cpp b/shared/test/unit_test/os_interface/windows/wddm_tests.cpp index 8fbee9075c..8d5e25a971 100644 --- a/shared/test/unit_test/os_interface/windows/wddm_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/wddm_tests.cpp @@ -17,7 +17,7 @@ TEST_F(WddmTests, whenCreatingAllocation64kThenDoNotCreateResource) { init(); D3DKMT_HANDLE handle; - Gmm gmm(executionEnvironment->rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, 20, 0, false, true, {}, true); + Gmm gmm(executionEnvironment->rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, 20, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, true, {}, true); EXPECT_TRUE(wddm->createAllocation(&gmm, handle)); auto gdiParam = getMockAllocationFcn();