mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-07 21:27:04 +08:00
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:
@@ -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>(
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user