Add hostPtrOffset to constructPropertiesForReadWriteBuffer()

Change-Id: If7ac8efaa0ae9c485339abae49503052f97bae79
Related-To: NEO-3020
Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz
2019-09-17 10:43:14 +02:00
committed by sys_ocldev
parent 51e0c19f79
commit fe7340e029
4 changed files with 32 additions and 21 deletions

View File

@ -17,8 +17,8 @@
namespace NEO {
BlitProperties BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection blitDirection,
CommandStreamReceiver &commandStreamReceiver,
GraphicsAllocation *memObjAllocation, void *hostPtr, bool blocking,
size_t offset, uint64_t copySize) {
GraphicsAllocation *memObjAllocation, void *hostPtr, size_t hostPtrOffset,
bool blocking, size_t offset, uint64_t copySize) {
HostPtrSurface hostPtrSurface(hostPtr, static_cast<size_t>(copySize), true);
bool success = commandStreamReceiver.createAllocationForHostSurface(hostPtrSurface, false);
@ -26,9 +26,9 @@ BlitProperties BlitProperties::constructPropertiesForReadWriteBuffer(BlitterCons
auto hostPtrAllocation = hostPtrSurface.getAllocation();
if (BlitterConstants::BlitDirection::HostPtrToBuffer == blitDirection) {
return {nullptr, blitDirection, {}, AuxTranslationDirection::None, memObjAllocation, hostPtrAllocation, hostPtr, blocking, offset, 0, copySize};
return {nullptr, blitDirection, {}, AuxTranslationDirection::None, memObjAllocation, hostPtrAllocation, hostPtr, blocking, offset, hostPtrOffset, copySize};
} else {
return {nullptr, blitDirection, {}, AuxTranslationDirection::None, hostPtrAllocation, memObjAllocation, hostPtr, blocking, 0, offset, copySize};
return {nullptr, blitDirection, {}, AuxTranslationDirection::None, hostPtrAllocation, memObjAllocation, hostPtr, blocking, hostPtrOffset, offset, copySize};
}
}
@ -38,11 +38,11 @@ BlitProperties BlitProperties::constructPropertiesForReadWriteBuffer(BlitterCons
bool blocking) {
if (BlitterConstants::BlitDirection::HostPtrToBuffer == blitDirection) {
return constructPropertiesForReadWriteBuffer(blitDirection, commandStreamReceiver, builtinOpParams.dstMemObj->getGraphicsAllocation(),
builtinOpParams.srcPtr, blocking, builtinOpParams.dstOffset.x,
builtinOpParams.srcPtr, builtinOpParams.srcOffset.x, blocking, builtinOpParams.dstOffset.x,
builtinOpParams.size.x);
} else {
return constructPropertiesForReadWriteBuffer(blitDirection, commandStreamReceiver, builtinOpParams.srcMemObj->getGraphicsAllocation(),
builtinOpParams.dstPtr, blocking, builtinOpParams.srcOffset.x,
builtinOpParams.dstPtr, builtinOpParams.dstOffset.x, blocking, builtinOpParams.srcOffset.x,
builtinOpParams.size.x);
}
}

View File

@ -23,8 +23,8 @@ class TimestampPacketContainer;
struct BlitProperties {
static BlitProperties constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection blitDirection,
CommandStreamReceiver &commandStreamReceiver,
GraphicsAllocation *memObjAllocation, void *hostPtr, bool blocking,
size_t offset, uint64_t copySize);
GraphicsAllocation *memObjAllocation, void *hostPtr, size_t hostPtrOffset,
bool blocking, size_t offset, uint64_t copySize);
static BlitProperties constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection blitDirection,
CommandStreamReceiver &commandStreamReceiver,

View File

