mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Enable blit operation on enqueue copy buffer
Change-Id: Ie9571344a9b1e2a783c59955a68094f2868f36ee Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
61e91a376b
commit
08ceaf432a
@@ -155,7 +155,7 @@ HWTEST_F(DispatchFlagsTests, givenBlitEnqueueWhenDispatchingCommandsWithoutKerne
|
||||
|
||||
mockCmdQ->obtainNewTimestampPacketNodes(1, timestampPacketDependencies.previousEnqueueNodes, true);
|
||||
BlitProperties blitProperties = mockCmdQ->processDispatchForBlitEnqueue(multiDispatchInfo, timestampPacketDependencies,
|
||||
eventsRequest, mockCmdQ->getCS(0), 0, false);
|
||||
eventsRequest, mockCmdQ->getCS(0), CL_COMMAND_READ_BUFFER, false);
|
||||
|
||||
BlitPropertiesContainer blitPropertiesContainer;
|
||||
blitPropertiesContainer.push_back(blitProperties);
|
||||
@@ -194,7 +194,7 @@ HWTEST_F(DispatchFlagsTests, givenN1EnabledWhenDispatchingWithoutKernelTheAllowO
|
||||
|
||||
mockCmdQ->obtainNewTimestampPacketNodes(1, timestampPacketDependencies.previousEnqueueNodes, true);
|
||||
BlitProperties blitProperties = mockCmdQ->processDispatchForBlitEnqueue(multiDispatchInfo, timestampPacketDependencies,
|
||||
eventsRequest, mockCmdQ->getCS(0), 0, false);
|
||||
eventsRequest, mockCmdQ->getCS(0), CL_COMMAND_READ_BUFFER, false);
|
||||
BlitPropertiesContainer blitPropertiesContainer;
|
||||
blitPropertiesContainer.push_back(blitProperties);
|
||||
EnqueueProperties enqueueProperties(true, false, false, false, &blitPropertiesContainer);
|
||||
|
||||
@@ -855,8 +855,8 @@ HWTEST_F(BcsTests, givenMapAllocationInBuiltinOpParamsWhenConstructingThenUseItA
|
||||
builtinOpParams.size.x = 1;
|
||||
builtinOpParams.transferAllocation = mapAllocation;
|
||||
|
||||
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
|
||||
csr, builtinOpParams);
|
||||
auto blitProperties = BlitProperties::constructProperties(BlitterConstants::BlitDirection::HostPtrToBuffer,
|
||||
csr, builtinOpParams);
|
||||
EXPECT_EQ(mapAllocation, blitProperties.srcAllocation);
|
||||
}
|
||||
{
|
||||
@@ -867,8 +867,8 @@ HWTEST_F(BcsTests, givenMapAllocationInBuiltinOpParamsWhenConstructingThenUseItA
|
||||
builtinOpParams.size.x = 1;
|
||||
builtinOpParams.transferAllocation = mapAllocation;
|
||||
|
||||
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::BufferToHostPtr,
|
||||
csr, builtinOpParams);
|
||||
auto blitProperties = BlitProperties::constructProperties(BlitterConstants::BlitDirection::BufferToHostPtr,
|
||||
csr, builtinOpParams);
|
||||
EXPECT_EQ(mapAllocation, blitProperties.dstAllocation);
|
||||
}
|
||||
|
||||
@@ -896,8 +896,8 @@ HWTEST_F(BcsTests, givenNonZeroCopySvmAllocationWhenConstructingBlitPropertiesFo
|
||||
builtinOpParams.srcPtr = reinterpret_cast<void *>(svmData->cpuAllocation->getGpuAddress());
|
||||
builtinOpParams.size.x = 1;
|
||||
|
||||
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
|
||||
csr, builtinOpParams);
|
||||
auto blitProperties = BlitProperties::constructProperties(BlitterConstants::BlitDirection::HostPtrToBuffer,
|
||||
csr, builtinOpParams);
|
||||
EXPECT_EQ(svmData->cpuAllocation, blitProperties.srcAllocation);
|
||||
EXPECT_EQ(svmData->gpuAllocation, blitProperties.dstAllocation);
|
||||
}
|
||||
@@ -909,8 +909,8 @@ HWTEST_F(BcsTests, givenNonZeroCopySvmAllocationWhenConstructingBlitPropertiesFo
|
||||
builtinOpParams.dstPtr = reinterpret_cast<void *>(svmData->cpuAllocation->getGpuAddress());
|
||||
builtinOpParams.size.x = 1;
|
||||
|
||||
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::BufferToHostPtr,
|
||||
csr, builtinOpParams);
|
||||
auto blitProperties = BlitProperties::constructProperties(BlitterConstants::BlitDirection::BufferToHostPtr,
|
||||
csr, builtinOpParams);
|
||||
EXPECT_EQ(svmData->cpuAllocation, blitProperties.dstAllocation);
|
||||
EXPECT_EQ(svmData->gpuAllocation, blitProperties.srcAllocation);
|
||||
}
|
||||
|
||||
@@ -784,64 +784,98 @@ HWTEST_TEMPLATED_F(BcsBufferTests, givenBufferWithInitializationDataAndBcsCsrWhe
|
||||
EXPECT_EQ(1u, bcsCsr->blitBufferCalled);
|
||||
}
|
||||
|
||||
HWTEST_TEMPLATED_F(BcsBufferTests, givenBcsSupportedWhenEnqueueReadWriteBufferIsCalledThenUseBcsCsr) {
|
||||
HWTEST_TEMPLATED_F(BcsBufferTests, givenBcsSupportedWhenEnqueueBufferOperationIsCalledThenUseBcsCsr) {
|
||||
DebugManager.flags.EnableBlitterOperationsForReadWriteBuffers.set(0);
|
||||
auto bcsCsr = static_cast<UltCommandStreamReceiver<FamilyType> *>(commandQueue->getBcsCommandStreamReceiver());
|
||||
|
||||
auto bufferForBlt = clUniquePtr(Buffer::create(bcsMockContext.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
|
||||
bufferForBlt->forceDisallowCPUCopy = true;
|
||||
auto bufferForBlt0 = clUniquePtr(Buffer::create(bcsMockContext.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
|
||||
auto bufferForBlt1 = clUniquePtr(Buffer::create(bcsMockContext.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
|
||||
bufferForBlt0->forceDisallowCPUCopy = true;
|
||||
bufferForBlt1->forceDisallowCPUCopy = true;
|
||||
auto *hwInfo = device->getExecutionEnvironment()->getMutableHardwareInfo();
|
||||
|
||||
DebugManager.flags.EnableBlitterOperationsForReadWriteBuffers.set(0);
|
||||
hwInfo->capabilityTable.blitterOperationsSupported = false;
|
||||
commandQueue->enqueueWriteBuffer(bufferForBlt.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueReadBuffer(bufferForBlt.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueWriteBuffer(bufferForBlt0.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueReadBuffer(bufferForBlt0.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueCopyBuffer(bufferForBlt0.get(), bufferForBlt1.get(), 0, 1, 1, 0, nullptr, nullptr);
|
||||
|
||||
DebugManager.flags.EnableBlitterOperationsForReadWriteBuffers.set(1);
|
||||
hwInfo->capabilityTable.blitterOperationsSupported = false;
|
||||
commandQueue->enqueueWriteBuffer(bufferForBlt.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueReadBuffer(bufferForBlt.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueWriteBuffer(bufferForBlt0.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueReadBuffer(bufferForBlt0.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueCopyBuffer(bufferForBlt0.get(), bufferForBlt1.get(), 0, 1, 1, 0, nullptr, nullptr);
|
||||
|
||||
DebugManager.flags.EnableBlitterOperationsForReadWriteBuffers.set(0);
|
||||
hwInfo->capabilityTable.blitterOperationsSupported = true;
|
||||
commandQueue->enqueueWriteBuffer(bufferForBlt.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueReadBuffer(bufferForBlt.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueWriteBuffer(bufferForBlt0.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueReadBuffer(bufferForBlt0.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueCopyBuffer(bufferForBlt0.get(), bufferForBlt1.get(), 0, 1, 1, 0, nullptr, nullptr);
|
||||
|
||||
DebugManager.flags.EnableBlitterOperationsForReadWriteBuffers.set(-1);
|
||||
hwInfo->capabilityTable.blitterOperationsSupported = true;
|
||||
commandQueue->enqueueWriteBuffer(bufferForBlt.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueReadBuffer(bufferForBlt.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueWriteBuffer(bufferForBlt0.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueReadBuffer(bufferForBlt0.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueCopyBuffer(bufferForBlt0.get(), bufferForBlt1.get(), 0, 1, 1, 0, nullptr, nullptr);
|
||||
|
||||
EXPECT_EQ(2u, bcsCsr->blitBufferCalled);
|
||||
EXPECT_EQ(3u, bcsCsr->blitBufferCalled);
|
||||
|
||||
DebugManager.flags.EnableBlitterOperationsForReadWriteBuffers.set(1);
|
||||
hwInfo->capabilityTable.blitterOperationsSupported = true;
|
||||
commandQueue->enqueueWriteBuffer(bufferForBlt.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(3u, bcsCsr->blitBufferCalled);
|
||||
commandQueue->enqueueReadBuffer(bufferForBlt.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueWriteBuffer(bufferForBlt0.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(4u, bcsCsr->blitBufferCalled);
|
||||
commandQueue->enqueueReadBuffer(bufferForBlt0.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(5u, bcsCsr->blitBufferCalled);
|
||||
commandQueue->enqueueCopyBuffer(bufferForBlt0.get(), bufferForBlt1.get(), 0, 1, 1, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(6u, bcsCsr->blitBufferCalled);
|
||||
}
|
||||
|
||||
HWTEST_TEMPLATED_F(BcsBufferTests, givenBcsSupportedWhenQueueIsBlockedThenDispatchBlitWhenUnblocked) {
|
||||
auto bcsCsr = static_cast<UltCommandStreamReceiver<FamilyType> *>(commandQueue->getBcsCommandStreamReceiver());
|
||||
|
||||
auto bufferForBlt = clUniquePtr(Buffer::create(bcsMockContext.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
|
||||
bufferForBlt->forceDisallowCPUCopy = true;
|
||||
auto bufferForBlt0 = clUniquePtr(Buffer::create(bcsMockContext.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
|
||||
auto bufferForBlt1 = clUniquePtr(Buffer::create(bcsMockContext.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
|
||||
bufferForBlt0->forceDisallowCPUCopy = true;
|
||||
bufferForBlt1->forceDisallowCPUCopy = true;
|
||||
UserEvent userEvent(bcsMockContext.get());
|
||||
cl_event waitlist = &userEvent;
|
||||
|
||||
commandQueue->enqueueWriteBuffer(bufferForBlt.get(), CL_FALSE, 0, 1, &hostPtr, nullptr, 1, &waitlist, nullptr);
|
||||
commandQueue->enqueueReadBuffer(bufferForBlt.get(), CL_FALSE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueWriteBuffer(bufferForBlt0.get(), CL_FALSE, 0, 1, &hostPtr, nullptr, 1, &waitlist, nullptr);
|
||||
commandQueue->enqueueReadBuffer(bufferForBlt1.get(), CL_FALSE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueCopyBuffer(bufferForBlt0.get(), bufferForBlt1.get(), 0, 1, 1, 0, nullptr, nullptr);
|
||||
|
||||
EXPECT_EQ(0u, bcsCsr->blitBufferCalled);
|
||||
|
||||
userEvent.setStatus(CL_COMPLETE);
|
||||
|
||||
EXPECT_EQ(2u, bcsCsr->blitBufferCalled);
|
||||
|
||||
commandQueue->enqueueWriteBuffer(bufferForBlt.get(), CL_FALSE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(3u, bcsCsr->blitBufferCalled);
|
||||
commandQueue->enqueueReadBuffer(bufferForBlt.get(), CL_FALSE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
|
||||
commandQueue->enqueueWriteBuffer(bufferForBlt0.get(), CL_FALSE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(4u, bcsCsr->blitBufferCalled);
|
||||
commandQueue->enqueueReadBuffer(bufferForBlt0.get(), CL_FALSE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(5u, bcsCsr->blitBufferCalled);
|
||||
commandQueue->enqueueCopyBuffer(bufferForBlt0.get(), bufferForBlt1.get(), 0, 1, 1, 0, nullptr, nullptr);
|
||||
}
|
||||
|
||||
HWTEST_TEMPLATED_F(BcsBufferTests, givenBuffersWhenCopyBufferCalledThenUseBcs) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
auto cmdQ = clUniquePtr(new MockCommandQueueHw<FamilyType>(bcsMockContext.get(), device.get(), nullptr));
|
||||
|
||||
auto bufferForBlt0 = clUniquePtr(Buffer::create(bcsMockContext.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
|
||||
auto bufferForBlt1 = clUniquePtr(Buffer::create(bcsMockContext.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
|
||||
bufferForBlt0->forceDisallowCPUCopy = true;
|
||||
bufferForBlt1->forceDisallowCPUCopy = true;
|
||||
|
||||
cmdQ->enqueueCopyBuffer(bufferForBlt0.get(), bufferForBlt1.get(), 0, 0, 1, 0, nullptr, nullptr);
|
||||
|
||||
HardwareParse hwParser;
|
||||
hwParser.parseCommands<FamilyType>(commandQueue->getBcsCommandStreamReceiver()->getCS(0));
|
||||
auto commandItor = find<XY_COPY_BLT *>(hwParser.cmdList.begin(), hwParser.cmdList.end());
|
||||
EXPECT_NE(hwParser.cmdList.end(), commandItor);
|
||||
auto copyBltCmd = genCmdCast<XY_COPY_BLT *>(*commandItor);
|
||||
|
||||
EXPECT_EQ(bufferForBlt0->getGraphicsAllocation()->getGpuAddress(), copyBltCmd->getSourceBaseAddress());
|
||||
EXPECT_EQ(bufferForBlt1->getGraphicsAllocation()->getGpuAddress(), copyBltCmd->getDestinationBaseAddress());
|
||||
}
|
||||
|
||||
HWTEST_TEMPLATED_F(BcsBufferTests, givenBlockedBlitEnqueueWhenUnblockingThenMakeResidentAllTimestampPackets) {
|
||||
@@ -1110,7 +1144,7 @@ HWTEST_TEMPLATED_F(BcsBufferTests, givenPipeControlRequestWhenDispatchingBlocked
|
||||
cmdQ->isQueueBlocked();
|
||||
}
|
||||
|
||||
HWTEST_TEMPLATED_F(BcsBufferTests, givenReadOrWriteBufferOperationWithoutKernelWhenEstimatingCommandsSizeThenReturnCorrectValue) {
|
||||
HWTEST_TEMPLATED_F(BcsBufferTests, givenBufferOperationWithoutKernelWhenEstimatingCommandsSizeThenReturnCorrectValue) {
|
||||
auto cmdQ = clUniquePtr(new MockCommandQueueHw<FamilyType>(bcsMockContext.get(), device.get(), nullptr));
|
||||
CsrDependencies csrDependencies;
|
||||
MultiDispatchInfo multiDispatchInfo;
|
||||
@@ -1119,10 +1153,13 @@ HWTEST_TEMPLATED_F(BcsBufferTests, givenReadOrWriteBufferOperationWithoutKernelW
|
||||
true, *cmdQ, multiDispatchInfo);
|
||||
auto writeBufferCmdsSize = EnqueueOperation<FamilyType>::getTotalSizeRequiredCS(CL_COMMAND_WRITE_BUFFER, csrDependencies, false, false,
|
||||
true, *cmdQ, multiDispatchInfo);
|
||||
auto copyBufferCmdsSize = EnqueueOperation<FamilyType>::getTotalSizeRequiredCS(CL_COMMAND_COPY_BUFFER, csrDependencies, false, false,
|
||||
true, *cmdQ, multiDispatchInfo);
|
||||
auto expectedSize = TimestampPacketHelper::getRequiredCmdStreamSizeForNodeDependency<FamilyType>();
|
||||
|
||||
EXPECT_EQ(expectedSize, readBufferCmdsSize);
|
||||
EXPECT_EQ(expectedSize, writeBufferCmdsSize);
|
||||
EXPECT_EQ(expectedSize, copyBufferCmdsSize);
|
||||
}
|
||||
|
||||
HWTEST_TEMPLATED_F(BcsBufferTests, givenOutputTimestampPacketWhenBlitCalledThenProgramMiFlushDwWithDataWrite) {
|
||||
|
||||
Reference in New Issue
Block a user