mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Add Blitter support for WriteBufferRect
Related-To: NEO-4013 Change-Id: I8506e2ba1437399d888cc2c7cbc724c52fe2aa9f Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:

committed by
sys_ocldev

parent
f599773c27
commit
d2508fb501
@ -617,7 +617,8 @@ bool CommandQueue::blitEnqueueAllowed(cl_command_type cmdType) const {
|
||||
}
|
||||
|
||||
bool commandAllowed = (CL_COMMAND_READ_BUFFER == cmdType) || (CL_COMMAND_WRITE_BUFFER == cmdType) ||
|
||||
(CL_COMMAND_COPY_BUFFER == cmdType) || (CL_COMMAND_READ_BUFFER_RECT == cmdType);
|
||||
(CL_COMMAND_COPY_BUFFER == cmdType) || (CL_COMMAND_READ_BUFFER_RECT == cmdType) ||
|
||||
(CL_COMMAND_WRITE_BUFFER_RECT == cmdType);
|
||||
|
||||
return commandAllowed && blitAllowed;
|
||||
}
|
||||
|
@ -34,15 +34,16 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteBufferRect(
|
||||
const cl_event *eventWaitList,
|
||||
cl_event *event) {
|
||||
|
||||
const cl_command_type cmdType = CL_COMMAND_WRITE_BUFFER_RECT;
|
||||
auto isMemTransferNeeded = true;
|
||||
if (buffer->isMemObjZeroCopy()) {
|
||||
size_t bufferOffset;
|
||||
size_t hostOffset;
|
||||
computeOffsetsValueForRectCommands(&bufferOffset, &hostOffset, bufferOrigin, hostOrigin, region, bufferRowPitch, bufferSlicePitch, hostRowPitch, hostSlicePitch);
|
||||
isMemTransferNeeded = buffer->checkIfMemoryTransferIsRequired(bufferOffset, hostOffset, ptr, CL_COMMAND_WRITE_BUFFER_RECT);
|
||||
isMemTransferNeeded = buffer->checkIfMemoryTransferIsRequired(bufferOffset, hostOffset, ptr, cmdType);
|
||||
}
|
||||
if (!isMemTransferNeeded) {
|
||||
return enqueueMarkerForReadWriteOperation(buffer, const_cast<void *>(ptr), CL_COMMAND_WRITE_BUFFER_RECT, blockingWrite,
|
||||
return enqueueMarkerForReadWriteOperation(buffer, const_cast<void *>(ptr), cmdType, blockingWrite,
|
||||
numEventsInWaitList, eventWaitList, event);
|
||||
}
|
||||
|
||||
@ -64,7 +65,8 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteBufferRect(
|
||||
if (region[0] != 0 &&
|
||||
region[1] != 0 &&
|
||||
region[2] != 0) {
|
||||
bool status = getGpgpuCommandStreamReceiver().createAllocationForHostSurface(hostPtrSurf, false);
|
||||
auto &csr = blitEnqueueAllowed(cmdType) ? *getBcsCommandStreamReceiver() : getGpgpuCommandStreamReceiver();
|
||||
bool status = csr.createAllocationForHostSurface(hostPtrSurf, false);
|
||||
if (!status) {
|
||||
return CL_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -80,6 +82,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteBufferRect(
|
||||
dc.srcOffset = hostOrigin;
|
||||
dc.srcOffset.x += srcPtrOffset;
|
||||
dc.dstOffset = bufferOrigin;
|
||||
dc.transferAllocation = hostPtrSurf.getAllocation();
|
||||
dc.size = region;
|
||||
dc.srcRowPitch = hostRowPitch;
|
||||
dc.srcSlicePitch = hostSlicePitch;
|
||||
|
@ -61,7 +61,12 @@ struct ClBlitProperties {
|
||||
gpuAllocation = builtinOpParams.dstMemObj->getGraphicsAllocation();
|
||||
memObjGpuVa = (gpuAllocation->getGpuAddress() + builtinOpParams.dstMemObj->getOffset());
|
||||
}
|
||||
copySize.x = builtinOpParams.size.x;
|
||||
|
||||
hostRowPitch = builtinOpParams.srcRowPitch;
|
||||
hostSlicePitch = builtinOpParams.srcSlicePitch;
|
||||
gpuRowPitch = builtinOpParams.dstRowPitch;
|
||||
gpuSlicePitch = builtinOpParams.dstSlicePitch;
|
||||
copySize = builtinOpParams.size;
|
||||
}
|
||||
|
||||
if (BlitterConstants::BlitDirection::BufferToHostPtr == blitDirection) {
|
||||
@ -100,7 +105,7 @@ struct ClBlitProperties {
|
||||
}
|
||||
|
||||
static BlitterConstants::BlitDirection obtainBlitDirection(uint32_t commandType) {
|
||||
if (CL_COMMAND_WRITE_BUFFER == commandType) {
|
||||
if (CL_COMMAND_WRITE_BUFFER == commandType || CL_COMMAND_WRITE_BUFFER_RECT == commandType) {
|
||||
return BlitterConstants::BlitDirection::HostPtrToBuffer;
|
||||
} else if (CL_COMMAND_READ_BUFFER == commandType || CL_COMMAND_READ_BUFFER_RECT == commandType) {
|
||||
return BlitterConstants::BlitDirection::BufferToHostPtr;
|
||||
|
@ -533,6 +533,7 @@ HWTEST_F(EnqueueWriteBufferRectTest, givenInOrderQueueAndDstPtrEqualSrcPtrAndNon
|
||||
}
|
||||
|
||||
HWTEST_F(EnqueueReadWriteBufferRectDispatch, givenOffsetResultingInMisalignedPtrWhenEnqueueWriteBufferRectForNon3DCaseIsCalledThenAddressInStateBaseAddressIsAlignedAndMatchesKernelDispatchInfoParams) {
|
||||
hwInfo->capabilityTable.blitterOperationsSupported = false;
|
||||
initializeFixture<FamilyType>();
|
||||
|
||||
if (device->areSharedSystemAllocationsAllowed()) {
|
||||
|
@ -411,7 +411,7 @@ HWTEST_F(BcsTests, givenBlitPropertiesContainerWhenExstimatingCommandsSizeThenCa
|
||||
EXPECT_EQ(expectedAlignedSize, alignedEstimatedSize);
|
||||
}
|
||||
|
||||
HWTEST_F(BcsTests, givenBlitPropertiesContainerWhenExstimatingCommandsSizeForReadBufferRectThenCalculateForAllAttachedProperites) {
|
||||
HWTEST_F(BcsTests, givenBlitPropertiesContainerWhenExstimatingCommandsSizeForWriteReadBufferRectThenCalculateForAllAttachedProperites) {
|
||||
const auto max2DBlitSize = BlitterConstants::maxBlitWidth * BlitterConstants::maxBlitHeight;
|
||||
const Vec3<size_t> bltSize = {(3 * max2DBlitSize), 4, 2};
|
||||
const size_t numberOfBlts = 3 * bltSize.y * bltSize.z;
|
||||
@ -620,14 +620,14 @@ struct BcsDetaliedTests : public BcsTests,
|
||||
}
|
||||
};
|
||||
|
||||
using BcsDetaliedTestsWithParams = BcsDetaliedTests<BcsTestParam>;
|
||||
using BcsDetaliedTestsWithParams = BcsDetaliedTests<std::tuple<BcsTestParam, BlitterConstants::BlitDirection>>;
|
||||
|
||||
HWTEST_P(BcsDetaliedTestsWithParams, givenBltSizeWithLeftoverWhenDispatchedThenProgramAddresseForReadBufferRect) {
|
||||
HWTEST_P(BcsDetaliedTestsWithParams, givenBltSizeWithLeftoverWhenDispatchedThenProgramAddresseForWriteReadBufferRect) {
|
||||
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
static_cast<OsAgnosticMemoryManager *>(csr.getMemoryManager())->turnOnFakingBigAllocations();
|
||||
|
||||
uint32_t bltLeftover = 17;
|
||||
Vec3<size_t> bltSize = GetParam().copySize;
|
||||
Vec3<size_t> bltSize = std::get<0>(GetParam()).copySize;
|
||||
|
||||
size_t numberOfBltsForSingleBltSizeProgramm = 3;
|
||||
size_t totalNumberOfBits = numberOfBltsForSingleBltSizeProgramm * bltSize.y * bltSize.z;
|
||||
@ -636,15 +636,15 @@ HWTEST_P(BcsDetaliedTestsWithParams, givenBltSizeWithLeftoverWhenDispatchedThenP
|
||||
auto buffer = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, static_cast<size_t>(8 * BlitterConstants::maxBlitWidth * BlitterConstants::maxBlitHeight), nullptr, retVal));
|
||||
void *hostPtr = reinterpret_cast<void *>(0x12340000);
|
||||
|
||||
Vec3<size_t> hostPtrOffset = GetParam().hostPtrOffset;
|
||||
Vec3<size_t> copyOffset = GetParam().copyOffset;
|
||||
Vec3<size_t> hostPtrOffset = std::get<0>(GetParam()).hostPtrOffset;
|
||||
Vec3<size_t> copyOffset = std::get<0>(GetParam()).copyOffset;
|
||||
|
||||
size_t dstRowPitch = GetParam().dstRowPitch;
|
||||
size_t dstSlicePitch = GetParam().dstSlicePitch;
|
||||
size_t srcRowPitch = GetParam().srcRowPitch;
|
||||
size_t srcSlicePitch = GetParam().srcSlicePitch;
|
||||
size_t dstRowPitch = std::get<0>(GetParam()).dstRowPitch;
|
||||
size_t dstSlicePitch = std::get<0>(GetParam()).dstSlicePitch;
|
||||
size_t srcRowPitch = std::get<0>(GetParam()).srcRowPitch;
|
||||
size_t srcSlicePitch = std::get<0>(GetParam()).srcSlicePitch;
|
||||
|
||||
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::BufferToHostPtr, //blitDirection
|
||||
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(std::get<1>(GetParam()), //blitDirection
|
||||
csr, buffer->getGraphicsAllocation(), //commandStreamReceiver
|
||||
nullptr, //memObjAllocation
|
||||
hostPtr, //preallocatedHostAllocation
|
||||
@ -706,12 +706,12 @@ HWTEST_P(BcsDetaliedTestsWithParams, givenBltSizeWithLeftoverWhenDispatchedThenP
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_P(BcsDetaliedTestsWithParams, givenBltSizeWithLeftoverWhenDispatchedThenProgramAllRequiredCommandsForReadBufferRect) {
|
||||
HWTEST_P(BcsDetaliedTestsWithParams, givenBltSizeWithLeftoverWhenDispatchedThenProgramAllRequiredCommandsForWriteReadBufferRect) {
|
||||
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
static_cast<OsAgnosticMemoryManager *>(csr.getMemoryManager())->turnOnFakingBigAllocations();
|
||||
|
||||
uint32_t bltLeftover = 17;
|
||||
Vec3<size_t> bltSize = GetParam().copySize;
|
||||
Vec3<size_t> bltSize = std::get<0>(GetParam()).copySize;
|
||||
|
||||
size_t numberOfBltsForSingleBltSizeProgramm = 3;
|
||||
size_t totalNumberOfBits = numberOfBltsForSingleBltSizeProgramm * bltSize.y * bltSize.z;
|
||||
@ -720,15 +720,15 @@ HWTEST_P(BcsDetaliedTestsWithParams, givenBltSizeWithLeftoverWhenDispatchedThenP
|
||||
auto buffer = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, static_cast<size_t>(8 * BlitterConstants::maxBlitWidth * BlitterConstants::maxBlitHeight), nullptr, retVal));
|
||||
void *hostPtr = reinterpret_cast<void *>(0x12340000);
|
||||
|
||||
Vec3<size_t> hostPtrOffset = GetParam().hostPtrOffset;
|
||||
Vec3<size_t> copyOffset = GetParam().copyOffset;
|
||||
Vec3<size_t> hostPtrOffset = std::get<0>(GetParam()).hostPtrOffset;
|
||||
Vec3<size_t> copyOffset = std::get<0>(GetParam()).copyOffset;
|
||||
|
||||
size_t dstRowPitch = GetParam().dstRowPitch;
|
||||
size_t dstSlicePitch = GetParam().dstSlicePitch;
|
||||
size_t srcRowPitch = GetParam().srcRowPitch;
|
||||
size_t srcSlicePitch = GetParam().srcSlicePitch;
|
||||
size_t dstRowPitch = std::get<0>(GetParam()).dstRowPitch;
|
||||
size_t dstSlicePitch = std::get<0>(GetParam()).dstSlicePitch;
|
||||
size_t srcRowPitch = std::get<0>(GetParam()).srcRowPitch;
|
||||
size_t srcSlicePitch = std::get<0>(GetParam()).srcSlicePitch;
|
||||
|
||||
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::BufferToHostPtr, //blitDirection
|
||||
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(std::get<1>(GetParam()), //blitDirection
|
||||
csr, buffer->getGraphicsAllocation(), //commandStreamReceiver
|
||||
nullptr, //memObjAllocation
|
||||
hostPtr, //preallocatedHostAllocation
|
||||
@ -786,7 +786,9 @@ HWTEST_P(BcsDetaliedTestsWithParams, givenBltSizeWithLeftoverWhenDispatchedThenP
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(BcsDetaliedTest,
|
||||
BcsDetaliedTestsWithParams,
|
||||
::testing::ValuesIn(BlitterProperties));
|
||||
::testing::Combine(
|
||||
::testing::ValuesIn(BlitterProperties),
|
||||
::testing::Values(BlitterConstants::BlitDirection::HostPtrToBuffer, BlitterConstants::BlitDirection::BufferToHostPtr)));
|
||||
|
||||
HWTEST_F(BcsTests, givenCsrDependenciesWhenProgrammingCommandStreamThenAddSemaphoreAndAtomic) {
|
||||
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
@ -1270,6 +1272,26 @@ HWTEST_F(BcsTests, givenMapAllocationWhenDispatchReadWriteOperationThenSetValidG
|
||||
}
|
||||
EXPECT_EQ(buffer->getGraphicsAllocation()->getGpuAddress(), bltCmd->getSourceBaseAddress());
|
||||
}
|
||||
{
|
||||
// bufferWrite from hostPtr
|
||||
HardwareParse hwParser;
|
||||
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
|
||||
csr, buffer->getGraphicsAllocation(),
|
||||
mapAllocation, mapPtr,
|
||||
buffer->getGraphicsAllocation()->getGpuAddress(),
|
||||
castToUint64(mapPtr),
|
||||
{hostPtrOffset, 0, 0}, 0, {4, 2, 1}, 0, 0, 0, 0);
|
||||
blitBuffer(&csr, blitProperties, true);
|
||||
|
||||
hwParser.parseCommands<FamilyType>(csr.commandStream);
|
||||
|
||||
auto bltCmd = genCmdCast<typename FamilyType::XY_COPY_BLT *>(*hwParser.cmdList.begin());
|
||||
EXPECT_NE(nullptr, bltCmd);
|
||||
if (pDevice->isFullRangeSvm()) {
|
||||
EXPECT_EQ(reinterpret_cast<uint64_t>(ptrOffset(mapPtr, hostPtrOffset)), bltCmd->getSourceBaseAddress());
|
||||
}
|
||||
EXPECT_EQ(buffer->getGraphicsAllocation()->getGpuAddress(), bltCmd->getDestinationBaseAddress());
|
||||
}
|
||||
|
||||
memoryManager->freeGraphicsMemory(mapAllocation);
|
||||
}
|
||||
|
@ -781,6 +781,9 @@ HWTEST_TEMPLATED_F(BcsBufferTests, givenBcsSupportedWhenEnqueueBufferOperationIs
|
||||
commandQueue->enqueueReadBufferRect(bufferForBlt0.get(), CL_TRUE, bufferOrigin, hostOrigin, region,
|
||||
MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize,
|
||||
MemoryConstants::cacheLineSize, &hostPtr, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueWriteBufferRect(bufferForBlt0.get(), CL_TRUE, bufferOrigin, hostOrigin, region,
|
||||
MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize,
|
||||
MemoryConstants::cacheLineSize, &hostPtr, 0, nullptr, nullptr);
|
||||
|
||||
DebugManager.flags.EnableBlitterOperationsForReadWriteBuffers.set(1);
|
||||
hwInfo->capabilityTable.blitterOperationsSupported = false;
|
||||
@ -790,6 +793,9 @@ HWTEST_TEMPLATED_F(BcsBufferTests, givenBcsSupportedWhenEnqueueBufferOperationIs
|
||||
commandQueue->enqueueReadBufferRect(bufferForBlt0.get(), CL_TRUE, bufferOrigin, hostOrigin, region,
|
||||
MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize,
|
||||
MemoryConstants::cacheLineSize, &hostPtr, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueWriteBufferRect(bufferForBlt0.get(), CL_TRUE, bufferOrigin, hostOrigin, region,
|
||||
MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize,
|
||||
MemoryConstants::cacheLineSize, &hostPtr, 0, nullptr, nullptr);
|
||||
|
||||
DebugManager.flags.EnableBlitterOperationsForReadWriteBuffers.set(0);
|
||||
hwInfo->capabilityTable.blitterOperationsSupported = true;
|
||||
@ -799,6 +805,9 @@ HWTEST_TEMPLATED_F(BcsBufferTests, givenBcsSupportedWhenEnqueueBufferOperationIs
|
||||
commandQueue->enqueueReadBufferRect(bufferForBlt0.get(), CL_TRUE, bufferOrigin, hostOrigin, region,
|
||||
MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize,
|
||||
MemoryConstants::cacheLineSize, &hostPtr, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueWriteBufferRect(bufferForBlt0.get(), CL_TRUE, bufferOrigin, hostOrigin, region,
|
||||
MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize,
|
||||
MemoryConstants::cacheLineSize, &hostPtr, 0, nullptr, nullptr);
|
||||
|
||||
DebugManager.flags.EnableBlitterOperationsForReadWriteBuffers.set(-1);
|
||||
hwInfo->capabilityTable.blitterOperationsSupported = true;
|
||||
@ -808,21 +817,28 @@ HWTEST_TEMPLATED_F(BcsBufferTests, givenBcsSupportedWhenEnqueueBufferOperationIs
|
||||
commandQueue->enqueueReadBufferRect(bufferForBlt0.get(), CL_TRUE, bufferOrigin, hostOrigin, region,
|
||||
MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize,
|
||||
MemoryConstants::cacheLineSize, &hostPtr, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueWriteBufferRect(bufferForBlt0.get(), CL_TRUE, bufferOrigin, hostOrigin, region,
|
||||
MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize,
|
||||
MemoryConstants::cacheLineSize, &hostPtr, 0, nullptr, nullptr);
|
||||
|
||||
EXPECT_EQ(4u, bcsCsr->blitBufferCalled);
|
||||
EXPECT_EQ(5u, bcsCsr->blitBufferCalled);
|
||||
|
||||
DebugManager.flags.EnableBlitterOperationsForReadWriteBuffers.set(1);
|
||||
hwInfo->capabilityTable.blitterOperationsSupported = true;
|
||||
commandQueue->enqueueWriteBuffer(bufferForBlt0.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(5u, bcsCsr->blitBufferCalled);
|
||||
commandQueue->enqueueReadBuffer(bufferForBlt0.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(6u, bcsCsr->blitBufferCalled);
|
||||
commandQueue->enqueueCopyBuffer(bufferForBlt0.get(), bufferForBlt1.get(), 0, 1, 1, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueReadBuffer(bufferForBlt0.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(7u, bcsCsr->blitBufferCalled);
|
||||
commandQueue->enqueueCopyBuffer(bufferForBlt0.get(), bufferForBlt1.get(), 0, 1, 1, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(8u, bcsCsr->blitBufferCalled);
|
||||
commandQueue->enqueueReadBufferRect(bufferForBlt0.get(), CL_TRUE, bufferOrigin, hostOrigin, region,
|
||||
MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize,
|
||||
MemoryConstants::cacheLineSize, &hostPtr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(8u, bcsCsr->blitBufferCalled);
|
||||
EXPECT_EQ(9u, bcsCsr->blitBufferCalled);
|
||||
commandQueue->enqueueWriteBufferRect(bufferForBlt0.get(), CL_TRUE, bufferOrigin, hostOrigin, region,
|
||||
MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize,
|
||||
MemoryConstants::cacheLineSize, &hostPtr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(10u, bcsCsr->blitBufferCalled);
|
||||
}
|
||||
|
||||
HWTEST_TEMPLATED_F(BcsBufferTests, givenBcsSupportedWhenQueueIsBlockedThenDispatchBlitWhenUnblocked) {
|
||||
@ -845,22 +861,29 @@ HWTEST_TEMPLATED_F(BcsBufferTests, givenBcsSupportedWhenQueueIsBlockedThenDispat
|
||||
commandQueue->enqueueReadBufferRect(bufferForBlt0.get(), CL_FALSE, bufferOrigin, hostOrigin, region,
|
||||
MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize,
|
||||
MemoryConstants::cacheLineSize, &hostPtr, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueWriteBufferRect(bufferForBlt0.get(), CL_FALSE, bufferOrigin, hostOrigin, region,
|
||||
MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize,
|
||||
MemoryConstants::cacheLineSize, &hostPtr, 0, nullptr, nullptr);
|
||||
|
||||
EXPECT_EQ(0u, bcsCsr->blitBufferCalled);
|
||||
|
||||
userEvent.setStatus(CL_COMPLETE);
|
||||
|
||||
EXPECT_EQ(4u, bcsCsr->blitBufferCalled);
|
||||
EXPECT_EQ(5u, bcsCsr->blitBufferCalled);
|
||||
|
||||
commandQueue->enqueueWriteBuffer(bufferForBlt0.get(), CL_FALSE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(5u, bcsCsr->blitBufferCalled);
|
||||
commandQueue->enqueueReadBuffer(bufferForBlt0.get(), CL_FALSE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(6u, bcsCsr->blitBufferCalled);
|
||||
commandQueue->enqueueCopyBuffer(bufferForBlt0.get(), bufferForBlt1.get(), 0, 1, 1, 0, nullptr, nullptr);
|
||||
commandQueue->enqueueReadBuffer(bufferForBlt0.get(), CL_FALSE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(7u, bcsCsr->blitBufferCalled);
|
||||
commandQueue->enqueueCopyBuffer(bufferForBlt0.get(), bufferForBlt1.get(), 0, 1, 1, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(8u, bcsCsr->blitBufferCalled);
|
||||
commandQueue->enqueueReadBufferRect(bufferForBlt0.get(), CL_FALSE, bufferOrigin, hostOrigin, region,
|
||||
MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize,
|
||||
MemoryConstants::cacheLineSize, &hostPtr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(9u, bcsCsr->blitBufferCalled);
|
||||
commandQueue->enqueueWriteBufferRect(bufferForBlt0.get(), CL_FALSE, bufferOrigin, hostOrigin, region,
|
||||
MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize,
|
||||
MemoryConstants::cacheLineSize, &hostPtr, 0, nullptr, nullptr);
|
||||
}
|
||||
|
||||
HWTEST_TEMPLATED_F(BcsBufferTests, givenBuffersWhenCopyBufferCalledThenUseBcs) {
|
||||
@ -1424,6 +1447,53 @@ HWTEST_TEMPLATED_F(BcsBufferTests, givenBlockingReadBufferRectWhenUsingBcsThenCa
|
||||
EXPECT_EQ(1u, myMockCsr->waitForTaskCountAndCleanAllocationListCalled);
|
||||
}
|
||||
|
||||
HWTEST_TEMPLATED_F(BcsBufferTests, givenBlockingWriteBufferRectWhenUsingBcsThenCallWait) {
|
||||
auto myMockCsr = new MyMockCsr<FamilyType>(*device->getExecutionEnvironment(), device->getRootDeviceIndex());
|
||||
myMockCsr->taskCount = 1234;
|
||||
myMockCsr->initializeTagAllocation();
|
||||
myMockCsr->setupContext(*bcsMockContext->bcsOsContext);
|
||||
bcsMockContext->bcsCsr.reset(myMockCsr);
|
||||
|
||||
EngineControl bcsEngineControl = {myMockCsr, bcsMockContext->bcsOsContext.get()};
|
||||
|
||||
auto cmdQ = clUniquePtr(new MockCommandQueueHw<FamilyType>(bcsMockContext.get(), device.get(), nullptr));
|
||||
cmdQ->bcsEngine = &bcsEngineControl;
|
||||
auto &gpgpuCsr = cmdQ->getGpgpuCommandStreamReceiver();
|
||||
myMockCsr->gpgpuCsr = &gpgpuCsr;
|
||||
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
auto buffer = clUniquePtr<Buffer>(Buffer::create(bcsMockContext.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
|
||||
buffer->forceDisallowCPUCopy = true;
|
||||
void *hostPtr = reinterpret_cast<void *>(0x12340000);
|
||||
|
||||
size_t bufferOrigin[] = {0, 0, 0};
|
||||
size_t hostOrigin[] = {0, 0, 0};
|
||||
size_t region[] = {1, 2, 1};
|
||||
|
||||
cmdQ->enqueueWriteBufferRect(buffer.get(), false, bufferOrigin, hostOrigin, region,
|
||||
MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize,
|
||||
MemoryConstants::cacheLineSize, hostPtr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(0u, myMockCsr->waitForTaskCountAndCleanAllocationListCalled);
|
||||
EXPECT_TRUE(gpgpuCsr.getTemporaryAllocations().peekIsEmpty());
|
||||
EXPECT_FALSE(myMockCsr->getTemporaryAllocations().peekIsEmpty());
|
||||
|
||||
bool tempAllocationFound = false;
|
||||
auto tempAllocation = myMockCsr->getTemporaryAllocations().peekHead();
|
||||
while (tempAllocation) {
|
||||
if (tempAllocation->getUnderlyingBuffer() == hostPtr) {
|
||||
tempAllocationFound = true;
|
||||
break;
|
||||
}
|
||||
tempAllocation = tempAllocation->next;
|
||||
}
|
||||
EXPECT_TRUE(tempAllocationFound);
|
||||
|
||||
cmdQ->enqueueWriteBufferRect(buffer.get(), true, bufferOrigin, hostOrigin, region,
|
||||
MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize,
|
||||
MemoryConstants::cacheLineSize, hostPtr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(1u, myMockCsr->waitForTaskCountAndCleanAllocationListCalled);
|
||||
}
|
||||
|
||||
HWTEST_TEMPLATED_F(BcsBufferTests, givenBlockingReadBufferWhenUsingBcsThenCallWait) {
|
||||
auto myMockCsr = new MyMockCsr<FamilyType>(*device->getExecutionEnvironment(), device->getRootDeviceIndex());
|
||||
myMockCsr->taskCount = 1234;
|
||||
|
@ -48,7 +48,12 @@ BlitProperties BlitProperties::constructPropertiesForReadWriteBuffer(BlitterCons
|
||||
hostAllocGpuVa, // srcGpuAddress
|
||||
copySize, // copySize
|
||||
copyOffset, // dstOffset
|
||||
hostPtrOffset}; // srcOffset
|
||||
hostPtrOffset, // srcOffset
|
||||
gpuRowPitch, //dstRowPitch
|
||||
gpuSlicePitch, //dstSlicePitch
|
||||
hostRowPitch, //srcRowPitch
|
||||
hostSlicePitch}; //srcSlicePitch
|
||||
|
||||
} else {
|
||||
return {
|
||||
nullptr, // outputTimestampPacket
|
||||
|
Reference in New Issue
Block a user