@ -384,7 +384,8 @@ HWTEST_F(BcsTests, givenBltSizeWithLeftoverWhenDispatchedThenProgramAllRequiredC
csr.taskCount = newTaskCount - 1;
EXPECT_EQ(0u, csr.recursiveLockCounter.load());
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
csr, buffer->getGraphicsAllocation(), hostPtr, true, 0, bltSize);
csr, buffer->getGraphicsAllocation(), hostPtr, 0, true,
0, bltSize);
csr.blitBuffer(blitProperties);
EXPECT_EQ(newTaskCount, csr.taskCount);
@ -443,7 +444,8 @@ HWTEST_F(BcsTests, givenCsrDependenciesWhenProgrammingCommandStreamThenAddSemaph
size_t numberNodesPerContainer = 5;
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
csr, buffer->getGraphicsAllocation(), hostPtr, true, 0, 1);
csr, buffer->getGraphicsAllocation(), hostPtr, 0, true,
0, 1);
MockTimestampPacketContainer timestamp0(*csr.getTimestampPacketAllocator(), numberNodesPerContainer);
MockTimestampPacketContainer timestamp1(*csr.getTimestampPacketAllocator(), numberNodesPerContainer);
@ -491,7 +493,8 @@ HWTEST_F(BcsTests, givenInputAllocationsWhenBlitDispatchedThenMakeAllAllocations
EXPECT_EQ(0u, csr.makeSurfacePackNonResidentCalled);
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
csr, buffer->getGraphicsAllocation(), hostPtr, true, 0, 1);
csr, buffer->getGraphicsAllocation(), hostPtr, 0, true,
0, 1);
csr.blitBuffer(blitProperties);
@ -519,7 +522,8 @@ HWTEST_F(BcsTests, givenBufferWhenBlitCalledThenFlushCommandBuffer) {
csr.taskCount = newTaskCount - 1;
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
csr, buffer->getGraphicsAllocation(), hostPtr, true, 0, 1);
csr, buffer->getGraphicsAllocation(), hostPtr, 0, true,
0, 1);
csr.blitBuffer(blitProperties);
@ -567,7 +571,8 @@ HWTEST_F(BcsTests, whenBlitFromHostPtrCalledThenCallWaitWithKmdFallback) {
void *hostPtr = reinterpret_cast<void *>(0x12340000);
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
*myMockCsr, buffer->getGraphicsAllocation(), hostPtr, false, 0, 1);
*myMockCsr, buffer->getGraphicsAllocation(), hostPtr, 0,
false, 0, 1);
myMockCsr->blitBuffer(blitProperties);
@ -597,7 +602,8 @@ HWTEST_F(BcsTests, whenBlitFromHostPtrCalledThenCleanTemporaryAllocations) {
EXPECT_EQ(0u, mockInternalAllocationsStorage->cleanAllocationsCalled);
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
bcsCsr, buffer->getGraphicsAllocation(), hostPtr, false, 0, 1);
bcsCsr, buffer->getGraphicsAllocation(), hostPtr, 0,
false, 0, 1);
bcsCsr.blitBuffer(blitProperties);
@ -618,12 +624,14 @@ HWTEST_F(BcsTests, givenBufferWhenBlitOperationCalledThenProgramCorrectGpuAddres
auto buffer1 = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
auto buffer2 = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
void *hostPtr = reinterpret_cast<void *>(0x12340000);
size_t hostPtrOffset = 0x1234;
{
// from hostPtr
HardwareParse hwParser;
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
csr, buffer1->getGraphicsAllocation(), hostPtr, true, 0, 1);
csr, buffer1->getGraphicsAllocation(), hostPtr, hostPtrOffset,
true, 0, 1);
csr.blitBuffer(blitProperties);
@ -632,7 +640,7 @@ HWTEST_F(BcsTests, givenBufferWhenBlitOperationCalledThenProgramCorrectGpuAddres
auto bltCmd = genCmdCast<typename FamilyType::XY_COPY_BLT *>(*hwParser.cmdList.begin());
EXPECT_NE(nullptr, bltCmd);
if (pDevice->isFullRangeSvm()) {
EXPECT_EQ(reinterpret_cast<uint64_t>(hostPtr), bltCmd->getSourceBaseAddress());
EXPECT_EQ(reinterpret_cast<uint64_t>(ptrOffset(hostPtr, hostPtrOffset)), bltCmd->getSourceBaseAddress());
}
EXPECT_EQ(buffer1->getGraphicsAllocation()->getGpuAddress(), bltCmd->getDestinationBaseAddress());
}
@ -641,7 +649,8 @@ HWTEST_F(BcsTests, givenBufferWhenBlitOperationCalledThenProgramCorrectGpuAddres
HardwareParse hwParser;
auto offset = csr.commandStream.getUsed();
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::BufferToHostPtr,
csr, buffer1->getGraphicsAllocation(), hostPtr, true, 0, 1);
csr, buffer1->getGraphicsAllocation(), hostPtr, hostPtrOffset,
true, 0, 1);
csr.blitBuffer(blitProperties);
@ -650,7 +659,7 @@ HWTEST_F(BcsTests, givenBufferWhenBlitOperationCalledThenProgramCorrectGpuAddres
auto bltCmd = genCmdCast<typename FamilyType::XY_COPY_BLT *>(*hwParser.cmdList.begin());
EXPECT_NE(nullptr, bltCmd);
if (pDevice->isFullRangeSvm()) {
EXPECT_EQ(reinterpret_cast<uint64_t>(hostPtr), bltCmd->getDestinationBaseAddress());
EXPECT_EQ(reinterpret_cast<uint64_t>(ptrOffset(hostPtr, hostPtrOffset)), bltCmd->getDestinationBaseAddress());
}
EXPECT_EQ(buffer1->getGraphicsAllocation()->getGpuAddress(), bltCmd->getSourceBaseAddress());
}
@ -689,7 +698,8 @@ HWTEST_F(BcsTests, givenBufferWithOffsetWhenBlitOperationCalledThenProgramCorrec
HardwareParse hwParser;
auto offset = csr.commandStream.getUsed();
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
csr, buffer1->getGraphicsAllocation(), hostPtr, true, buffer1Offset, 1);
csr, buffer1->getGraphicsAllocation(), hostPtr,
0, true, buffer1Offset, 1);
csr.blitBuffer(blitProperties);
@ -707,7 +717,8 @@ HWTEST_F(BcsTests, givenBufferWithOffsetWhenBlitOperationCalledThenProgramCorrec
HardwareParse hwParser;
auto offset = csr.commandStream.getUsed();
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::BufferToHostPtr,
csr, buffer1->getGraphicsAllocation(), hostPtr, true, buffer1Offset, 1);
csr, buffer1->getGraphicsAllocation(), hostPtr,
0, true, buffer1Offset, 1);
csr.blitBuffer(blitProperties);

View File

@ -674,7 +674,7 @@ struct BcsBufferTests : public ::testing::Test {
BlitOperationResult blitMemoryToAllocation(MemObj &memObj, GraphicsAllocation *memory, void *hostPtr, size_t size) const override {
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
*bcsCsr, memory,
hostPtr, true, 0, size);
hostPtr, 0, true, 0, size);
bcsCsr->blitBuffer(blitProperties);
return BlitOperationResult::Success;
}