mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
Fix a bug with cpu copy and simulation mode.
- if buffer was used on GPU it would be marked as non-updateable from CPU - if we do CPU data transfer from the host, we however need to deliver data to the buffer - in such scenario mark such buffer for update in subsequent submissions. Change-Id: Id3813c4193aa18917de117c61303fd6f62745abb Signed-off-by: Michal Mrozek <michal.mrozek@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
e0dbb03b90
commit
d2df43d169
@@ -85,6 +85,7 @@ void *CommandQueue::cpuDataTransferHandler(TransferProperties &transferPropertie
|
||||
// read/write buffers are always blocking
|
||||
if (!blockQueue || transferProperties.blocking) {
|
||||
err.set(Event::waitForEvents(eventsRequest.numEventsInWaitList, eventsRequest.eventWaitList));
|
||||
bool modifySimulationFlags = false;
|
||||
|
||||
if (outEventObj) {
|
||||
outEventObj->setSubmitTimeStamp();
|
||||
@@ -123,9 +124,7 @@ void *CommandQueue::cpuDataTransferHandler(TransferProperties &transferPropertie
|
||||
eventCompleted = true;
|
||||
}
|
||||
if (!unmapInfo.readOnly) {
|
||||
auto graphicsAllocation = transferProperties.memObj->getGraphicsAllocation();
|
||||
graphicsAllocation->setAubWritable(true, GraphicsAllocation::defaultBank);
|
||||
graphicsAllocation->setTbxWritable(true, GraphicsAllocation::defaultBank);
|
||||
modifySimulationFlags = true;
|
||||
}
|
||||
break;
|
||||
case CL_COMMAND_READ_BUFFER:
|
||||
@@ -135,6 +134,7 @@ void *CommandQueue::cpuDataTransferHandler(TransferProperties &transferPropertie
|
||||
case CL_COMMAND_WRITE_BUFFER:
|
||||
memcpy_s(transferProperties.getCpuPtrForReadWrite(), transferProperties.size[0], transferProperties.ptr, transferProperties.size[0]);
|
||||
eventCompleted = true;
|
||||
modifySimulationFlags = true;
|
||||
break;
|
||||
case CL_COMMAND_MARKER:
|
||||
break;
|
||||
@@ -152,6 +152,11 @@ void *CommandQueue::cpuDataTransferHandler(TransferProperties &transferPropertie
|
||||
outEventObj->updateExecutionStatus();
|
||||
}
|
||||
}
|
||||
if (modifySimulationFlags) {
|
||||
auto graphicsAllocation = transferProperties.memObj->getGraphicsAllocation();
|
||||
graphicsAllocation->setAubWritable(true, GraphicsAllocation::defaultBank);
|
||||
graphicsAllocation->setTbxWritable(true, GraphicsAllocation::defaultBank);
|
||||
}
|
||||
}
|
||||
|
||||
if (context->isProvidingPerformanceHints()) {
|
||||
|
||||
@@ -214,6 +214,28 @@ HWTEST_F(EnqueueUnmapMemObjTest, givenEnqueueUnmapMemObjectWhenNonAubWritableBuf
|
||||
EXPECT_TRUE(buffer->getGraphicsAllocation()->isTbxWritable(GraphicsAllocation::defaultBank));
|
||||
}
|
||||
|
||||
HWTEST_F(EnqueueUnmapMemObjTest, givenWriteBufferIsServicedOnCPUWhenBufferIsNonAubTbxWriteableThanFlagsChange) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.DoCpuCopyOnWriteBuffer.set(true);
|
||||
auto buffer = std::unique_ptr<Buffer>(BufferHelper<>::create());
|
||||
ASSERT_NE(nullptr, buffer);
|
||||
buffer->getGraphicsAllocation()->setAubWritable(false, GraphicsAllocation::defaultBank);
|
||||
buffer->getGraphicsAllocation()->setTbxWritable(false, GraphicsAllocation::defaultBank);
|
||||
|
||||
EXPECT_FALSE(buffer->getGraphicsAllocation()->isAubWritable(GraphicsAllocation::defaultBank));
|
||||
EXPECT_FALSE(buffer->getGraphicsAllocation()->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_TRUE(buffer->getGraphicsAllocation()->isAubWritable(GraphicsAllocation::defaultBank));
|
||||
EXPECT_TRUE(buffer->getGraphicsAllocation()->isTbxWritable(GraphicsAllocation::defaultBank));
|
||||
}
|
||||
|
||||
HWTEST_F(EnqueueUnmapMemObjTest, givenMemObjWhenUnmappingThenSetAubWritableBeforeEnqueueWrite) {
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.DisableZeroCopyForBuffers.set(true);
|
||||
|
||||
Reference in New Issue
Block a user