Pass root device index to Buffer::getGraphicsAllocation

Related-To: NEO-4672
Change-Id: I652a818a93b350670c8bccec023e57d1dddb6c0e
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2020-06-08 15:28:06 +02:00
committed by sys_ocldev
parent e286ada6b5
commit d9cc640986
21 changed files with 101 additions and 93 deletions

View File

@@ -607,7 +607,7 @@ HWTEST_F(EnqueueReadBufferTypeTest, gicenEnqueueReadBufferCalledWhenLockedPtrInT
ctx.memoryManager = &memoryManager;
auto mockCmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(context, pClDevice, nullptr);
std::unique_ptr<Buffer> buffer(Buffer::create(&ctx, 0, 1, nullptr, retVal));
static_cast<MemoryAllocation *>(buffer->getGraphicsAllocation())->overrideMemoryPool(MemoryPool::System4KBPages);
static_cast<MemoryAllocation *>(buffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()))->overrideMemoryPool(MemoryPool::System4KBPages);
void *ptr = nonZeroCopyBuffer->getCpuAddressForMemoryTransfer();
retVal = mockCmdQ->enqueueReadBuffer(buffer.get(),
@@ -628,7 +628,7 @@ HWTEST_F(EnqueueReadBufferTypeTest, givenEnqueueReadBufferBlockingWhenAUBDumpAll
DebugManagerStateRestore dbgRestore;
DebugManager.flags.AUBDumpAllocsOnEnqueueReadOnly.set(true);
ASSERT_FALSE(srcBuffer->getGraphicsAllocation()->isAllocDumpable());
ASSERT_FALSE(srcBuffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex())->isAllocDumpable());
cl_int retVal = CL_SUCCESS;
void *ptr = nonZeroCopyBuffer->getCpuAddressForMemoryTransfer();
retVal = pCmdQ->enqueueReadBuffer(srcBuffer.get(),
@@ -642,7 +642,7 @@ HWTEST_F(EnqueueReadBufferTypeTest, givenEnqueueReadBufferBlockingWhenAUBDumpAll
nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(srcBuffer->getGraphicsAllocation()->isAllocDumpable());
EXPECT_TRUE(srcBuffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex())->isAllocDumpable());
EXPECT_TRUE(srcBuffer->forceDisallowCPUCopy);
}
@@ -650,7 +650,7 @@ HWTEST_F(EnqueueReadBufferTypeTest, givenEnqueueReadBufferNonBlockingWhenAUBDump
DebugManagerStateRestore dbgRestore;
DebugManager.flags.AUBDumpAllocsOnEnqueueReadOnly.set(true);
ASSERT_FALSE(srcBuffer->getGraphicsAllocation()->isAllocDumpable());
ASSERT_FALSE(srcBuffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex())->isAllocDumpable());
cl_int retVal = CL_SUCCESS;
void *ptr = nonZeroCopyBuffer->getCpuAddressForMemoryTransfer();
retVal = pCmdQ->enqueueReadBuffer(srcBuffer.get(),
@@ -664,7 +664,7 @@ HWTEST_F(EnqueueReadBufferTypeTest, givenEnqueueReadBufferNonBlockingWhenAUBDump
nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_FALSE(srcBuffer->getGraphicsAllocation()->isAllocDumpable());
EXPECT_FALSE(srcBuffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex())->isAllocDumpable());
EXPECT_FALSE(srcBuffer->forceDisallowCPUCopy);
}

View File

@@ -197,8 +197,9 @@ TEST_F(EnqueueUnmapMemObjTest, WhenUnmappingMemoryObjectThenWaitEventIsUpdated)
HWTEST_F(EnqueueUnmapMemObjTest, givenEnqueueUnmapMemObjectWhenNonAubWritableBufferObjectMappedToHostPtrForWritingThenItShouldBeResetToAubAndTbxWritable) {
auto buffer = std::unique_ptr<Buffer>(BufferHelper<>::create());
ASSERT_NE(nullptr, buffer);
buffer->getGraphicsAllocation()->setAubWritable(false, GraphicsAllocation::defaultBank);
buffer->getGraphicsAllocation()->setTbxWritable(false, GraphicsAllocation::defaultBank);
auto graphicsAllocation = buffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex());
graphicsAllocation->setAubWritable(false, GraphicsAllocation::defaultBank);
graphicsAllocation->setTbxWritable(false, GraphicsAllocation::defaultBank);
auto mappedForWritingPtr = pCmdQ->enqueueMapBuffer(buffer.get(), CL_TRUE, CL_MAP_WRITE, 0, 8, 0, nullptr, nullptr, retVal);
ASSERT_NE(nullptr, mappedForWritingPtr);
@@ -211,8 +212,8 @@ HWTEST_F(EnqueueUnmapMemObjTest, givenEnqueueUnmapMemObjectWhenNonAubWritableBuf
nullptr);
ASSERT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(buffer->getGraphicsAllocation()->isAubWritable(GraphicsAllocation::defaultBank));
EXPECT_TRUE(buffer->getGraphicsAllocation()->isTbxWritable(GraphicsAllocation::defaultBank));
EXPECT_TRUE(graphicsAllocation->isAubWritable(GraphicsAllocation::defaultBank));
EXPECT_TRUE(graphicsAllocation->isTbxWritable(GraphicsAllocation::defaultBank));
}
HWTEST_F(EnqueueUnmapMemObjTest, givenWriteBufferIsServicedOnCPUWhenBufferIsNonAubTbxWriteableThanFlagsChange) {
@@ -220,21 +221,22 @@ HWTEST_F(EnqueueUnmapMemObjTest, givenWriteBufferIsServicedOnCPUWhenBufferIsNonA
DebugManager.flags.DoCpuCopyOnWriteBuffer.set(1);
auto buffer = std::unique_ptr<Buffer>(BufferHelper<>::create());
ASSERT_NE(nullptr, buffer);
buffer->getGraphicsAllocation()->setAubWritable(false, GraphicsAllocation::defaultBank);
buffer->getGraphicsAllocation()->setTbxWritable(false, GraphicsAllocation::defaultBank);
auto graphicsAllocation = buffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex());
graphicsAllocation->setAubWritable(false, GraphicsAllocation::defaultBank);
graphicsAllocation->setTbxWritable(false, GraphicsAllocation::defaultBank);
EXPECT_FALSE(buffer->getGraphicsAllocation()->isAubWritable(GraphicsAllocation::defaultBank));
EXPECT_FALSE(buffer->getGraphicsAllocation()->isTbxWritable(GraphicsAllocation::defaultBank));
EXPECT_FALSE(graphicsAllocation->isAubWritable(GraphicsAllocation::defaultBank));
EXPECT_FALSE(graphicsAllocation->isTbxWritable(GraphicsAllocation::defaultBank));
auto ptr = allocateAlignedMemory(buffer->getSize(), MemoryConstants::cacheLineSize);
retVal = pCmdQ->enqueueWriteBuffer(buffer.get(), true, 0u, buffer->getSize(), ptr.get(), nullptr, 0u, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(0, memcmp(ptr.get(), buffer->getGraphicsAllocation()->getUnderlyingBuffer(), buffer->getSize()));
EXPECT_EQ(0, memcmp(ptr.get(), graphicsAllocation->getUnderlyingBuffer(), buffer->getSize()));
EXPECT_TRUE(buffer->getGraphicsAllocation()->isAubWritable(GraphicsAllocation::defaultBank));
EXPECT_TRUE(buffer->getGraphicsAllocation()->isTbxWritable(GraphicsAllocation::defaultBank));
EXPECT_TRUE(graphicsAllocation->isAubWritable(GraphicsAllocation::defaultBank));
EXPECT_TRUE(graphicsAllocation->isTbxWritable(GraphicsAllocation::defaultBank));
}
HWTEST_F(EnqueueUnmapMemObjTest, givenMemObjWhenUnmappingThenSetAubWritableBeforeEnqueueWrite) {

View File

@@ -383,7 +383,7 @@ HWTEST_F(EnqueueWriteBufferTypeTest, givenEnqueueWriteBufferCalledWhenLockedPtrI
ctx.memoryManager = &memoryManager;
auto mockCmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(context, pClDevice, nullptr);
std::unique_ptr<Buffer> buffer(Buffer::create(&ctx, 0, 1, nullptr, retVal));
static_cast<MemoryAllocation *>(buffer->getGraphicsAllocation())->overrideMemoryPool(MemoryPool::SystemCpuInaccessible);
static_cast<MemoryAllocation *>(buffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()))->overrideMemoryPool(MemoryPool::SystemCpuInaccessible);
void *ptr = srcBuffer->getCpuAddressForMemoryTransfer();
retVal = mockCmdQ->enqueueWriteBuffer(buffer.get(),
@@ -411,9 +411,11 @@ HWTEST_F(EnqueueWriteBufferTypeTest, givenForcedCpuCopyWhenEnqueueWriteCompresse
ctx.memoryManager = &memoryManager;
auto mockCmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(context, pClDevice, nullptr);
std::unique_ptr<Buffer> buffer(Buffer::create(&ctx, 0, 1, nullptr, retVal));
static_cast<MemoryAllocation *>(buffer->getGraphicsAllocation())->overrideMemoryPool(MemoryPool::SystemCpuInaccessible);
auto allocation = static_cast<MemoryAllocation *>(buffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()));
allocation->overrideMemoryPool(MemoryPool::SystemCpuInaccessible);
void *ptr = srcBuffer->getCpuAddressForMemoryTransfer();
buffer->getGraphicsAllocation()->setAllocationType(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
allocation->setAllocationType(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
retVal = mockCmdQ->enqueueWriteBuffer(buffer.get(),
CL_FALSE,
@@ -426,10 +428,10 @@ HWTEST_F(EnqueueWriteBufferTypeTest, givenForcedCpuCopyWhenEnqueueWriteCompresse
nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_FALSE(buffer->getGraphicsAllocation()->isLocked());
EXPECT_FALSE(allocation->isLocked());
EXPECT_FALSE(mockCmdQ->cpuDataTransferHandlerCalled);
buffer->getGraphicsAllocation()->setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
allocation->setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
retVal = mockCmdQ->enqueueWriteBuffer(buffer.get(),
CL_FALSE,
@@ -442,7 +444,7 @@ HWTEST_F(EnqueueWriteBufferTypeTest, givenForcedCpuCopyWhenEnqueueWriteCompresse
nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(buffer->getGraphicsAllocation()->isLocked());
EXPECT_TRUE(allocation->isLocked());
EXPECT_TRUE(mockCmdQ->cpuDataTransferHandlerCalled);
}
@@ -457,7 +459,7 @@ HWTEST_F(EnqueueWriteBufferTypeTest, givenEnqueueWriteBufferCalledWhenLockedPtrI
ctx.memoryManager = &memoryManager;
auto mockCmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(context, pClDevice, nullptr);
std::unique_ptr<Buffer> buffer(Buffer::create(&ctx, 0, 1, nullptr, retVal));
static_cast<MemoryAllocation *>(buffer->getGraphicsAllocation())->overrideMemoryPool(MemoryPool::System4KBPages);
static_cast<MemoryAllocation *>(buffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()))->overrideMemoryPool(MemoryPool::System4KBPages);
void *ptr = srcBuffer->getCpuAddressForMemoryTransfer();
retVal = mockCmdQ->enqueueWriteBuffer(buffer.get(),