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 <katarzyna.cencelewska@intel.com>
This commit is contained in:
Katarzyna Cencelewska 2024-08-23 00:02:44 +00:00 committed by Compute-Runtime-Automation
parent 71c6731287
commit 2e0884a301
35 changed files with 201 additions and 129 deletions

View File

@ -803,7 +803,7 @@ TEST_F(KernelImmutableDataTests, givenInternalModuleWhenKernelIsCreatedThenIsaIs
bool isInternal = true;
std::unique_ptr<MockImmutableData> mockKernelImmData = std::make_unique<MockImmutableData>(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);

View File

@ -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);

View File

@ -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) {

View File

@ -99,7 +99,7 @@ void CompressionXeHPAndLater<testLocalMemory>::givenCompressedBuffersWhenWriting
auto notCompressedBuffer = std::unique_ptr<Buffer>(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);
}

View File

@ -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<GraphicsAllocation>(allocation), TEMPORARY_ALLOCATION);
allocation->setAllocationType(AllocationType::buffer);
allocation->setAllocationType(AllocationType::buffer, csr->getProductHelper());
allocation->setMemObjectsAllocationWithWritableFlags(true);
return allocation;
}

View File

@ -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);
}

View File

@ -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<size_t>(bigSize);
MockBuffer dstBuffer;
dstBuffer.size = static_cast<size_t>(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<size_t>(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<size_t>(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<size_t>(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<size_t>(bigSize);
dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory);
dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory, pDevice->getProductHelper());
std ::unique_ptr<Image> pSrcImage(Image2dHelper<>::create(pContext));
ASSERT_NE(nullptr, pSrcImage.get());
@ -1139,7 +1142,7 @@ HWTEST_F(BuiltInTests, givenBigOffsetAndSizeWhenBuilderCopyImageToLocalBufferSta
MockBuffer dstBuffer;
dstBuffer.size = static_cast<size_t>(bigSize);
dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer);
dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer, pDevice->getProductHelper());
std ::unique_ptr<Image> pSrcImage(Image2dHelper<>::create(pContext));
ASSERT_NE(nullptr, pSrcImage.get());
@ -2468,8 +2471,9 @@ HWTEST2_F(BuiltInTests, whenBuilderCopyBufferToSystemBufferRectStatelessHeapless
MockBuffer dstBuffer;
dstBuffer.size = static_cast<size_t>(bigSize);
srcBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer);
dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory);
const auto &productHelper = pDevice->getRootDeviceEnvironment().getHelper<ProductHelper>();
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<size_t>(bigSize);
MockBuffer dstBuffer;
dstBuffer.size = static_cast<size_t>(bigSize);
srcBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory);
dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer);
const auto &productHelper = pDevice->getRootDeviceEnvironment().getHelper<ProductHelper>();
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<size_t>(bigSize);
MockBuffer dstBuffer;
dstBuffer.size = static_cast<size_t>(bigSize);
srcBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer);
dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory);
const auto &productHelper = pDevice->getRootDeviceEnvironment().getHelper<ProductHelper>();
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<size_t>(bigSize);
MockBuffer dstBuffer;
dstBuffer.size = static_cast<size_t>(bigSize);
srcBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory);
dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer);
const auto &productHelper = pDevice->getRootDeviceEnvironment().getHelper<ProductHelper>();
srcBuffer.mockGfxAllocation.setAllocationType(AllocationType::bufferHostMemory, productHelper);
dstBuffer.mockGfxAllocation.setAllocationType(AllocationType::buffer, productHelper);
BuiltinOpParams dc;
dc.srcMemObj = &srcBuffer;

View File

@ -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();

View File

