Skip to content

Commit 87596d2

Browse files
Use root device index when accessing graphics allocation from buffer
Related-To: NEO-4672 Change-Id: I31ed0aa567276b606f4b09733ca2a8d678f9786f Signed-off-by: Mateusz Jablonski <[email protected]>
1 parent 9e8945c commit 87596d2

27 files changed

+256
-230
lines changed

opencl/test/unit_test/aub_tests/command_queue/enqueue_kernel_aub_tests.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -909,11 +909,11 @@ HWTEST2_F(AUBBindlessKernel, givenBindlessCopyKernelWhenEnqueuedThenResultsValid
909909

910910
auto simulatedCsr = AUBFixture::getSimulatedCsr<FamilyType>();
911911

912-
memcpy(pBufferSrc->getGraphicsAllocation()->getUnderlyingBuffer(), bufferDataSrc, bufferSize);
913-
memcpy(pBufferDst->getGraphicsAllocation()->getUnderlyingBuffer(), bufferDataDst, bufferSize);
912+
memcpy(pBufferSrc->getGraphicsAllocation(device->getRootDeviceIndex())->getUnderlyingBuffer(), bufferDataSrc, bufferSize);
913+
memcpy(pBufferDst->getGraphicsAllocation(device->getRootDeviceIndex())->getUnderlyingBuffer(), bufferDataDst, bufferSize);
914914

915-
simulatedCsr->writeMemory(*pBufferSrc->getGraphicsAllocation());
916-
simulatedCsr->writeMemory(*pBufferDst->getGraphicsAllocation());
915+
simulatedCsr->writeMemory(*pBufferSrc->getGraphicsAllocation(device->getRootDeviceIndex()));
916+
simulatedCsr->writeMemory(*pBufferDst->getGraphicsAllocation(device->getRootDeviceIndex()));
917917

918918
//Src
919919
kernel->setArg(0, pBufferSrc.get());
@@ -948,7 +948,7 @@ HWTEST2_F(AUBBindlessKernel, givenBindlessCopyKernelWhenEnqueuedThenResultsValid
948948
EXPECT_TRUE(this->kernel->getKernelInfo().kernelArgInfo[0].pureStatefulBufferAccess);
949949

950950
this->pCmdQ->finish();
951-
expectMemory<FamilyType>(reinterpret_cast<void *>(pBufferDst->getGraphicsAllocation()->getGpuAddress()),
951+
expectMemory<FamilyType>(reinterpret_cast<void *>(pBufferDst->getGraphicsAllocation(device->getRootDeviceIndex())->getGpuAddress()),
952952
bufferDataSrc, bufferSize);
953953
}
954954

@@ -1012,13 +1012,13 @@ HWTEST2_F(AUBBindlessKernel, DISABLED_givenBindlessCopyImageKernelWhenEnqueuedTh
10121012
retVal));
10131013
ASSERT_NE(nullptr, bufferSrc);
10141014

1015-
memcpy(image->getGraphicsAllocation()->getUnderlyingBuffer(), imageDataDst, imageSize);
1016-
memcpy(bufferSrc->getGraphicsAllocation()->getUnderlyingBuffer(), imageDataSrc, imageSize);
1015+
memcpy(image->getGraphicsAllocation(device->getRootDeviceIndex())->getUnderlyingBuffer(), imageDataDst, imageSize);
1016+
memcpy(bufferSrc->getGraphicsAllocation(device->getRootDeviceIndex())->getUnderlyingBuffer(), imageDataSrc, imageSize);
10171017

10181018
auto simulatedCsr = AUBFixture::getSimulatedCsr<FamilyType>();
10191019

1020-
simulatedCsr->writeMemory(*bufferSrc->getGraphicsAllocation());
1021-
simulatedCsr->writeMemory(*image->getGraphicsAllocation());
1020+
simulatedCsr->writeMemory(*bufferSrc->getGraphicsAllocation(device->getRootDeviceIndex()));
1021+
simulatedCsr->writeMemory(*image->getGraphicsAllocation(device->getRootDeviceIndex()));
10221022

10231023
kernel->setArg(0, bufferSrc.get());
10241024
kernel->setArg(1, image.get());
@@ -1045,6 +1045,6 @@ HWTEST2_F(AUBBindlessKernel, DISABLED_givenBindlessCopyImageKernelWhenEnqueuedTh
10451045
retVal = this->pCmdQ->finish();
10461046
EXPECT_EQ(CL_SUCCESS, retVal);
10471047

1048-
expectMemory<FamilyType>(reinterpret_cast<void *>(image->getGraphicsAllocation()->getGpuAddress()),
1048+
expectMemory<FamilyType>(reinterpret_cast<void *>(image->getGraphicsAllocation(device->getRootDeviceIndex())->getGpuAddress()),
10491049
imageDataSrc, imageSize);
10501050
}

opencl/test/unit_test/aub_tests/command_queue/enqueue_read_buffer_aub_tests.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,22 +116,22 @@ HWTEST_F(AUBReadBuffer, reserveCanonicalGpuAddress) {
116116

117117
cl_float srcMemory[] = {1.0f, 2.0f, 3.0f, 4.0f};
118118
cl_float dstMemory[] = {0.0f, 0.0f, 0.0f, 0.0f};
119-
GraphicsAllocation *srcAlocation = new MockGraphicsAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN,
120-
srcMemory,
121-
0xFFFF800400001000,
122-
0xFFFF800400001000,
123-
sizeof(srcMemory),
124-
MemoryPool::MemoryNull);
119+
GraphicsAllocation *srcAllocation = new MockGraphicsAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN,
120+
srcMemory,
121+
0xFFFF800400001000,
122+
0xFFFF800400001000,
123+
sizeof(srcMemory),
124+
MemoryPool::MemoryNull);
125125

126126
std::unique_ptr<Buffer> srcBuffer(Buffer::createBufferHw(
127127
&context,
128128
MemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, &context.getDevice(0)->getDevice()),
129129
CL_MEM_USE_HOST_PTR,
130130
0,
131131
sizeof(srcMemory),
132-
srcAlocation->getUnderlyingBuffer(),
132+
srcAllocation->getUnderlyingBuffer(),
133133
srcMemory,
134-
srcAlocation,
134+
srcAllocation,
135135
false,
136136
false,
137137
false));

