diff --git a/runtime/command_queue/command_queue_hw.h b/runtime/command_queue/command_queue_hw.h index 2572c39295..89e26179fe 100644 --- a/runtime/command_queue/command_queue_hw.h +++ b/runtime/command_queue/command_queue_hw.h @@ -76,6 +76,9 @@ class CommandQueueHw : public CommandQueue { return new CommandQueueHw(context, device, properties); } + MOCKABLE_VIRTUAL void notifyEnqueueReadBuffer(Buffer *buffer, bool blockingRead); + MOCKABLE_VIRTUAL void notifyEnqueueReadImage(Image *image, bool blockingRead); + cl_int enqueueBarrierWithWaitList(cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) override; diff --git a/runtime/command_queue/command_queue_hw.inl b/runtime/command_queue/command_queue_hw.inl index 5ded683e3d..53a872af7d 100644 --- a/runtime/command_queue/command_queue_hw.inl +++ b/runtime/command_queue/command_queue_hw.inl @@ -41,3 +41,12 @@ #include "runtime/command_queue/enqueue_write_image.h" #include "runtime/command_queue/finish.h" #include "runtime/command_queue/flush.h" + +namespace OCLRT { +template +void CommandQueueHw::notifyEnqueueReadBuffer(Buffer *buffer, bool blockingRead) { +} +template +void CommandQueueHw::notifyEnqueueReadImage(Image *image, bool blockingRead) { +} +} // namespace OCLRT diff --git a/runtime/command_queue/enqueue_read_buffer.h b/runtime/command_queue/enqueue_read_buffer.h index 15696fe671..f2ed040330 100644 --- a/runtime/command_queue/enqueue_read_buffer.h +++ b/runtime/command_queue/enqueue_read_buffer.h @@ -45,6 +45,8 @@ cl_int CommandQueueHw::enqueueReadBuffer( const cl_event *eventWaitList, cl_event *event) { + notifyEnqueueReadBuffer(buffer, !!blockingRead); + cl_int retVal = CL_SUCCESS; bool isMemTransferNeeded = buffer->isMemObjZeroCopy() ? buffer->checkIfMemoryTransferIsRequired(offset, 0, ptr, CL_COMMAND_READ_BUFFER) : true; if ((DebugManager.flags.DoCpuCopyOnReadBuffer.get() || diff --git a/runtime/command_queue/enqueue_read_image.h b/runtime/command_queue/enqueue_read_image.h index 9858e7c12f..fd4b83eef0 100644 --- a/runtime/command_queue/enqueue_read_image.h +++ b/runtime/command_queue/enqueue_read_image.h @@ -50,6 +50,8 @@ cl_int CommandQueueHw::enqueueReadImage( const cl_event *eventWaitList, cl_event *event) { + notifyEnqueueReadImage(srcImage, !!blockingRead); + MultiDispatchInfo di; auto isMemTransferNeeded = true; if (srcImage->isMemObjZeroCopy()) { diff --git a/runtime/memory_manager/graphics_allocation.h b/runtime/memory_manager/graphics_allocation.h index 9edc95df24..03ceec0314 100644 --- a/runtime/memory_manager/graphics_allocation.h +++ b/runtime/memory_manager/graphics_allocation.h @@ -136,6 +136,8 @@ class GraphicsAllocation : public IDNode { void setAubWritable(bool writable) { aubWritable = writable; } bool isAubWritable() const { return aubWritable; } + void setAllocDumpable(bool dumpable) { allocDumpable = dumpable; } + bool isAllocDumpable() const { return allocDumpable; } bool isMemObjectsAllocationWithWritableFlags() const { return memObjectsAllocationWithWritableFlags; } void setMemObjectsAllocationWithWritableFlags(bool newValue) { memObjectsAllocationWithWritableFlags = newValue; } @@ -160,6 +162,7 @@ class GraphicsAllocation : public IDNode { uint32_t inspectionId = 0; AllocationType allocationType = AllocationType::UNKNOWN; bool aubWritable = true; + bool allocDumpable = false; bool memObjectsAllocationWithWritableFlags = false; }; } // namespace OCLRT diff --git a/unit_tests/command_queue/enqueue_read_buffer_tests.cpp b/unit_tests/command_queue/enqueue_read_buffer_tests.cpp index df481bd631..449f35f69b 100644 --- a/unit_tests/command_queue/enqueue_read_buffer_tests.cpp +++ b/unit_tests/command_queue/enqueue_read_buffer_tests.cpp @@ -30,6 +30,7 @@ #include "unit_tests/command_queue/enqueue_read_buffer_fixture.h" #include "unit_tests/helpers/debug_manager_state_restore.h" #include "unit_tests/helpers/unit_test_helper.h" +#include "unit_tests/mocks/mock_command_queue.h" #include "test.h" using namespace OCLRT; @@ -451,6 +452,22 @@ HWTEST_F(EnqueueReadBufferTypeTest, givenInOrderQueueAndEnabledSupportCpuCopiesA EXPECT_EQ(pCmdQ->taskLevel, 1u); } +HWTEST_F(EnqueueReadBufferTypeTest, givenCommandQueueWhenEnqueueReadBufferIsCalledThenItCallsNotifyFunction) { + auto mockCmdQ = std::make_unique>(context, pDevice, nullptr); + void *ptr = nonZeroCopyBuffer->getCpuAddressForMemoryTransfer(); + auto retVal = mockCmdQ->enqueueReadBuffer(srcBuffer.get(), + CL_TRUE, + 0, + MemoryConstants::cacheLineSize, + ptr, + 0, + nullptr, + nullptr); + + EXPECT_EQ(CL_SUCCESS, retVal); + EXPECT_TRUE(mockCmdQ->notifyEnqueueReadBufferCalled); +} + using NegativeFailAllocationTest = Test; HWTEST_F(NegativeFailAllocationTest, givenEnqueueReadBufferWhenHostPtrAllocationCreationFailsThenReturnOutOfResource) { diff --git a/unit_tests/command_queue/enqueue_read_image_tests.cpp b/unit_tests/command_queue/enqueue_read_image_tests.cpp index 6bbecabb6c..eb34015017 100644 --- a/unit_tests/command_queue/enqueue_read_image_tests.cpp +++ b/unit_tests/command_queue/enqueue_read_image_tests.cpp @@ -25,7 +25,9 @@ #include "unit_tests/command_queue/enqueue_read_image_fixture.h" #include "unit_tests/gen_common/gen_commands_common_validation.h" #include "unit_tests/helpers/unit_test_helper.h" +#include "unit_tests/helpers/debug_manager_state_restore.h" #include "unit_tests/mocks/mock_builtin_dispatch_info_builder.h" +#include "unit_tests/mocks/mock_command_queue.h" #include "test.h" using namespace OCLRT; @@ -533,6 +535,18 @@ HWTEST_F(EnqueueReadImageTest, GivenNonZeroCopyImage2DAndImageShareTheSameStorag EXPECT_EQ(pCmdQ->taskLevel, 2u); } +HWTEST_F(EnqueueReadImageTest, givenCommandQueueWhenEnqueueReadImageIsCalledThenItCallsNotifyFunction) { + auto mockCmdQ = std::make_unique>(context, pDevice, nullptr); + std::unique_ptr srcImage(Image2dArrayHelper<>::create(context)); + auto imageDesc = srcImage->getImageDesc(); + size_t origin[] = {0, 0, 0}; + size_t region[] = {imageDesc.image_width, imageDesc.image_height, imageDesc.image_array_size}; + + EnqueueReadImageHelper<>::enqueueReadImage(mockCmdQ.get(), srcImage.get(), CL_TRUE, origin, region); + + EXPECT_TRUE(mockCmdQ->notifyEnqueueReadImageCalled); +} + typedef EnqueueReadImageMipMapTest MipMapReadImageTest; HWTEST_P(MipMapReadImageTest, GivenImageWithMipLevelNonZeroWhenReadImageIsCalledThenProperMipLevelIsSet) { diff --git a/unit_tests/mem_obj/mem_obj_tests.cpp b/unit_tests/mem_obj/mem_obj_tests.cpp index 873b93b568..f36593760f 100644 --- a/unit_tests/mem_obj/mem_obj_tests.cpp +++ b/unit_tests/mem_obj/mem_obj_tests.cpp @@ -481,3 +481,10 @@ TEST(MemObj, givenNotSharedMemObjectWhenChangingGfxAllocationThenOldAllocationIs EXPECT_EQ(newGfxAllocation, memObj.getGraphicsAllocation()); } + +TEST(MemObj, givenGraphicsAllocationWhenCallingIsAllocDumpableThenItReturnsTheCorrectValue) { + GraphicsAllocation gfxAllocation(nullptr, 0); + EXPECT_FALSE(gfxAllocation.isAllocDumpable()); + gfxAllocation.setAllocDumpable(true); + EXPECT_TRUE(gfxAllocation.isAllocDumpable()); +} diff --git a/unit_tests/mocks/mock_command_queue.h b/unit_tests/mocks/mock_command_queue.h index 73281574c7..cb7db90d85 100644 --- a/unit_tests/mocks/mock_command_queue.h +++ b/unit_tests/mocks/mock_command_queue.h @@ -114,11 +114,20 @@ class MockCommandQueueHw : public CommandQueueHw { } } + void notifyEnqueueReadBuffer(Buffer *buffer, bool blockingRead) override { + notifyEnqueueReadBufferCalled = true; + } + void notifyEnqueueReadImage(Image *image, bool blockingRead) override { + notifyEnqueueReadImageCalled = true; + } + unsigned int lastCommandType; std::vector lastEnqueuedKernels; size_t EnqueueWriteImageCounter = 0; size_t EnqueueWriteBufferCounter = 0; bool blockingWriteBuffer = false; + bool notifyEnqueueReadBufferCalled = false; + bool notifyEnqueueReadImageCalled = false; LinearStream *peekCommandStream() { return this->commandStream;