@ -1442,7 +1442,7 @@ HWTEST_F(CommandQueueHwTest, givenDirectSubmissionAndSharedDisplayableImageWhenR
auto image = std::unique_ptr<Image>(ImageHelper<Image2dDefaults>::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;

View File

@ -1321,7 +1321,7 @@ HWTEST_F(CommandQueueTests, givenEnqueuesForSharedObjectsWithImageWhenUsingShari
auto image = std::unique_ptr<Image>(ImageHelper<Image2dDefaults>::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<Image>(ImageHelper<Image2dDefaults>::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<Buffer>(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;

View File

@ -517,8 +517,9 @@ HWTEST_F(EnqueueSvmMemCopyTest, givenEnqueueSvmMemcpyWhenSvmZeroCopyThenBuiltinK
std::unique_ptr<NEO::BuiltinDispatchInfoBuilder>(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<NEO::BuiltinDispatchInfoBuilder>(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(

View File

@ -275,7 +275,9 @@ HWTEST_F(EnqueueSvmMemFillHwTest, givenEnqueueSVMMemFillWhenUsingCopyBufferToSys
auto cmdQ = std::make_unique<CommandQueueStateless<FamilyType>>(context.get(), device.get());
auto svmData = context->getSVMAllocsManager()->getSVMAlloc(svmPtr);
svmData->size = static_cast<size_t>(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;

View File

@ -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);

View File

@ -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)));
}

View File

@ -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<Gmm>(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;

View File

@ -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;

View File

@ -644,7 +644,7 @@ XE_HPC_CORETEST_F(ProductHelperTestXeHpcCore, givenDefaultProductHelperHwWhenGet
auto &productHelper = getHelper<ProductHelper>();
MockGraphicsAllocation allocation;
allocation.overrideMemoryPool(MemoryPool::localMemory);
allocation.setAllocationType(AllocationType::bufferHostMemory);
allocation.setAllocationType(AllocationType::bufferHostMemory, pDevice->getProductHelper());
EXPECT_FALSE(productHelper.isBlitCopyRequiredForLocalMemory(pDevice->getRootDeviceEnvironment(), allocation));
}

View File

@ -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) {}

View File

@ -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();

View File

@ -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);
}
}

View File

@ -36,6 +36,7 @@ class Gmm;
class MemoryManager;
class CommandStreamReceiver;
class GraphicsAllocation;
class ProductHelper;
struct AllocationProperties;
@ -150,7 +151,7 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
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; }

View File

@ -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));

View File

@ -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));

View File

@ -272,6 +272,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenNoCpuPtrAndNotLockableAllocationWhe
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
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();

View File

@ -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<ProductHelper>();
mockAllocation.setAllocationType(AllocationType::kernelIsa, productHelper);
csr.useNewResourceImplicitFlush = true;
csr.newResources = false;

View File

@ -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<DeviceFixture>;
HWTEST_F(GraphicsAllocationSetAllocationTypeTest, givenAnotherAllocationTypeWhenCalSetAllocationTypeThenUsageAndCacheableAreSetCorrectly) {
MockGraphicsAllocation graphicsAllocation;
GmmRequirements gmmRequirements{};
auto gmm = std::unique_ptr<Gmm>(new Gmm(pDevice->getGmmHelper(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, {}, gmmRequirements));
graphicsAllocation.setDefaultGmm(gmm.get());
auto &productHelper = getHelper<ProductHelper>();
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);
}

View File

@ -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;

View File

@ -3073,8 +3073,8 @@ HWTEST_F(MemoryAllocatorTest, givenUseLocalPreferredForCacheableBuffersAndCompre
EXPECT_EQ(false, allocData.storageInfo.systemMemoryForced);
}
}
TEST(MemoryTransferHelperTest, WhenBlitterIsSelectedButBlitCopyFailsThenFallbackToCopyOnCPU) {
using MemoryTransferHelperTest = Test<DeviceFixture>;
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<ProductHelper>();
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<ProductHelper>();
graphicsAllocation.setAllocationType(AllocationType::buffer, productHelper);
auto hwInfo = *defaultHwInfo;
hwInfo.capabilityTable.blitterOperationsSupported = true;

View File

@ -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);

View File

@ -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));
}

View File

@ -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;

View File

@ -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;

View File

@ -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<DeviceFixture>;
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<NEO::ProductHelper>();
for (uint32_t i = 0; i < static_cast<uint32_t>(AllocationType::count); i++) {
graphicsAllocation.setAllocationType(static_cast<AllocationType>(i));
graphicsAllocation.setAllocationType(static_cast<AllocationType>(i), productHelper);
auto result = getAllocationTypeString(&graphicsAllocation);

View File

@ -517,7 +517,7 @@ XE2_HPG_CORETEST_F(ProductHelperTestXe2HpgCore, givenProductHelperWhenGettingIsB
auto &productHelper = getHelper<ProductHelper>();
MockGraphicsAllocation allocation;
allocation.overrideMemoryPool(MemoryPool::localMemory);
allocation.setAllocationType(AllocationType::bufferHostMemory);
allocation.setAllocationType(AllocationType::bufferHostMemory, productHelper);
EXPECT_FALSE(productHelper.isBlitCopyRequiredForLocalMemory(pDevice->getRootDeviceEnvironment(), allocation));
}

View File

@ -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<ProductHelper>();
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;