From 2e0884a301b94d1d1f06a3169a8d59facffbfdd1 Mon Sep 17 00:00:00 2001 From: Katarzyna Cencelewska Date: Fri, 23 Aug 2024 00:02:44 +0000 Subject: [PATCH] fix: set properly resource params when setAllocationType gmm params: usage, cachable and resource info should be set properly when override allocation type Resolves: HSD-22020344331 Signed-off-by: Katarzyna Cencelewska --- .../unit_tests/sources/kernel/test_kernel.cpp | 4 +- opencl/source/mem_obj/buffer.cpp | 2 +- opencl/source/mem_obj/image.cpp | 2 +- .../compression_aub_tests_xehp_and_later.cpp | 2 +- .../aub_tests/fixtures/aub_fixture.cpp | 4 +- .../aub_tests/fixtures/simple_arg_fixture.h | 4 +- .../unit_test/built_ins/built_in_tests.cpp | 60 ++++++++++--------- .../command_queue/blit_enqueue_fixture.h | 2 +- .../command_queue_hw_1_tests.cpp | 2 +- .../command_queue/command_queue_tests.cpp | 6 +- .../enqueue_svm_mem_copy_tests.cpp | 10 ++-- .../enqueue_svm_mem_fill_tests.cpp | 7 ++- .../gen12lp/buffer_tests_gen12lp.inl | 3 +- .../gen12lp/gfx_core_helper_tests_gen12lp.inl | 3 +- .../kernel/kernel_arg_buffer_tests.cpp | 51 ++++++++++------ .../unit_test/kernel/kernel_arg_svm_tests.cpp | 9 ++- .../gfx_core_helper_tests_xe_hpc_core.cpp | 2 +- shared/source/gmm_helper/gmm.cpp | 31 ++++++---- shared/source/gmm_helper/gmm.h | 2 + .../memory_manager/graphics_allocation.cpp | 11 +++- .../memory_manager/graphics_allocation.h | 3 +- .../aub_mem_dump/aub_alloc_dump_tests.cpp | 24 ++++---- .../aub_command_stream_receiver_1_tests.cpp | 3 +- .../aub_command_stream_receiver_2_tests.cpp | 6 +- .../command_stream_receiver_tests.cpp | 3 +- .../graphics_allocation_tests.cpp | 15 +++++ ...nager_allocate_in_preferred_pool_tests.cpp | 6 +- .../memory_manager/memory_manager_tests.cpp | 12 ++-- .../aub_memory_operations_handler_tests.cpp | 3 +- .../os_interface/product_helper_tests.cpp | 6 +- .../windows/file_logger_win_tests.cpp | 8 ++- .../windows/wddm_memory_manager_tests.cpp | 9 +-- .../test/unit_test/utilities/logger_tests.cpp | 9 ++- .../gfx_core_helper_tests_xe2_hpg_core.cpp | 2 +- .../pvc/engine_node_helper_tests_pvc.cpp | 4 +- 35 files changed, 201 insertions(+), 129 deletions(-) diff --git a/level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp b/level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp index f7451ecb2e..1d765beb29 100644 --- a/level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp +++ b/level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp @@ -803,7 +803,7 @@ TEST_F(KernelImmutableDataTests, givenInternalModuleWhenKernelIsCreatedThenIsaIs bool isInternal = true; std::unique_ptr mockKernelImmData = std::make_unique(perHwThreadPrivateMemorySizeRequested); - mockKernelImmData->getIsaGraphicsAllocation()->setAllocationType(AllocationType::kernelIsaInternal); + mockKernelImmData->getIsaGraphicsAllocation()->setAllocationType(AllocationType::kernelIsaInternal, device->getProductHelper()); size_t previouscopyMemoryToAllocationCalledTimes = mockMemoryManager->copyMemoryToAllocationCalledTimes; @@ -878,7 +878,7 @@ TEST_P(KernelIsaCopyingMomentTest, givenInternalModuleWhenKernelIsCreatedThenIsa kernelMock.immutableData.kernelInfo = kernelInfo; kernelMock.immutableData.surfaceStateHeapSize = 64; kernelMock.immutableData.surfaceStateHeapTemplate.reset(new uint8_t[64]); - kernelMock.immutableData.getIsaGraphicsAllocation()->setAllocationType(AllocationType::kernelIsaInternal); + kernelMock.immutableData.getIsaGraphicsAllocation()->setAllocationType(AllocationType::kernelIsaInternal, device->getProductHelper()); kernelInfo->kernelDescriptor.payloadMappings.implicitArgs.systemThreadSurfaceAddress.bindful = 0; moduleMock->translationUnit->programInfo.kernelInfos.push_back(kernelInfo); diff --git a/opencl/source/mem_obj/buffer.cpp b/opencl/source/mem_obj/buffer.cpp index caa0c9c2b7..ab675eb8aa 100644 --- a/opencl/source/mem_obj/buffer.cpp +++ b/opencl/source/mem_obj/buffer.cpp @@ -476,7 +476,7 @@ Buffer *Buffer::create(Context *context, allocationInfo.allocationType = AllocationType::bufferHostMemory; } - allocationInfo.memory->setAllocationType(allocationInfo.allocationType); + allocationInfo.memory->setAllocationType(allocationInfo.allocationType, defaultDevice->getProductHelper()); auto isWritable = !(memoryProperties.flags.readOnly || memoryProperties.flags.hostReadOnly || memoryProperties.flags.hostNoAccess); allocationInfo.memory->setMemObjectsAllocationWithWritableFlags(isWritable); diff --git a/opencl/source/mem_obj/image.cpp b/opencl/source/mem_obj/image.cpp index 00262c0c4e..12cb46e15c 100644 --- a/opencl/source/mem_obj/image.cpp +++ b/opencl/source/mem_obj/image.cpp @@ -268,7 +268,7 @@ Image *Image::create(Context *context, } if (parentBuffer == nullptr) { - allocationInfo.memory->setAllocationType(AllocationType::image); + allocationInfo.memory->setAllocationType(AllocationType::image, defaultDevice->getProductHelper()); } if (parentImage) { diff --git a/opencl/test/unit_test/aub_tests/command_queue/compression_aub_tests_xehp_and_later.cpp b/opencl/test/unit_test/aub_tests/command_queue/compression_aub_tests_xehp_and_later.cpp index 4f85aaad4e..6c35b221d6 100644 --- a/opencl/test/unit_test/aub_tests/command_queue/compression_aub_tests_xehp_and_later.cpp +++ b/opencl/test/unit_test/aub_tests/command_queue/compression_aub_tests_xehp_and_later.cpp @@ -99,7 +99,7 @@ void CompressionXeHPAndLater::givenCompressedBuffersWhenWriting auto notCompressedBuffer = std::unique_ptr(Buffer::create(context, CL_MEM_READ_WRITE, bufferSize, nullptr, retVal)); auto nonCompressedAllocation = notCompressedBuffer->getGraphicsAllocation(device->getRootDeviceIndex()); - nonCompressedAllocation->setAllocationType(AllocationType::buffer); + nonCompressedAllocation->setAllocationType(AllocationType::buffer, device->getProductHelper()); if (nonCompressedAllocation->getDefaultGmm()) { nonCompressedAllocation->getDefaultGmm()->setCompressionEnabled(false); } diff --git a/opencl/test/unit_test/aub_tests/fixtures/aub_fixture.cpp b/opencl/test/unit_test/aub_tests/fixtures/aub_fixture.cpp index f28a1a4b5d..e59bdf1132 100644 --- a/opencl/test/unit_test/aub_tests/fixtures/aub_fixture.cpp +++ b/opencl/test/unit_test/aub_tests/fixtures/aub_fixture.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2023 Intel Corporation + * Copyright (C) 2018-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -18,7 +18,7 @@ GraphicsAllocation *AUBFixture::createHostPtrAllocationFromSvmPtr(void *svmPtr, GraphicsAllocation *allocation = csr->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), false, size}, svmPtr); csr->makeResidentHostPtrAllocation(allocation); csr->getInternalAllocationStorage()->storeAllocation(std::unique_ptr(allocation), TEMPORARY_ALLOCATION); - allocation->setAllocationType(AllocationType::buffer); + allocation->setAllocationType(AllocationType::buffer, csr->getProductHelper()); allocation->setMemObjectsAllocationWithWritableFlags(true); return allocation; } diff --git a/opencl/test/unit_test/aub_tests/fixtures/simple_arg_fixture.h b/opencl/test/unit_test/aub_tests/fixtures/simple_arg_fixture.h index ea745022cb..b2e8992e0f 100644 --- a/opencl/test/unit_test/aub_tests/fixtures/simple_arg_fixture.h +++ b/opencl/test/unit_test/aub_tests/fixtures/simple_arg_fixture.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2023 Intel Corporation + * Copyright (C) 2018-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -73,7 +73,7 @@ struct SimpleArgFixture : public FixtureFactory::IndirectHeapFixture, outBuffer = AUBCommandStreamFixture::createResidentAllocationAndStoreItInCsr(pDestMemory, sizeUserMemory); ASSERT_NE(nullptr, outBuffer); - outBuffer->setAllocationType(AllocationType::buffer); + outBuffer->setAllocationType(AllocationType::buffer, pClDevice->getProductHelper()); outBuffer->setMemObjectsAllocationWithWritableFlags(true); } 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 4297f933ae..6633bcb08c 100644 --- a/opencl/test/unit_test/built_ins/built_in_tests.cpp +++ b/opencl/test/unit_test/built_ins/built_in_tests.cpp @@ -289,9 +289,9 @@ TEST_F(BuiltInTests, GivenCopyBufferToSystemMemoryBufferWhenDispatchInfoIsCreate MockBuffer &src = *srcPtr; MockBuffer &dst = *dstPtr; - - srcPtr->mockGfxAllocation.setAllocationType(AllocationType::buffer); - dstPtr->mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory); + auto &productHelper = pDevice->getProductHelper(); + srcPtr->mockGfxAllocation.setAllocationType(AllocationType::buffer, productHelper); + dstPtr->mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory, productHelper); BuiltinOpParams builtinOpsParams; @@ -356,9 +356,9 @@ TEST_F(BuiltInTests, GivenCopyBufferToLocalMemoryBufferWhenDispatchInfoIsCreated MockBuffer &src = *srcPtr; MockBuffer &dst = *dstPtr; - - srcPtr->mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory); - dstPtr->mockGfxAllocation.setAllocationType(AllocationType::buffer); + auto &productHelper = pDevice->getProductHelper(); + srcPtr->mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory, productHelper); + dstPtr->mockGfxAllocation.setAllocationType(AllocationType::buffer, productHelper); BuiltinOpParams builtinOpsParams; @@ -922,9 +922,9 @@ TEST_F(BuiltInTests, givenBigOffsetAndSizeWhenBuilderCopyBufferToSystemBufferRec srcBuffer.size = static_cast(bigSize); MockBuffer dstBuffer; dstBuffer.size = static_cast(bigSize); - - srcBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer); - dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory); + auto &productHelper = pDevice->getProductHelper(); + srcBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer, productHelper); + dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory, productHelper); BuiltinOpParams dc; dc.srcMemObj = &srcBuffer; @@ -963,8 +963,9 @@ TEST_F(BuiltInTests, givenBigOffsetAndSizeWhenBuilderCopyBufferToLocalBufferRect MockBuffer dstBuffer; dstBuffer.size = static_cast(bigSize); - srcBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory); - dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer); + auto &productHelper = pDevice->getProductHelper(); + srcBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory, productHelper); + dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer, productHelper); BuiltinOpParams dc; dc.srcMemObj = &srcBuffer; @@ -1003,8 +1004,9 @@ TEST_F(BuiltInTests, givenBigOffsetAndSizeWhenBuilderFillSystemBufferStatelessIs MockBuffer dstBuffer; dstBuffer.size = static_cast(bigSize); - srcBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer); - dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory); + auto &productHelper = pDevice->getProductHelper(); + srcBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer, productHelper); + dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory, productHelper); BuiltinOpParams dc; dc.srcMemObj = &srcBuffer; @@ -1038,8 +1040,9 @@ TEST_F(BuiltInTests, givenBigOffsetAndSizeWhenBuilderFillLocalBufferStatelessIsU MockBuffer dstBuffer; dstBuffer.size = static_cast(bigSize); - srcBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory); - dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer); + auto &productHelper = pDevice->getProductHelper(); + srcBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory, productHelper); + dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer, productHelper); BuiltinOpParams dc; dc.srcMemObj = &srcBuffer; @@ -1101,7 +1104,7 @@ HWTEST_F(BuiltInTests, givenBigOffsetAndSizeWhenBuilderCopyImageToSystemBufferSt MockBuffer dstBuffer; dstBuffer.size = static_cast(bigSize); - dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory); + dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory, pDevice->getProductHelper()); std ::unique_ptr pSrcImage(Image2dHelper<>::create(pContext)); ASSERT_NE(nullptr, pSrcImage.get()); @@ -1139,7 +1142,7 @@ HWTEST_F(BuiltInTests, givenBigOffsetAndSizeWhenBuilderCopyImageToLocalBufferSta MockBuffer dstBuffer; dstBuffer.size = static_cast(bigSize); - dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer); + dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer, pDevice->getProductHelper()); std ::unique_ptr pSrcImage(Image2dHelper<>::create(pContext)); ASSERT_NE(nullptr, pSrcImage.get()); @@ -2468,8 +2471,9 @@ HWTEST2_F(BuiltInTests, whenBuilderCopyBufferToSystemBufferRectStatelessHeapless MockBuffer dstBuffer; dstBuffer.size = static_cast(bigSize); - srcBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer); - dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory); + const auto &productHelper = pDevice->getRootDeviceEnvironment().getHelper(); + srcBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer, productHelper); + dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory, productHelper); BuiltinOpParams dc; dc.srcMemObj = &srcBuffer; @@ -2507,9 +2511,9 @@ HWTEST2_F(BuiltInTests, whenBuilderCopyBufferToLocalBufferRectStatelessHeaplessI srcBuffer.size = static_cast(bigSize); MockBuffer dstBuffer; dstBuffer.size = static_cast(bigSize); - - srcBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory); - dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer); + const auto &productHelper = pDevice->getRootDeviceEnvironment().getHelper(); + srcBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory, productHelper); + dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer, productHelper); BuiltinOpParams dc; dc.srcMemObj = &srcBuffer; @@ -2547,9 +2551,9 @@ HWTEST2_F(BuiltInTests, whenBuilderFillSystemBufferStatelessHeaplessIsUsedThenPa srcBuffer.size = static_cast(bigSize); MockBuffer dstBuffer; dstBuffer.size = static_cast(bigSize); - - srcBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer); - dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory); + const auto &productHelper = pDevice->getRootDeviceEnvironment().getHelper(); + srcBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer, productHelper); + dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory, productHelper); BuiltinOpParams dc; dc.srcMemObj = &srcBuffer; @@ -2582,9 +2586,9 @@ HWTEST2_F(BuiltInTests, whenBuilderFillLocalBufferStatelessHeaplessIsUsedThenPar srcBuffer.size = static_cast(bigSize); MockBuffer dstBuffer; dstBuffer.size = static_cast(bigSize); - - srcBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory); - dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer); + const auto &productHelper = pDevice->getRootDeviceEnvironment().getHelper(); + srcBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory, productHelper); + dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer, productHelper); BuiltinOpParams dc; dc.srcMemObj = &srcBuffer; diff --git a/opencl/test/unit_test/command_queue/blit_enqueue_fixture.h b/opencl/test/unit_test/command_queue/blit_enqueue_fixture.h index 2631a51b7f..4db7409097 100644 --- a/opencl/test/unit_test/command_queue/blit_enqueue_fixture.h +++ b/opencl/test/unit_test/command_queue/blit_enqueue_fixture.h @@ -164,7 +164,7 @@ struct BlitEnqueueTests : public ::testing::Test { } void setAllocationType(GraphicsAllocation *graphicsAllocation, bool compressed) { - graphicsAllocation->setAllocationType(AllocationType::buffer); + graphicsAllocation->setAllocationType(AllocationType::buffer, device->getProductHelper()); if (compressed && !graphicsAllocation->getDefaultGmm()) { auto gmmHelper = device->getRootDeviceEnvironment().getGmmHelper(); diff --git a/opencl/test/unit_test/command_queue/command_queue_hw_1_tests.cpp b/opencl/test/unit_test/command_queue/command_queue_hw_1_tests.cpp index 84deb6d129..3a8dbb65ac 100644 --- a/opencl/test/unit_test/command_queue/command_queue_hw_1_tests.cpp +++ b/opencl/test/unit_test/command_queue/command_queue_hw_1_tests.cpp @@ -1442,7 +1442,7 @@ HWTEST_F(CommandQueueHwTest, givenDirectSubmissionAndSharedDisplayableImageWhenR auto image = std::unique_ptr(ImageHelper::create(context)); image->setSharingHandler(mockSharingHandler); - image->getGraphicsAllocation(0u)->setAllocationType(AllocationType::sharedImage); + image->getGraphicsAllocation(0u)->setAllocationType(AllocationType::sharedImage, pClDevice->getProductHelper()); cl_mem memObject = image.get(); cl_uint numObjects = 1; diff --git a/opencl/test/unit_test/command_queue/command_queue_tests.cpp b/opencl/test/unit_test/command_queue/command_queue_tests.cpp index f1bf58fc81..deeff1c806 100644 --- a/opencl/test/unit_test/command_queue/command_queue_tests.cpp +++ b/opencl/test/unit_test/command_queue/command_queue_tests.cpp @@ -1321,7 +1321,7 @@ HWTEST_F(CommandQueueTests, givenEnqueuesForSharedObjectsWithImageWhenUsingShari auto image = std::unique_ptr(ImageHelper::create(&context)); image->setSharingHandler(mockSharingHandler); - image->getGraphicsAllocation(0u)->setAllocationType(AllocationType::sharedImage); + image->getGraphicsAllocation(0u)->setAllocationType(AllocationType::sharedImage, context.getDevice(0)->getProductHelper()); cl_mem memObject = image.get(); cl_uint numObjects = 1; @@ -1345,7 +1345,7 @@ HWTEST_F(CommandQueueTests, givenDirectSubmissionAndSharedImageWhenReleasingShar auto image = std::unique_ptr(ImageHelper::create(&context)); image->setSharingHandler(mockSharingHandler); - image->getGraphicsAllocation(0u)->setAllocationType(AllocationType::sharedImage); + image->getGraphicsAllocation(0u)->setAllocationType(AllocationType::sharedImage, context.getDevice(0)->getProductHelper()); cl_mem memObject = image.get(); cl_uint numObjects = 1; @@ -1376,7 +1376,7 @@ HWTEST_F(CommandQueueTests, givenDcFlushMitigationAndDirectSubmissionAndBufferWh auto buffer = std::unique_ptr(BufferHelper<>::create(&context)); buffer->setSharingHandler(mockSharingHandler); - buffer->getGraphicsAllocation(0u)->setAllocationType(AllocationType::sharedBuffer); + buffer->getGraphicsAllocation(0u)->setAllocationType(AllocationType::sharedBuffer, context.getDevice(0)->getProductHelper()); cl_mem memObject = buffer.get(); cl_uint numObjects = 1; diff --git a/opencl/test/unit_test/command_queue/enqueue_svm_mem_copy_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_svm_mem_copy_tests.cpp index 20783745d0..4077ed64c6 100644 --- a/opencl/test/unit_test/command_queue/enqueue_svm_mem_copy_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_svm_mem_copy_tests.cpp @@ -517,8 +517,9 @@ HWTEST_F(EnqueueSvmMemCopyTest, givenEnqueueSvmMemcpyWhenSvmZeroCopyThenBuiltinK std::unique_ptr(new MockBuiltinDispatchInfoBuilder(*builtIns, pCmdQ->getClDevice(), &origBuilder))); EXPECT_EQ(&origBuilder, oldBuilder.get()); - srcSvmAlloc->setAllocationType(NEO::AllocationType::svmZeroCopy); - dstSvmAlloc->setAllocationType(NEO::AllocationType::svmZeroCopy); + auto &productHelper = pDevice->getProductHelper(); + srcSvmAlloc->setAllocationType(NEO::AllocationType::svmZeroCopy, productHelper); + dstSvmAlloc->setAllocationType(NEO::AllocationType::svmZeroCopy, productHelper); // call enqueue on mock builder auto retVal = pCmdQ->enqueueSVMMemcpy( @@ -594,8 +595,9 @@ HWTEST_F(EnqueueSvmMemCopyTest, givenEnqueueSvmMemcpyWhenSvmGpuThenBuiltinKernel std::unique_ptr(new MockBuiltinDispatchInfoBuilder(*builtIns, pCmdQ->getClDevice(), &origBuilder))); EXPECT_EQ(&origBuilder, oldBuilder.get()); - srcSvmAlloc->setAllocationType(NEO::AllocationType::svmGpu); - dstSvmAlloc->setAllocationType(NEO::AllocationType::svmGpu); + auto &productHelper = pDevice->getProductHelper(); + srcSvmAlloc->setAllocationType(NEO::AllocationType::svmGpu, productHelper); + dstSvmAlloc->setAllocationType(NEO::AllocationType::svmGpu, productHelper); // call enqueue on mock builder auto retVal = pCmdQ->enqueueSVMMemcpy( diff --git a/opencl/test/unit_test/command_queue/enqueue_svm_mem_fill_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_svm_mem_fill_tests.cpp index 4b07ee2990..deb256b6d7 100644 --- a/opencl/test/unit_test/command_queue/enqueue_svm_mem_fill_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_svm_mem_fill_tests.cpp @@ -275,7 +275,9 @@ HWTEST_F(EnqueueSvmMemFillHwTest, givenEnqueueSVMMemFillWhenUsingCopyBufferToSys auto cmdQ = std::make_unique>(context.get(), device.get()); auto svmData = context->getSVMAllocsManager()->getSVMAlloc(svmPtr); svmData->size = static_cast(bigSize); - svmData->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex())->setAllocationType(AllocationType::svmZeroCopy); + + auto &productHelper = device->getProductHelper(); + svmData->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex())->setAllocationType(AllocationType::svmZeroCopy, productHelper); cmdQ->validateKernelSystemMemory = true; cmdQ->expectedKernelSystemMemory = true; @@ -298,7 +300,8 @@ HWTEST_F(EnqueueSvmMemFillHwTest, givenEnqueueSVMMemFillWhenUsingCopyBufferToLoc GTEST_SKIP(); } auto svmData = context->getSVMAllocsManager()->getSVMAlloc(svmPtr); - svmData->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex())->setAllocationType(AllocationType::svmGpu); + auto &productHelper = device->getProductHelper(); + svmData->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex())->setAllocationType(AllocationType::svmGpu, productHelper); cmdQ->validateKernelSystemMemory = true; cmdQ->expectedKernelSystemMemory = false; diff --git a/opencl/test/unit_test/gen12lp/buffer_tests_gen12lp.inl b/opencl/test/unit_test/gen12lp/buffer_tests_gen12lp.inl index 25aeddf6e4..e0f9f2b615 100644 --- a/opencl/test/unit_test/gen12lp/buffer_tests_gen12lp.inl +++ b/opencl/test/unit_test/gen12lp/buffer_tests_gen12lp.inl @@ -75,7 +75,8 @@ GEN12LPTEST_F(BufferTestsTgllp, givenConstantSurfaceWhenProgrammingSurfaceStateT nullptr, retVal)); ASSERT_EQ(CL_SUCCESS, retVal); - buffer->getGraphicsAllocation(0)->setAllocationType(AllocationType::constantSurface); + auto &productHelper = device->getProductHelper(); + buffer->getGraphicsAllocation(0)->setAllocationType(AllocationType::constantSurface, productHelper); typename FamilyType::RENDER_SURFACE_STATE surfaceState = {}; buffer->setArgStateful(&surfaceState, false, false, false, false, context->getDevice(0)->getDevice(), false); diff --git a/opencl/test/unit_test/gen12lp/gfx_core_helper_tests_gen12lp.inl b/opencl/test/unit_test/gen12lp/gfx_core_helper_tests_gen12lp.inl index db0a8e50ab..3ae6302d16 100644 --- a/opencl/test/unit_test/gen12lp/gfx_core_helper_tests_gen12lp.inl +++ b/opencl/test/unit_test/gen12lp/gfx_core_helper_tests_gen12lp.inl @@ -275,7 +275,8 @@ GEN12LPTEST_F(GfxCoreHelperTestsGen12LpBuffer, givenBufferThenCheckResourceCompa buffer.reset(Buffer::create(context.get(), 0, MemoryConstants::cacheLineSize, nullptr, retVal)); - buffer->getGraphicsAllocation(rootDeviceIndex)->setAllocationType(AllocationType::buffer); + auto &productHelper = device->getProductHelper(); + buffer->getGraphicsAllocation(rootDeviceIndex)->setAllocationType(AllocationType::buffer, productHelper); EXPECT_TRUE(gfxCoreHelper.checkResourceCompatibility(*buffer->getGraphicsAllocation(rootDeviceIndex))); } 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 48255a6963..f9debf7263 100644 --- a/opencl/test/unit_test/kernel/kernel_arg_buffer_tests.cpp +++ b/opencl/test/unit_test/kernel/kernel_arg_buffer_tests.cpp @@ -206,7 +206,8 @@ TEST_F(KernelArgBufferTest, given32BitDeviceWhenArgPassedIsNullThenOnly4BytesAre TEST_F(KernelArgBufferTest, givenBufferWhenHasDirectStatelessAccessToHostMemoryIsCalledThenReturnFalse) { MockBuffer buffer; - buffer.getGraphicsAllocation(mockRootDeviceIndex)->setAllocationType(AllocationType::buffer); + auto &productHelper = pClDevice->getProductHelper(); + buffer.getGraphicsAllocation(mockRootDeviceIndex)->setAllocationType(AllocationType::buffer, productHelper); auto val = (cl_mem)&buffer; auto pVal = &val; @@ -223,7 +224,8 @@ TEST_F(KernelArgBufferTest, givenBufferWhenHasDirectStatelessAccessToHostMemoryI TEST_F(KernelArgBufferTest, givenSharedBufferWhenHasDirectStatelessAccessToSharedBufferIsCalledThenReturnCorrectValue) { MockBuffer buffer; - buffer.getGraphicsAllocation(mockRootDeviceIndex)->setAllocationType(AllocationType::sharedBuffer); + auto &productHelper = pClDevice->getProductHelper(); + buffer.getGraphicsAllocation(mockRootDeviceIndex)->setAllocationType(AllocationType::sharedBuffer, productHelper); auto val = (cl_mem)&buffer; auto pVal = &val; @@ -240,7 +242,8 @@ TEST_F(KernelArgBufferTest, givenSharedBufferWhenHasDirectStatelessAccessToShare TEST_F(KernelArgBufferTest, givenBufferInHostMemoryWhenHasDirectStatelessAccessToHostMemoryIsCalledThenReturnCorrectValue) { MockBuffer buffer; - buffer.getGraphicsAllocation(mockRootDeviceIndex)->setAllocationType(AllocationType::bufferHostMemory); + auto &productHelper = pClDevice->getProductHelper(); + buffer.getGraphicsAllocation(mockRootDeviceIndex)->setAllocationType(AllocationType::bufferHostMemory, productHelper); auto val = (cl_mem)&buffer; auto pVal = &val; @@ -264,7 +267,8 @@ TEST_F(KernelArgBufferTest, givenGfxAllocationWhenHasDirectStatelessAccessToHost char data[128]; void *ptr = &data; MockGraphicsAllocation gfxAllocation(ptr, 128); - gfxAllocation.setAllocationType(AllocationType::buffer); + auto &productHelper = pClDevice->getProductHelper(); + gfxAllocation.setAllocationType(AllocationType::buffer, productHelper); for (auto pureStatefulBufferAccess : {false, true}) { pKernelInfo->setBufferStateful(0, pureStatefulBufferAccess); @@ -285,7 +289,8 @@ TEST_F(KernelArgBufferTest, givenGfxAllocationInHostMemoryWhenHasDirectStateless char data[128]; void *ptr = &data; MockGraphicsAllocation gfxAllocation(ptr, 128); - gfxAllocation.setAllocationType(AllocationType::bufferHostMemory); + auto &productHelper = pClDevice->getProductHelper(); + gfxAllocation.setAllocationType(AllocationType::bufferHostMemory, productHelper); for (auto pureStatefulBufferAccess : {false, true}) { pKernelInfo->setBufferStateful(0, pureStatefulBufferAccess); @@ -329,8 +334,9 @@ TEST_F(KernelArgBufferTest, givenKernelWithIndirectStatelessAccessWhenHasIndirec MockKernel kernelWithIndirectUnifiedMemoryAllocation(pProgram, kernelInfo, *pClDevice); MockGraphicsAllocation gfxAllocation; + auto &productHelper = pClDevice->getProductHelper(); for (const auto type : allocationTypes) { - gfxAllocation.setAllocationType(type); + gfxAllocation.setAllocationType(type, productHelper); kernelWithIndirectUnifiedMemoryAllocation.setUnifiedMemoryExecInfo(&gfxAllocation); if (type == AllocationType::bufferHostMemory) { EXPECT_TRUE(kernelWithIndirectUnifiedMemoryAllocation.hasIndirectStatelessAccessToHostMemory()); @@ -385,7 +391,8 @@ TEST_F(KernelArgBufferTest, givenSetArgBufferOnKernelWithDirectStatelessAccessTo debugManager.flags.EnableStatelessCompression.set(1); MockBuffer buffer; - buffer.getGraphicsAllocation(mockRootDeviceIndex)->setAllocationType(AllocationType::sharedBuffer); + auto &productHelper = pClDevice->getProductHelper(); + buffer.getGraphicsAllocation(mockRootDeviceIndex)->setAllocationType(AllocationType::sharedBuffer, productHelper); auto val = (cl_mem)&buffer; auto pVal = &val; @@ -407,7 +414,8 @@ TEST_F(KernelArgBufferTest, givenSetArgBufferOnKernelWithDirectStatelessAccessTo debugManager.flags.EnableStatelessCompression.set(1); MockBuffer buffer; - buffer.getGraphicsAllocation(mockRootDeviceIndex)->setAllocationType(AllocationType::bufferHostMemory); + auto &productHelper = pClDevice->getProductHelper(); + buffer.getGraphicsAllocation(mockRootDeviceIndex)->setAllocationType(AllocationType::bufferHostMemory, productHelper); auto val = (cl_mem)&buffer; auto pVal = &val; @@ -457,7 +465,8 @@ TEST_F(KernelArgBufferTest, givenSetArgSvmAllocOnKernelWithDirectStatelessAccess char data[128]; void *ptr = &data; MockGraphicsAllocation gfxAllocation(ptr, 128); - gfxAllocation.setAllocationType(AllocationType::bufferHostMemory); + auto &productHelper = pClDevice->getProductHelper(); + gfxAllocation.setAllocationType(AllocationType::bufferHostMemory, productHelper); auto retVal = pKernel->setArgSvmAlloc(0, ptr, &gfxAllocation, 0u); EXPECT_EQ(CL_SUCCESS, retVal); @@ -503,7 +512,8 @@ TEST_F(KernelArgBufferTest, givenSetUnifiedMemoryExecInfoOnKernelWithNoIndirectS pKernelInfo->kernelDescriptor.kernelAttributes.hasIndirectStatelessAccess = false; MockGraphicsAllocation gfxAllocation; - gfxAllocation.setAllocationType(AllocationType::bufferHostMemory); + auto &productHelper = pClDevice->getProductHelper(); + gfxAllocation.setAllocationType(AllocationType::bufferHostMemory, productHelper); pKernel->setUnifiedMemoryExecInfo(&gfxAllocation); @@ -526,9 +536,9 @@ TEST_F(KernelArgBufferTest, givenSetUnifiedMemoryExecInfoOnKernelWithIndirectSta AllocationType::bufferHostMemory}; MockGraphicsAllocation gfxAllocation; - + auto &productHelper = pClDevice->getProductHelper(); for (const auto type : allocationTypes) { - gfxAllocation.setAllocationType(type); + gfxAllocation.setAllocationType(type, productHelper); pKernel->setUnifiedMemoryExecInfo(&gfxAllocation); @@ -569,9 +579,9 @@ TEST_F(KernelArgBufferTest, givenSetUnifiedMemoryExecInfoOnKernelWithIndirectSta auto gmm = std::make_unique(pDevice->getRootDeviceEnvironment().getGmmHelper(), nullptr, 0, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, StorageInfo{}, gmmRequirements); MockGraphicsAllocation gfxAllocation; gfxAllocation.setDefaultGmm(gmm.get()); - + auto &productHelper = pClDevice->getProductHelper(); for (const auto type : allocationTypes) { - gfxAllocation.setAllocationType(type.allocationType); + gfxAllocation.setAllocationType(type.allocationType, productHelper); pKernel->setUnifiedMemoryExecInfo(&gfxAllocation); gmm->setCompressionEnabled(type.compressed); @@ -616,9 +626,9 @@ TEST_F(KernelArgBufferTest, givenSVMAllocsManagerWithCompressedSVMAllocationsWhe SvmAllocationData allocData(0); allocData.gpuAllocations.addAllocation(&gfxAllocation); allocData.device = &pClDevice->getDevice(); - + auto &productHelper = pClDevice->getProductHelper(); for (const auto type : allocationTypes) { - gfxAllocation.setAllocationType(type.allocationType); + gfxAllocation.setAllocationType(type.allocationType, productHelper); gmm->setCompressionEnabled(type.compressed); @@ -733,7 +743,8 @@ HWTEST_F(KernelArgBufferTestBindless, givenBindlessBuffersWhenPatchBindlessOffse TEST_F(KernelArgBufferTest, givenBufferAsHostMemoryWhenSettingKernelArgThenKernelUsesSystemMemory) { MockBuffer buffer; - buffer.getGraphicsAllocation(mockRootDeviceIndex)->setAllocationType(AllocationType::bufferHostMemory); + auto &productHelper = pClDevice->getProductHelper(); + buffer.getGraphicsAllocation(mockRootDeviceIndex)->setAllocationType(AllocationType::bufferHostMemory, productHelper); auto memVal = (cl_mem)&buffer; auto val = &memVal; @@ -748,7 +759,8 @@ TEST_F(KernelArgBufferTest, givenBufferAsHostMemoryWhenSettingKernelArgThenKerne TEST_F(KernelArgBufferTest, givenBufferAsDeviceMemoryWhenSettingKernelArgThenKernelNotUsesSystemMemory) { MockBuffer buffer; - buffer.getGraphicsAllocation(mockRootDeviceIndex)->setAllocationType(AllocationType::buffer); + auto &productHelper = pClDevice->getProductHelper(); + buffer.getGraphicsAllocation(mockRootDeviceIndex)->setAllocationType(AllocationType::buffer, productHelper); auto memVal = (cl_mem)&buffer; auto val = &memVal; @@ -763,7 +775,8 @@ TEST_F(KernelArgBufferTest, givenBufferAsDeviceMemoryWhenSettingKernelArgThenKer TEST_F(KernelArgBufferTest, givenBufferAsDeviceMemoryAndKernelIsAlreadySetToUseSystemWhenSettingKernelArgThenKernelUsesSystemMemory) { MockBuffer buffer; - buffer.getGraphicsAllocation(mockRootDeviceIndex)->setAllocationType(AllocationType::buffer); + auto &productHelper = pClDevice->getProductHelper(); + buffer.getGraphicsAllocation(mockRootDeviceIndex)->setAllocationType(AllocationType::buffer, productHelper); auto memVal = (cl_mem)&buffer; auto val = &memVal; diff --git a/opencl/test/unit_test/kernel/kernel_arg_svm_tests.cpp b/opencl/test/unit_test/kernel/kernel_arg_svm_tests.cpp index 9d73bf2de3..402851ec5c 100644 --- a/opencl/test/unit_test/kernel/kernel_arg_svm_tests.cpp +++ b/opencl/test/unit_test/kernel/kernel_arg_svm_tests.cpp @@ -714,7 +714,8 @@ TEST_F(KernelArgSvmTest, GivenZeroCopySvmPtrWhenSettingKernelArgThenKernelUsesSy auto svmData = pContext->getSVMAllocsManager()->getSVMAlloc(alloc); auto gpuAllocation = svmData->gpuAllocations.getGraphicsAllocation(*pContext->getRootDeviceIndices().begin()); - gpuAllocation->setAllocationType(NEO::AllocationType::svmZeroCopy); + auto &productHelper = pClDevice->getProductHelper(); + gpuAllocation->setAllocationType(NEO::AllocationType::svmZeroCopy, productHelper); EXPECT_FALSE(pKernel->isAnyKernelArgumentUsingSystemMemory()); @@ -740,7 +741,8 @@ TEST_F(KernelArgSvmTest, GivenGpuSvmPtrWhenSettingKernelArgThenKernelNotUsesSyst auto svmData = pContext->getSVMAllocsManager()->getSVMAlloc(alloc); auto gpuAllocation = svmData->gpuAllocations.getGraphicsAllocation(*pContext->getRootDeviceIndices().begin()); - gpuAllocation->setAllocationType(NEO::AllocationType::svmGpu); + auto &productHelper = pClDevice->getProductHelper(); + gpuAllocation->setAllocationType(NEO::AllocationType::svmGpu, productHelper); EXPECT_FALSE(pKernel->isAnyKernelArgumentUsingSystemMemory()); @@ -766,7 +768,8 @@ TEST_F(KernelArgSvmTest, GivenGpuSvmPtrAndKernelIsAlreadySetToUseSystemWhenSetti auto svmData = pContext->getSVMAllocsManager()->getSVMAlloc(alloc); auto gpuAllocation = svmData->gpuAllocations.getGraphicsAllocation(*pContext->getRootDeviceIndices().begin()); - gpuAllocation->setAllocationType(NEO::AllocationType::svmGpu); + auto &productHelper = pClDevice->getProductHelper(); + gpuAllocation->setAllocationType(NEO::AllocationType::svmGpu, productHelper); EXPECT_FALSE(pKernel->isAnyKernelArgumentUsingSystemMemory()); pKernel->anyKernelArgumentUsingSystemMemory = true; diff --git a/opencl/test/unit_test/xe_hpc_core/gfx_core_helper_tests_xe_hpc_core.cpp b/opencl/test/unit_test/xe_hpc_core/gfx_core_helper_tests_xe_hpc_core.cpp index 60a7e962c5..597590b48e 100644 --- a/opencl/test/unit_test/xe_hpc_core/gfx_core_helper_tests_xe_hpc_core.cpp +++ b/opencl/test/unit_test/xe_hpc_core/gfx_core_helper_tests_xe_hpc_core.cpp @@ -644,7 +644,7 @@ XE_HPC_CORETEST_F(ProductHelperTestXeHpcCore, givenDefaultProductHelperHwWhenGet auto &productHelper = getHelper(); MockGraphicsAllocation allocation; allocation.overrideMemoryPool(MemoryPool::localMemory); - allocation.setAllocationType(AllocationType::bufferHostMemory); + allocation.setAllocationType(AllocationType::bufferHostMemory, pDevice->getProductHelper()); EXPECT_FALSE(productHelper.isBlitCopyRequiredForLocalMemory(pDevice->getRootDeviceEnvironment(), allocation)); } diff --git a/shared/source/gmm_helper/gmm.cpp b/shared/source/gmm_helper/gmm.cpp index f33c4944d8..8078f4fc71 100644 --- a/shared/source/gmm_helper/gmm.cpp +++ b/shared/source/gmm_helper/gmm.cpp @@ -22,6 +22,22 @@ #include "shared/source/memory_manager/definitions/storage_info.h" namespace NEO { +void Gmm::updateUsageAndCachableFlag(GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsage, const GmmRequirements &gmmRequirements) { + resourceParams.Usage = gmmResourceUsage; + this->preferNoCpuAccess = CacheSettingsHelper::preferNoCpuAccess(gmmResourceUsage, gmmHelper->getRootDeviceEnvironment()); + bool cacheable = !this->preferNoCpuAccess && !CacheSettingsHelper::isUncachedType(gmmResourceUsage); + + gmmRequirements.overriderPreferNoCpuAccess.doOverride(this->preferNoCpuAccess); + gmmRequirements.overriderCacheable.doOverride(cacheable); + if (NEO::debugManager.flags.OverrideGmmCacheableField.get() != -1) { + cacheable = !!NEO::debugManager.flags.OverrideGmmCacheableField.get(); + } + resourceParams.Flags.Info.Cacheable = cacheable; +} + +void Gmm::applyResourceInfo() { + gmmResourceInfo.reset(GmmResourceInfo::create(gmmHelper->getClientContext(), &resourceParams)); +} Gmm::Gmm(GmmHelper *gmmHelper, const void *alignedPtr, size_t alignedSize, size_t alignment, GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsage, const StorageInfo &storageInfo, const GmmRequirements &gmmRequirements) : gmmHelper(gmmHelper) { resourceParams.Type = RESOURCE_BUFFER; @@ -37,20 +53,9 @@ Gmm::Gmm(GmmHelper *gmmHelper, const void *alignedPtr, size_t alignedSize, size_ } } - resourceParams.Usage = gmmResourceUsage; resourceParams.Flags.Info.Linear = 1; - this->preferNoCpuAccess = CacheSettingsHelper::preferNoCpuAccess(gmmResourceUsage, gmmHelper->getRootDeviceEnvironment()); - bool cacheable = !this->preferNoCpuAccess && !CacheSettingsHelper::isUncachedType(gmmResourceUsage); - - gmmRequirements.overriderPreferNoCpuAccess.doOverride(this->preferNoCpuAccess); - gmmRequirements.overriderCacheable.doOverride(cacheable); - - if (NEO::debugManager.flags.OverrideGmmCacheableField.get() != -1) { - cacheable = !!NEO::debugManager.flags.OverrideGmmCacheableField.get(); - } - - resourceParams.Flags.Info.Cacheable = cacheable; + updateUsageAndCachableFlag(gmmResourceUsage, gmmRequirements); resourceParams.Flags.Gpu.Texture = 1; @@ -71,7 +76,7 @@ Gmm::Gmm(GmmHelper *gmmHelper, const void *alignedPtr, size_t alignedSize, size_ applyAppResource(storageInfo); applyDebugOverrides(); - gmmResourceInfo.reset(GmmResourceInfo::create(gmmHelper->getClientContext(), &resourceParams)); + applyResourceInfo(); } Gmm::Gmm(GmmHelper *gmmHelper, GMM_RESOURCE_INFO *inputGmm) : Gmm(gmmHelper, inputGmm, false) {} diff --git a/shared/source/gmm_helper/gmm.h b/shared/source/gmm_helper/gmm.h index 32d1f53a45..0d934de9c8 100644 --- a/shared/source/gmm_helper/gmm.h +++ b/shared/source/gmm_helper/gmm.h @@ -53,6 +53,7 @@ class Gmm { void applyAuxFlagsForBuffer(bool preferCompression); void applyMemoryFlags(const StorageInfo &storageInfo); void applyAppResource(const StorageInfo &storageInfo); + void applyResourceInfo(); bool unifiedAuxTranslationCapable() const; bool hasMultisampleControlSurface() const; @@ -62,6 +63,7 @@ class Gmm { uint32_t queryQPitch(GMM_RESOURCE_TYPE resType); void updateImgInfoAndDesc(ImageInfo &imgInfo, uint32_t arrayIndex, ImagePlane yuvPlaneType); void updateOffsetsInImgInfo(ImageInfo &imgInfo, uint32_t arrayIndex); + void updateUsageAndCachableFlag(GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsage, const GmmRequirements &gmmRequirements); uint8_t resourceCopyBlt(void *sys, void *gpu, uint32_t pitch, uint32_t height, unsigned char upload, ImagePlane plane); uint32_t getUnifiedAuxPitchTiles(); diff --git a/shared/source/memory_manager/graphics_allocation.cpp b/shared/source/memory_manager/graphics_allocation.cpp index 528f6f3afb..8170e05aeb 100644 --- a/shared/source/memory_manager/graphics_allocation.cpp +++ b/shared/source/memory_manager/graphics_allocation.cpp @@ -8,8 +8,10 @@ #include "graphics_allocation.h" #include "shared/source/command_stream/command_stream_receiver.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" #include "shared/source/helpers/aligned_memory.h" #include "shared/source/helpers/bit_helpers.h" #include "shared/source/memory_manager/allocation_properties.h" @@ -18,9 +20,16 @@ #include "shared/source/utilities/logger.h" namespace NEO { -void GraphicsAllocation::setAllocationType(AllocationType allocationType) { +void GraphicsAllocation::setAllocationType(AllocationType allocationType, const ProductHelper &productHelper) { if (this->allocationType != allocationType) { this->allocationType = allocationType; + auto gmm = getDefaultGmm(); + if (gmm) { + GmmRequirements gmmRequirements{}; + auto gmmResourceUsage = CacheSettingsHelper::getGmmUsageType(allocationType, false, productHelper); + gmm->updateUsageAndCachableFlag(gmmResourceUsage, gmmRequirements); + gmm->applyResourceInfo(); + } fileLoggerInstance().logAllocation(this); } } diff --git a/shared/source/memory_manager/graphics_allocation.h b/shared/source/memory_manager/graphics_allocation.h index eda8b90b9b..665ae5bf3e 100644 --- a/shared/source/memory_manager/graphics_allocation.h +++ b/shared/source/memory_manager/graphics_allocation.h @@ -36,6 +36,7 @@ class Gmm; class MemoryManager; class CommandStreamReceiver; class GraphicsAllocation; +class ProductHelper; struct AllocationProperties; @@ -150,7 +151,7 @@ class GraphicsAllocation : public IDNode { osHandle peekSharedHandle() const { return sharingInfo.sharedHandle; } void setSharedHandle(osHandle handle) { sharingInfo.sharedHandle = handle; } - void setAllocationType(AllocationType allocationType); + void setAllocationType(AllocationType allocationType, const ProductHelper &productHelper); AllocationType getAllocationType() const { return allocationType; } MemoryPool getMemoryPool() const { return memoryPool; } diff --git a/shared/test/unit_test/aub_mem_dump/aub_alloc_dump_tests.cpp b/shared/test/unit_test/aub_mem_dump/aub_alloc_dump_tests.cpp index e52006502b..926690f9eb 100644 --- a/shared/test/unit_test/aub_mem_dump/aub_alloc_dump_tests.cpp +++ b/shared/test/unit_test/aub_mem_dump/aub_alloc_dump_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2023 Intel Corporation + * Copyright (C) 2019-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -36,44 +36,44 @@ struct AubFileStreamMock : public AubMemDump::AubFileStream { HWTEST_F(AubAllocDumpTests, givenBufferOrImageWhenGraphicsAllocationIsKnownThenItsTypeCanBeCheckedIfItIsWritable) { auto memoryManager = pDevice->getMemoryManager(); auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), MemoryConstants::pageSize}); - - gfxAllocation->setAllocationType(AllocationType::buffer); + auto &productHelper = pDevice->getProductHelper(); + gfxAllocation->setAllocationType(AllocationType::buffer, productHelper); EXPECT_FALSE(gfxAllocation->isMemObjectsAllocationWithWritableFlags()); EXPECT_FALSE(AubAllocDump::isWritableBuffer(*gfxAllocation)); - gfxAllocation->setAllocationType(AllocationType::buffer); + gfxAllocation->setAllocationType(AllocationType::buffer, productHelper); gfxAllocation->setMemObjectsAllocationWithWritableFlags(true); EXPECT_TRUE(AubAllocDump::isWritableBuffer(*gfxAllocation)); - gfxAllocation->setAllocationType(AllocationType::bufferHostMemory); + gfxAllocation->setAllocationType(AllocationType::bufferHostMemory, productHelper); gfxAllocation->setMemObjectsAllocationWithWritableFlags(false); EXPECT_FALSE(AubAllocDump::isWritableBuffer(*gfxAllocation)); - gfxAllocation->setAllocationType(AllocationType::bufferHostMemory); + gfxAllocation->setAllocationType(AllocationType::bufferHostMemory, productHelper); gfxAllocation->setMemObjectsAllocationWithWritableFlags(true); EXPECT_TRUE(AubAllocDump::isWritableBuffer(*gfxAllocation)); - gfxAllocation->setAllocationType(AllocationType::externalHostPtr); + gfxAllocation->setAllocationType(AllocationType::externalHostPtr, productHelper); gfxAllocation->setMemObjectsAllocationWithWritableFlags(false); EXPECT_FALSE(AubAllocDump::isWritableBuffer(*gfxAllocation)); - gfxAllocation->setAllocationType(AllocationType::externalHostPtr); + gfxAllocation->setAllocationType(AllocationType::externalHostPtr, productHelper); gfxAllocation->setMemObjectsAllocationWithWritableFlags(true); EXPECT_TRUE(AubAllocDump::isWritableBuffer(*gfxAllocation)); - gfxAllocation->setAllocationType(AllocationType::mapAllocation); + gfxAllocation->setAllocationType(AllocationType::mapAllocation, productHelper); gfxAllocation->setMemObjectsAllocationWithWritableFlags(false); EXPECT_FALSE(AubAllocDump::isWritableBuffer(*gfxAllocation)); - gfxAllocation->setAllocationType(AllocationType::mapAllocation); + gfxAllocation->setAllocationType(AllocationType::mapAllocation, productHelper); gfxAllocation->setMemObjectsAllocationWithWritableFlags(true); EXPECT_TRUE(AubAllocDump::isWritableBuffer(*gfxAllocation)); - gfxAllocation->setAllocationType(AllocationType::image); + gfxAllocation->setAllocationType(AllocationType::image, productHelper); gfxAllocation->setMemObjectsAllocationWithWritableFlags(false); EXPECT_FALSE(AubAllocDump::isWritableImage(*gfxAllocation)); - gfxAllocation->setAllocationType(AllocationType::image); + gfxAllocation->setAllocationType(AllocationType::image, productHelper); gfxAllocation->setMemObjectsAllocationWithWritableFlags(true); EXPECT_TRUE(AubAllocDump::isWritableImage(*gfxAllocation)); diff --git a/shared/test/unit_test/command_stream/aub_command_stream_receiver_1_tests.cpp b/shared/test/unit_test/command_stream/aub_command_stream_receiver_1_tests.cpp index 1fc272918a..a586a815c8 100644 --- a/shared/test/unit_test/command_stream/aub_command_stream_receiver_1_tests.cpp +++ b/shared/test/unit_test/command_stream/aub_command_stream_receiver_1_tests.cpp @@ -786,6 +786,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenWriteMe aubCsr->setupContext(*pDevice->getDefaultEngine().osContext); memoryManager.reset(new OsAgnosticMemoryManager(*pDevice->executionEnvironment)); aubCsr->initializeEngine(); + auto &productHelper = pDevice->getProductHelper(); auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), MemoryConstants::pageSize}); @@ -809,7 +810,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenWriteMe for (auto allocationType : onlyOneTimeAubWritableTypes) { gfxAllocation->setAubWritable(true, GraphicsAllocation::defaultBank); - gfxAllocation->setAllocationType(allocationType); + gfxAllocation->setAllocationType(allocationType, productHelper); aubCsr->writeMemory(*gfxAllocation); EXPECT_FALSE(aubCsr->isAubWritable(*gfxAllocation)); 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 4b83d3a1ec..52f72a97da 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 @@ -272,6 +272,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenNoCpuPtrAndNotLockableAllocationWhe auto aubExecutionEnvironment = getEnvironment>(true, true, true); auto aubCsr = aubExecutionEnvironment->template getCsr>(); auto mockMemoryManager = new MockMemoryManager(); + auto &productHelper = pDevice->getProductHelper(); auto memoryManagerBackup = aubExecutionEnvironment->executionEnvironment->memoryManager.release(); aubExecutionEnvironment->executionEnvironment->memoryManager.reset(mockMemoryManager); @@ -281,7 +282,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenNoCpuPtrAndNotLockableAllocationWhe constexpr uint64_t initGpuAddress = 1234; constexpr size_t initSize = 10; MockGraphicsAllocation allocation(nullptr, initGpuAddress, initSize); - allocation.setAllocationType(AllocationType::buffer); + allocation.setAllocationType(AllocationType::buffer, productHelper); allocation.overrideMemoryPool(MemoryPool::localMemory); aubExecutionEnvironment->executionEnvironment->rootDeviceEnvironments[0]->initGmm(); @@ -319,7 +320,8 @@ HWTEST_F(AubCommandStreamReceiverTests, givenNoCpuPtrAndLockableAllocationWhenGe constexpr uint64_t initGpuAddress = 1234; constexpr size_t initSize = 10; MockGraphicsAllocation allocation(nullptr, initGpuAddress, initSize); - allocation.setAllocationType(AllocationType::bufferHostMemory); + auto &productHelper = pDevice->getProductHelper(); + allocation.setAllocationType(AllocationType::bufferHostMemory, productHelper); allocation.overrideMemoryPool(MemoryPool::localMemory); aubExecutionEnvironment->executionEnvironment->rootDeviceEnvironments[0]->initGmm(); diff --git a/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp b/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp index 324470fe90..382839ab47 100644 --- a/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp +++ b/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp @@ -1654,7 +1654,8 @@ TEST(CommandStreamReceiverSimpleTest, givenNewResourceFlushEnabledWhenProvidingN DeviceBitfield deviceBitfield(1); MockCommandStreamReceiver csr(executionEnvironment, 0, deviceBitfield); MockGraphicsAllocation mockAllocation; - mockAllocation.setAllocationType(AllocationType::kernelIsa); + auto &productHelper = executionEnvironment.rootDeviceEnvironments[0]->getHelper(); + mockAllocation.setAllocationType(AllocationType::kernelIsa, productHelper); csr.useNewResourceImplicitFlush = true; csr.newResources = false; diff --git a/shared/test/unit_test/memory_manager/graphics_allocation_tests.cpp b/shared/test/unit_test/memory_manager/graphics_allocation_tests.cpp index 9eb5c94061..86ebc361da 100644 --- a/shared/test/unit_test/memory_manager/graphics_allocation_tests.cpp +++ b/shared/test/unit_test/memory_manager/graphics_allocation_tests.cpp @@ -5,9 +5,12 @@ * */ +#include "shared/source/gmm_helper/gmm.h" +#include "shared/test/common/fixtures/device_fixture.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/mocks/mock_aub_csr.h" #include "shared/test/common/mocks/mock_command_stream_receiver.h" +#include "shared/test/common/mocks/mock_device.h" #include "shared/test/common/mocks/mock_execution_environment.h" #include "shared/test/common/mocks/mock_graphics_allocation.h" #include "shared/test/common/test_macros/hw_test.h" @@ -636,4 +639,16 @@ TEST(GraphicsAllocationTest, givenGraphicsAllocationsWhenAllocationTypeIsRingBuf graphicsAllocation.hasAllocationReadOnlyTypeCallBase = true; graphicsAllocation.allocationType = AllocationType::ringBuffer; EXPECT_TRUE(graphicsAllocation.hasAllocationReadOnlyType()); +} +using GraphicsAllocationSetAllocationTypeTest = Test; +HWTEST_F(GraphicsAllocationSetAllocationTypeTest, givenAnotherAllocationTypeWhenCalSetAllocationTypeThenUsageAndCacheableAreSetCorrectly) { + MockGraphicsAllocation graphicsAllocation; + GmmRequirements gmmRequirements{}; + auto gmm = std::unique_ptr(new Gmm(pDevice->getGmmHelper(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, {}, gmmRequirements)); + graphicsAllocation.setDefaultGmm(gmm.get()); + auto &productHelper = getHelper(); + graphicsAllocation.setAllocationType(AllocationType::bufferHostMemory, productHelper); + + EXPECT_EQ(graphicsAllocation.getDefaultGmm()->resourceParams.Usage, GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER); + EXPECT_TRUE(graphicsAllocation.getDefaultGmm()->resourceParams.Flags.Info.Cacheable); } \ No newline at end of file diff --git a/shared/test/unit_test/memory_manager/memory_manager_allocate_in_preferred_pool_tests.cpp b/shared/test/unit_test/memory_manager/memory_manager_allocate_in_preferred_pool_tests.cpp index 5deceba345..a2afd073dc 100644 --- a/shared/test/unit_test/memory_manager/memory_manager_allocate_in_preferred_pool_tests.cpp +++ b/shared/test/unit_test/memory_manager/memory_manager_allocate_in_preferred_pool_tests.cpp @@ -1118,7 +1118,7 @@ TEST(MemoryManagerTest, givenMemoryManagerWhenAllocationIsCommandBufferAndItIsSe std::swap(executionEnvironment.rootDeviceEnvironments[0]->productHelper, productHelper); MockMemoryManager memoryManager(false, true, executionEnvironment); MockGraphicsAllocation mockGa; - mockGa.setAllocationType(AllocationType::commandBuffer); + mockGa.setAllocationType(AllocationType::commandBuffer, *productHelper.get()); mockGa.hasAllocationReadOnlyTypeResult = true; @@ -1143,7 +1143,7 @@ TEST(MemoryManagerTest, givenMemoryManagerWhenAllocationIsCommandBufferAndMultiC std::swap(executionEnvironment.rootDeviceEnvironments[0]->productHelper, productHelper); MockMemoryManager memoryManager(false, true, executionEnvironment); MockGraphicsAllocation mockGa; - mockGa.setAllocationType(AllocationType::commandBuffer); + mockGa.setAllocationType(AllocationType::commandBuffer, *productHelper.get()); mockGa.hasAllocationReadOnlyTypeResult = true; @@ -1169,7 +1169,7 @@ TEST(MemoryManagerTest, givenMemoryManagerWhenAllocationTypeAndPlatrormSupportRe std::swap(executionEnvironment.rootDeviceEnvironments[0]->productHelper, productHelper); MockMemoryManager memoryManager(false, true, executionEnvironment); MockGraphicsAllocation mockGa; - mockGa.setAllocationType(AllocationType::buffer); + mockGa.setAllocationType(AllocationType::buffer, *productHelper.get()); mockGa.hasAllocationReadOnlyTypeResult = true; diff --git a/shared/test/unit_test/memory_manager/memory_manager_tests.cpp b/shared/test/unit_test/memory_manager/memory_manager_tests.cpp index 3569d7719a..7e1dc7e467 100644 --- a/shared/test/unit_test/memory_manager/memory_manager_tests.cpp +++ b/shared/test/unit_test/memory_manager/memory_manager_tests.cpp @@ -3073,8 +3073,8 @@ HWTEST_F(MemoryAllocatorTest, givenUseLocalPreferredForCacheableBuffersAndCompre EXPECT_EQ(false, allocData.storageInfo.systemMemoryForced); } } - -TEST(MemoryTransferHelperTest, WhenBlitterIsSelectedButBlitCopyFailsThenFallbackToCopyOnCPU) { +using MemoryTransferHelperTest = Test; +HWTEST_F(MemoryTransferHelperTest, WhenBlitterIsSelectedButBlitCopyFailsThenFallbackToCopyOnCPU) { constexpr uint32_t dataSize = 16; uint8_t destData[dataSize] = {}; uint8_t srcData[dataSize] = {}; @@ -3082,7 +3082,8 @@ TEST(MemoryTransferHelperTest, WhenBlitterIsSelectedButBlitCopyFailsThenFallback srcData[i] = i; } MockGraphicsAllocation graphicsAllocation{destData, sizeof(destData)}; - graphicsAllocation.setAllocationType(AllocationType::bufferHostMemory); + auto &productHelper = getHelper(); + graphicsAllocation.setAllocationType(AllocationType::bufferHostMemory, productHelper); auto hwInfo = *defaultHwInfo; hwInfo.capabilityTable.blitterOperationsSupported = false; @@ -3096,14 +3097,15 @@ TEST(MemoryTransferHelperTest, WhenBlitterIsSelectedButBlitCopyFailsThenFallback EXPECT_EQ(0, memcmp(destData, srcData, dataSize)); } -TEST(MemoryTransferHelperTest, givenBlitOperationSupportedWhenBcsEngineNotAvailableThenReturnUnsupported) { +HWTEST_F(MemoryTransferHelperTest, givenBlitOperationSupportedWhenBcsEngineNotAvailableThenReturnUnsupported) { constexpr uint32_t dataSize = 16; uint8_t destData[dataSize] = {}; uint8_t srcData[dataSize] = {}; MockGraphicsAllocation graphicsAllocation{destData, sizeof(destData)}; graphicsAllocation.storageInfo.memoryBanks = 1; - graphicsAllocation.setAllocationType(AllocationType::buffer); + auto &productHelper = getHelper(); + graphicsAllocation.setAllocationType(AllocationType::buffer, productHelper); auto hwInfo = *defaultHwInfo; hwInfo.capabilityTable.blitterOperationsSupported = true; diff --git a/shared/test/unit_test/os_interface/aub_memory_operations_handler_tests.cpp b/shared/test/unit_test/os_interface/aub_memory_operations_handler_tests.cpp index a6c7ab8710..f560a5ddcb 100644 --- a/shared/test/unit_test/os_interface/aub_memory_operations_handler_tests.cpp +++ b/shared/test/unit_test/os_interface/aub_memory_operations_handler_tests.cpp @@ -75,7 +75,8 @@ TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerWhenCallingLockThenTrueRe TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerAndAllocationOfOneTimeAubWritableAllocationTypeWhenMakeResidentCalledTwoTimesThenWriteMemoryOnce) { ASSERT_TRUE(AubHelper::isOneTimeAubWritableAllocationType(AllocationType::buffer)); - allocPtr->setAllocationType(AllocationType::buffer); + auto &productHelper = device->getProductHelper(); + allocPtr->setAllocationType(AllocationType::buffer, productHelper); MockAubManager aubManager; getMemoryOperationsHandler()->setAubManager(&aubManager); diff --git a/shared/test/unit_test/os_interface/product_helper_tests.cpp b/shared/test/unit_test/os_interface/product_helper_tests.cpp index 1aa29c90ab..ddd6abf23e 100644 --- a/shared/test/unit_test/os_interface/product_helper_tests.cpp +++ b/shared/test/unit_test/os_interface/product_helper_tests.cpp @@ -524,7 +524,7 @@ HWTEST_F(ProductHelperTest, givenLockableAllocationWhenGettingIsBlitCopyRequired pInHwInfo.capabilityTable.blitterOperationsSupported = true; MockGraphicsAllocation graphicsAllocation; - graphicsAllocation.setAllocationType(AllocationType::bufferHostMemory); + graphicsAllocation.setAllocationType(AllocationType::bufferHostMemory, *productHelper); EXPECT_TRUE(GraphicsAllocation::isLockable(graphicsAllocation.getAllocationType())); graphicsAllocation.overrideMemoryPool(MemoryPool::localMemory); @@ -556,7 +556,7 @@ HWTEST_F(ProductHelperTest, givenNotLockableAllocationWhenGettingIsBlitCopyRequi hwInfo.capabilityTable.blitterOperationsSupported = true; MockGraphicsAllocation graphicsAllocation; - graphicsAllocation.setAllocationType(AllocationType::svmGpu); + graphicsAllocation.setAllocationType(AllocationType::svmGpu, *productHelper); EXPECT_FALSE(GraphicsAllocation::isLockable(graphicsAllocation.getAllocationType())); graphicsAllocation.overrideMemoryPool(MemoryPool::localMemory); @@ -596,7 +596,7 @@ HWTEST2_F(ProductHelperTest, givenProductHelperWhenGettingIsBlitCopyRequiredForL MockGraphicsAllocation graphicsAllocation; graphicsAllocation.overrideMemoryPool(MemoryPool::localMemory); - graphicsAllocation.setAllocationType(AllocationType::bufferHostMemory); + graphicsAllocation.setAllocationType(AllocationType::bufferHostMemory, *productHelper); EXPECT_FALSE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation)); } diff --git a/shared/test/unit_test/os_interface/windows/file_logger_win_tests.cpp b/shared/test/unit_test/os_interface/windows/file_logger_win_tests.cpp index 5b30b65471..2469002acf 100644 --- a/shared/test/unit_test/os_interface/windows/file_logger_win_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/file_logger_win_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2023 Intel Corporation + * Copyright (C) 2019-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -22,6 +22,7 @@ TEST_F(FileLoggerTests, GivenLogAllocationMemoryPoolFlagThenLogsCorrectInfo) { DebugVariables flags; flags.LogAllocationMemoryPool.set(true); FullyEnabledFileLogger fileLogger(testFile, flags); + auto &productHelper = executionEnvironment->rootDeviceEnvironments[0]->getProductHelper(); // Log file not created bool logFileCreated = fileExists(fileLogger.getLogFileName()); @@ -29,7 +30,7 @@ TEST_F(FileLoggerTests, GivenLogAllocationMemoryPoolFlagThenLogsCorrectInfo) { MockWddmAllocation allocation(getGmmHelper()); allocation.handle = 4; - allocation.setAllocationType(AllocationType::buffer); + allocation.setAllocationType(AllocationType::buffer, productHelper); allocation.memoryPool = MemoryPool::system64KBPages; allocation.getDefaultGmm()->resourceParams.Flags.Info.NonLocalOnly = 0; allocation.setGpuAddress(0x12345); @@ -66,6 +67,7 @@ TEST_F(FileLoggerTests, GivenLogAllocationMemoryPoolFlagSetFalseThenAllocationIs DebugVariables flags; flags.LogAllocationMemoryPool.set(false); FullyEnabledFileLogger fileLogger(testFile, flags); + auto &productHelper = executionEnvironment->rootDeviceEnvironments[0]->getProductHelper(); // Log file not created bool logFileCreated = fileExists(fileLogger.getLogFileName()); @@ -75,7 +77,7 @@ TEST_F(FileLoggerTests, GivenLogAllocationMemoryPoolFlagSetFalseThenAllocationIs executionEnvironment->rootDeviceEnvironments[0]->initGmm(); MockWddmAllocation allocation(executionEnvironment->rootDeviceEnvironments[0]->getGmmHelper()); allocation.handle = 4; - allocation.setAllocationType(AllocationType::buffer); + allocation.setAllocationType(AllocationType::buffer, productHelper); allocation.memoryPool = MemoryPool::system64KBPages; allocation.getDefaultGmm()->resourceParams.Flags.Info.NonLocalOnly = 0; diff --git a/shared/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp b/shared/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp index bf398d693c..dfceccfc5f 100644 --- a/shared/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp @@ -1415,7 +1415,7 @@ TEST_F(WddmMemoryManagerSimpleTest, whenDestroyingAllocationWithReservedGpuVirtu TEST_F(WddmMemoryManagerSimpleTest, givenAllocationWithReservedGpuVirtualAddressWhenMapCallFailsDuringCreateWddmAllocationThenReleasePreferredAddress) { MockWddmAllocation allocation(rootDeviceEnvironment->getGmmHelper(), 1); - allocation.setAllocationType(AllocationType::kernelIsa); + allocation.setAllocationType(AllocationType::kernelIsa, csr->getProductHelper()); uint64_t gpuAddress = 0x123; uint64_t sizeForFree = 0x1234; allocation.setReservedGpuVirtualAddress(gpuAddress); @@ -1437,7 +1437,8 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMultiHandleAllocationAndPreferredGpuVaI uint32_t numGmms = 10; MockWddmAllocation allocation(rootDeviceEnvironment->getGmmHelper(), numGmms); - allocation.setAllocationType(AllocationType::buffer); + + allocation.setAllocationType(AllocationType::buffer, csr->getProductHelper()); allocation.storageInfo.multiStorage = true; wddm->callBaseMapGpuVa = true; @@ -1464,7 +1465,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMultiHandleAllocationWhenCreatePhysical uint32_t numGmms = 10; MockWddmAllocation allocation(rootDeviceEnvironment->getGmmHelper(), numGmms); - allocation.setAllocationType(AllocationType::buffer); + allocation.setAllocationType(AllocationType::buffer, csr->getProductHelper()); allocation.storageInfo.multiStorage = true; wddm->callBaseMapGpuVa = true; @@ -1482,7 +1483,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMultiHandleAllocationWhenCreatePhysical uint32_t numGmms = 10; MockWddmAllocation allocation(rootDeviceEnvironment->getGmmHelper(), numGmms); - allocation.setAllocationType(AllocationType::buffer); + allocation.setAllocationType(AllocationType::buffer, csr->getProductHelper()); allocation.storageInfo.multiStorage = true; wddm->callBaseMapGpuVa = true; diff --git a/shared/test/unit_test/utilities/logger_tests.cpp b/shared/test/unit_test/utilities/logger_tests.cpp index 773a6d7eb9..495bf0de81 100644 --- a/shared/test/unit_test/utilities/logger_tests.cpp +++ b/shared/test/unit_test/utilities/logger_tests.cpp @@ -11,8 +11,10 @@ #include "shared/source/memory_manager/memory_manager.h" #include "shared/source/memory_manager/memory_pool.h" #include "shared/source/utilities/logger.h" +#include "shared/test/common/fixtures/device_fixture.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/gtest_helpers.h" +#include "shared/test/common/test_macros/hw_test.h" #include "shared/test/common/utilities/base_object_utils.h" #include "gtest/gtest.h" @@ -493,16 +495,17 @@ TEST(AllocationTypeLoggingSingle, givenGraphicsAllocationTypeWhenConvertingToStr EXPECT_STREQ(result, "ILLEGAL_VALUE"); } - -TEST(AllocationTypeLoggingSingle, givenAllocationTypeWhenConvertingToStringThenSupportAll) { +using AllocationTypeLoggingSingleTest = Test; +HWTEST_F(AllocationTypeLoggingSingleTest, givenAllocationTypeWhenConvertingToStringThenSupportAll) { std::string testFile = "testfile"; DebugVariables flags; FullyEnabledFileLogger fileLogger(testFile, flags); GraphicsAllocation graphicsAllocation(0, 1u /*num gmms*/, AllocationType::unknown, nullptr, 0, 0, MemoryPool::memoryNull, MemoryManager::maxOsContextCount, 0llu); + auto &productHelper = getHelper(); for (uint32_t i = 0; i < static_cast(AllocationType::count); i++) { - graphicsAllocation.setAllocationType(static_cast(i)); + graphicsAllocation.setAllocationType(static_cast(i), productHelper); auto result = getAllocationTypeString(&graphicsAllocation); diff --git a/shared/test/unit_test/xe2_hpg_core/gfx_core_helper_tests_xe2_hpg_core.cpp b/shared/test/unit_test/xe2_hpg_core/gfx_core_helper_tests_xe2_hpg_core.cpp index 07828a4e28..91e353f2c5 100644 --- a/shared/test/unit_test/xe2_hpg_core/gfx_core_helper_tests_xe2_hpg_core.cpp +++ b/shared/test/unit_test/xe2_hpg_core/gfx_core_helper_tests_xe2_hpg_core.cpp @@ -517,7 +517,7 @@ XE2_HPG_CORETEST_F(ProductHelperTestXe2HpgCore, givenProductHelperWhenGettingIsB auto &productHelper = getHelper(); MockGraphicsAllocation allocation; allocation.overrideMemoryPool(MemoryPool::localMemory); - allocation.setAllocationType(AllocationType::bufferHostMemory); + allocation.setAllocationType(AllocationType::bufferHostMemory, productHelper); EXPECT_FALSE(productHelper.isBlitCopyRequiredForLocalMemory(pDevice->getRootDeviceEnvironment(), allocation)); } diff --git a/shared/test/unit_test/xe_hpc_core/pvc/engine_node_helper_tests_pvc.cpp b/shared/test/unit_test/xe_hpc_core/pvc/engine_node_helper_tests_pvc.cpp index 2d82d3ca7b..793f8b6b23 100644 --- a/shared/test/unit_test/xe_hpc_core/pvc/engine_node_helper_tests_pvc.cpp +++ b/shared/test/unit_test/xe_hpc_core/pvc/engine_node_helper_tests_pvc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2023 Intel Corporation + * Copyright (C) 2021-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -590,7 +590,7 @@ PVCTEST_F(EngineNodeHelperPvcTests, givenNonTile0AccessWhenGettingIsBlitCopyRequ auto &productHelper = getHelper(); hwInfo.capabilityTable.blitterOperationsSupported = true; MockGraphicsAllocation graphicsAllocation; - graphicsAllocation.setAllocationType(AllocationType::bufferHostMemory); + graphicsAllocation.setAllocationType(AllocationType::bufferHostMemory, productHelper); EXPECT_TRUE(GraphicsAllocation::isLockable(graphicsAllocation.getAllocationType())); graphicsAllocation.overrideMemoryPool(MemoryPool::localMemory); hwInfo.platform.usRevId = 0u;