diff --git a/runtime/command_queue/enqueue_read_buffer.h b/runtime/command_queue/enqueue_read_buffer.h index ea984bba77..00e1deb39b 100644 --- a/runtime/command_queue/enqueue_read_buffer.h +++ b/runtime/command_queue/enqueue_read_buffer.h @@ -55,10 +55,14 @@ cl_int CommandQueueHw::enqueueReadBuffer( numEventsInWaitList, eventWaitList, event); } - auto &builder = getDevice().getExecutionEnvironment()->getBuiltIns()->getBuiltinDispatchInfoBuilder(EBuiltInOps::CopyBufferToBuffer, - this->getContext(), this->getDevice()); + auto eBuiltInOps = EBuiltInOps::CopyBufferToBuffer; + if (forceStateless(size)) { + eBuiltInOps = EBuiltInOps::CopyBufferToBufferStateless; + } + auto &builder = getDevice().getExecutionEnvironment()->getBuiltIns()->getBuiltinDispatchInfoBuilder(eBuiltInOps, + this->getContext(), + this->getDevice()); BuiltInOwnershipWrapper builtInLock(builder, this->context); - MultiDispatchInfo dispatchInfo; void *dstPtr = ptr; @@ -93,6 +97,8 @@ cl_int CommandQueueHw::enqueueReadBuffer( dc.srcOffset = {offset, 0, 0}; dc.size = {size, 0, 0}; dc.transferAllocation = mapAllocation ? mapAllocation : hostPtrSurf.getAllocation(); + + MultiDispatchInfo dispatchInfo; builder.buildDispatchInfos(dispatchInfo, dc); if (context->isProvidingPerformanceHints()) { diff --git a/unit_tests/command_queue/enqueue_read_buffer_tests.cpp b/unit_tests/command_queue/enqueue_read_buffer_tests.cpp index 61dc407f07..75947ed5ba 100644 --- a/unit_tests/command_queue/enqueue_read_buffer_tests.cpp +++ b/unit_tests/command_queue/enqueue_read_buffer_tests.cpp @@ -680,3 +680,57 @@ HWTEST_F(NegativeFailAllocationTest, givenEnqueueReadBufferWhenHostPtrAllocation EXPECT_EQ(CL_OUT_OF_RESOURCES, retVal); } + +struct EnqueueReadBufferHw : public ::testing::Test { + + void SetUp() override { + if (is32bit) { + GTEST_SKIP(); + } + device.reset(MockDevice::createWithNewExecutionEnvironment(*platformDevices)); + context.reset(new MockContext(device.get())); + srcBuffer.reset(BufferHelper<>::create(context.get())); + } + + std::unique_ptr device; + std::unique_ptr context; + std::unique_ptr srcBuffer; +}; + +using EnqeueReadBufferStatelessTest = EnqueueReadBufferHw; + +HWTEST_F(EnqeueReadBufferStatelessTest, WhenReadingBufferStatelessThenSuccessIsReturned) { + + auto pCmdQ = std::make_unique>(context.get(), device.get()); + void *missAlignedPtr = reinterpret_cast(0x1041); + auto retVal = pCmdQ->enqueueReadBuffer(srcBuffer.get(), + CL_FALSE, + 0, + MemoryConstants::cacheLineSize, + missAlignedPtr, + nullptr, + 0, + nullptr, + nullptr); + + EXPECT_EQ(CL_SUCCESS, retVal); +} + +using EnqeueReadBufferStatefulTest = EnqueueReadBufferHw; + +HWTEST_F(EnqeueReadBufferStatefulTest, WhenReadingBufferStatefulThenSuccessIsReturned) { + + auto pCmdQ = std::make_unique>(context.get(), device.get()); + void *missAlignedPtr = reinterpret_cast(0x1041); + auto retVal = pCmdQ->enqueueReadBuffer(srcBuffer.get(), + CL_FALSE, + 0, + MemoryConstants::cacheLineSize, + missAlignedPtr, + nullptr, + 0, + nullptr, + nullptr); + + EXPECT_EQ(CL_SUCCESS, retVal); +}