Add support for stateless write buffer

Change-Id: Ie5d5abc9fac268c3467cafed5741828d84b13795
Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
Related-To: NEO-3314
This commit is contained in:
Kamil Kopryk
2019-11-04 14:58:49 +01:00
committed by sys_ocldev
parent 2599a712fe
commit 1bfe9f548e
2 changed files with 63 additions and 3 deletions

View File

@@ -50,11 +50,15 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteBuffer(
numEventsInWaitList, eventWaitList, event); numEventsInWaitList, eventWaitList, event);
} }
auto &builder = getDevice().getExecutionEnvironment()->getBuiltIns()->getBuiltinDispatchInfoBuilder(EBuiltInOps::CopyBufferToBuffer, auto eBuiltInOps = EBuiltInOps::CopyBufferToBuffer;
this->getContext(), this->getDevice()); if (forceStateless(size)) {
eBuiltInOps = EBuiltInOps::CopyBufferToBufferStateless;
}
auto &builder = getDevice().getExecutionEnvironment()->getBuiltIns()->getBuiltinDispatchInfoBuilder(eBuiltInOps,
this->getContext(),
this->getDevice());
BuiltInOwnershipWrapper builtInLock(builder, this->context); BuiltInOwnershipWrapper builtInLock(builder, this->context);
MultiDispatchInfo dispatchInfo;
void *srcPtr = const_cast<void *>(ptr); void *srcPtr = const_cast<void *>(ptr);
@@ -89,6 +93,8 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteBuffer(
dc.dstOffset = {offset, 0, 0}; dc.dstOffset = {offset, 0, 0};
dc.size = {size, 0, 0}; dc.size = {size, 0, 0};
dc.transferAllocation = mapAllocation ? mapAllocation : hostPtrSurf.getAllocation(); dc.transferAllocation = mapAllocation ? mapAllocation : hostPtrSurf.getAllocation();
MultiDispatchInfo dispatchInfo;
builder.buildDispatchInfos(dispatchInfo, dc); builder.buildDispatchInfos(dispatchInfo, dc);
enqueueHandler<CL_COMMAND_WRITE_BUFFER>( enqueueHandler<CL_COMMAND_WRITE_BUFFER>(

View File

@@ -488,3 +488,57 @@ HWTEST_F(NegativeFailAllocationTest, givenEnqueueWriteBufferWhenHostPtrAllocatio
EXPECT_EQ(CL_OUT_OF_RESOURCES, retVal); EXPECT_EQ(CL_OUT_OF_RESOURCES, retVal);
} }
struct EnqueueWriteBufferHw : public ::testing::Test {
void SetUp() override {
if (is32bit) {
GTEST_SKIP();
}
device.reset(MockDevice::createWithNewExecutionEnvironment<MockDevice>(*platformDevices));
context.reset(new MockContext(device.get()));
srcBuffer.reset(BufferHelper<>::create(context.get()));
}
std::unique_ptr<MockDevice> device;
std::unique_ptr<MockContext> context;
std::unique_ptr<Buffer> srcBuffer;
};
using EnqeueReadWriteStatelessTest = EnqueueWriteBufferHw;
HWTEST_F(EnqeueReadWriteStatelessTest, WhenWritingBufferStatelessThenSuccessIsReturned) {
auto pCmdQ = std::make_unique<CommandQueueStateless<FamilyType>>(context.get(), device.get());
void *missAlignedPtr = reinterpret_cast<void *>(0x1041);
auto retVal = pCmdQ->enqueueWriteBuffer(srcBuffer.get(),
CL_FALSE,
0,
MemoryConstants::cacheLineSize,
missAlignedPtr,
nullptr,
0,
nullptr,
nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
}
using EnqeueWriteBufferStatefulTest = EnqueueWriteBufferHw;
HWTEST_F(EnqeueWriteBufferStatefulTest, WhenWritingBufferStatefulThenSuccessIsReturned) {
auto pCmdQ = std::make_unique<CommandQueueStateful<FamilyType>>(context.get(), device.get());
void *missAlignedPtr = reinterpret_cast<void *>(0x1041);
auto retVal = pCmdQ->enqueueWriteBuffer(srcBuffer.get(),
CL_FALSE,
0,
MemoryConstants::cacheLineSize,
missAlignedPtr,
nullptr,
0,
nullptr,
nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
}