opencl/test/unit_test/command_queue/gl/windows/enqueue_kernel_gl_tests_windows.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ TEST_F(EnqueueKernelTest, givenKernelWithSharedObjArgsWhenEnqueueIsCalledThenRes
3232
pContext->setSharingFunctions(glSharing.sharingFunctions.release());
3333
auto retVal = CL_SUCCESS;
3434
auto sharedBuffer = GlBuffer::createSharedGlBuffer(pContext, CL_MEM_READ_WRITE, 1, &retVal);
35+
auto graphicsAllocation = sharedBuffer->getGraphicsAllocation(pContext->getDevice(0)->getRootDeviceIndex());
3536
auto sharedMem = static_cast<cl_mem>(sharedBuffer);
3637
auto nonSharedMem = static_cast<cl_mem>(nonSharedBuffer);
3738

@@ -45,8 +46,8 @@ TEST_F(EnqueueKernelTest, givenKernelWithSharedObjArgsWhenEnqueueIsCalledThenRes
4546

4647
auto address1 = static_cast<uint64_t>(*pKernelArg);
4748
auto sharedBufferGpuAddress =
48-
pKernel->isBuiltIn ? sharedBuffer->getGraphicsAllocation()->getGpuAddress()
49-
: sharedBuffer->getGraphicsAllocation()->getGpuAddressToPatch();
49+
pKernel->isBuiltIn ? graphicsAllocation->getGpuAddress()
50+
: graphicsAllocation->getGpuAddressToPatch();
5051
EXPECT_EQ(sharedBufferGpuAddress, address1);
5152

5253
// update address
@@ -58,8 +59,8 @@ TEST_F(EnqueueKernelTest, givenKernelWithSharedObjArgsWhenEnqueueIsCalledThenRes
5859
auto address2 = static_cast<uint64_t>(*pKernelArg);
5960
EXPECT_NE(address1, address2);
6061
sharedBufferGpuAddress =
61-
pKernel->isBuiltIn ? sharedBuffer->getGraphicsAllocation()->getGpuAddress()
62-
: sharedBuffer->getGraphicsAllocation()->getGpuAddressToPatch();
62+
pKernel->isBuiltIn ? graphicsAllocation->getGpuAddress()
63+
: graphicsAllocation->getGpuAddressToPatch();
6364
EXPECT_EQ(sharedBufferGpuAddress, address2);
6465

6566
delete sharedBuffer;

opencl/test/unit_test/command_queue/read_write_buffer_cpu_copy.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, givenRenderCompressedGmmWhenAskingForCpuOpe
2222
std::unique_ptr<Buffer> buffer(Buffer::create(context, CL_MEM_READ_WRITE, 1, nullptr, retVal));
2323
auto gmm = new Gmm(pDevice->getGmmClientContext(), nullptr, 1, false);
2424
gmm->isRenderCompressed = false;
25-
buffer->getGraphicsAllocation()->setDefaultGmm(gmm);
26-
auto allocation = buffer->getGraphicsAllocation();
25+
auto allocation = buffer->getGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex());
26+
allocation->setDefaultGmm(gmm);
2727

2828
auto alignedPtr = alignedMalloc(2, MemoryConstants::cacheLineSize);
2929
auto unalignedPtr = ptrOffset(alignedPtr, 1);
@@ -255,7 +255,7 @@ TEST(ReadWriteBufferOnCpu, givenNoHostPtrAndAlignedSizeWhenMemoryAllocationIsInN
255255

256256
EXPECT_TRUE(buffer->isReadWriteOnCpuAllowed());
257257
EXPECT_TRUE(buffer->isReadWriteOnCpuPreffered(reinterpret_cast<void *>(0x1000), MemoryConstants::pageSize));
258-
reinterpret_cast<MemoryAllocation *>(buffer->getGraphicsAllocation())->overrideMemoryPool(MemoryPool::SystemCpuInaccessible);
258+
reinterpret_cast<MemoryAllocation *>(buffer->getGraphicsAllocation(device->getRootDeviceIndex()))->overrideMemoryPool(MemoryPool::SystemCpuInaccessible);
259259
//read write on CPU is allowed, but not preffered. We can access this memory via Lock.
260260
EXPECT_TRUE(buffer->isReadWriteOnCpuAllowed());
261261
EXPECT_FALSE(buffer->isReadWriteOnCpuPreffered(reinterpret_cast<void *>(0x1000), MemoryConstants::pageSize));
@@ -309,7 +309,7 @@ TEST(ReadWriteBufferOnCpu, whenLocalMemoryPoolAllocationIsAskedForPreferenceThen
309309
cl_int retVal = 0;
310310
std::unique_ptr<Buffer> buffer(Buffer::create(&ctx, CL_MEM_READ_WRITE, MemoryConstants::pageSize, nullptr, retVal));
311311
ASSERT_NE(nullptr, buffer.get());
312-
reinterpret_cast<MemoryAllocation *>(buffer->getGraphicsAllocation())->overrideMemoryPool(MemoryPool::LocalMemory);
312+
reinterpret_cast<MemoryAllocation *>(buffer->getGraphicsAllocation(device->getRootDeviceIndex()))->overrideMemoryPool(MemoryPool::LocalMemory);
313313

314314
EXPECT_TRUE(buffer->isReadWriteOnCpuAllowed());
315315
EXPECT_FALSE(buffer->isReadWriteOnCpuPreffered(reinterpret_cast<void *>(0x1000), MemoryConstants::pageSize));

opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_2_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, handleTagAndScratchAllocationsResi
448448
EXPECT_TRUE(commandStreamReceiver->isMadeNonResident(scratchAllocation));
449449
}
450450

451-
HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCommandStreamReceiverWhenFenceAllocationIsRequiredAndFlushTaskIsCalledThenFenceAlocationIsMadeResident) {
451+
HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCommandStreamReceiverWhenFenceAllocationIsRequiredAndFlushTaskIsCalledThenFenceAllocationIsMadeResident) {
452452
RAIIHwHelperFactory<MockHwHelperWithFenceAllocation<FamilyType>> hwHelperBackup{pDevice->getHardwareInfo().platform.eRenderCoreFamily};
453453

454454
auto commandStreamReceiver = new MockCsrHw<FamilyType>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex());

0 commit comments

Comments
 (0)