diff --git a/opencl/source/command_queue/enqueue_common.h b/opencl/source/command_queue/enqueue_common.h index 037c0a5ffe..562bae52af 100644 --- a/opencl/source/command_queue/enqueue_common.h +++ b/opencl/source/command_queue/enqueue_common.h @@ -589,6 +589,7 @@ void CommandQueueHw::processDispatchForMarker(CommandQueue &commandQu HardwareInterface::dispatchProfilingPerfStartCommands(hwTimeStamps, hwPerfCounter, commandStream, commandQueue); HardwareInterface::dispatchProfilingPerfEndCommands(hwTimeStamps, hwPerfCounter, commandStream, commandQueue); + getGpgpuCommandStreamReceiver().makeResident(*hwTimeStamps->getBaseGraphicsAllocation()); } template diff --git a/opencl/test/unit_test/command_queue/command_queue_hw_tests.cpp b/opencl/test/unit_test/command_queue/command_queue_hw_tests.cpp index 668e333b13..2350f28717 100644 --- a/opencl/test/unit_test/command_queue/command_queue_hw_tests.cpp +++ b/opencl/test/unit_test/command_queue/command_queue_hw_tests.cpp @@ -176,6 +176,42 @@ HWTEST_F(CommandQueueHwTest, WhenEnqueuingBlockedMapUnmapOperationThenVirtualEve pHwQ->virtualEvent = nullptr; } +class MockCommandStreamReceiverWithFailingFlushBatchedSubmission : public MockCommandStreamReceiver { + public: + using MockCommandStreamReceiver::MockCommandStreamReceiver; + bool flushBatchedSubmissions() override { + return false; + } +}; + +template +struct MockCommandQueueHwWithOverwrittenCsr : public CommandQueueHw { + using CommandQueueHw::CommandQueueHw; + MockCommandStreamReceiverWithFailingFlushBatchedSubmission *csr; + CommandStreamReceiver &getGpgpuCommandStreamReceiver() const override { return *csr; } +}; + +HWTEST_F(CommandQueueHwTest, GivenCommandQueueWhenProcessDispatchForMarkerCalledThenEventAllocationIsMadeResident) { + + pDevice->getUltCommandStreamReceiver().timestampPacketWriteEnabled = false; + MockCommandStreamReceiverWithFailingFlushBatchedSubmission csr(*pDevice->getExecutionEnvironment(), 0, pDevice->getDeviceBitfield()); + auto myCmdQ = std::make_unique>(pCmdQ->getContextPtr(), pClDevice, nullptr, false); + myCmdQ->csr = &csr; + csr.osContext = &pCmdQ->getCommandStreamReceiver(false).getOsContext(); + std::unique_ptr event(new Event(myCmdQ.get(), CL_COMMAND_COPY_BUFFER, 0, 0)); + ASSERT_NE(nullptr, event); + + GraphicsAllocation *allocation = event->getHwTimeStampNode()->getBaseGraphicsAllocation()->getDefaultGraphicsAllocation(); + ASSERT_NE(nullptr, allocation); + cl_event a = event.get(); + EventsRequest eventsRequest(0, nullptr, &a); + uint32_t streamBuffer[100] = {}; + NEO::LinearStream linearStream(streamBuffer, sizeof(streamBuffer)); + CsrDependencies deps = {}; + myCmdQ->processDispatchForMarker(*myCmdQ.get(), &linearStream, eventsRequest, deps); + EXPECT_GT(csr.makeResidentCalledTimes, 0u); +} + HWTEST_F(CommandQueueHwTest, givenCommandQueueWhenAskingForCacheFlushOnBcsThenReturnTrue) { auto pHwQ = static_cast *>(pCmdQ); @@ -1366,21 +1402,6 @@ HWTEST_F(CommandQueueHwTest, givenSizeWhenForceStatelessIsCalledThenCorrectValue EXPECT_FALSE(pCmdQHw->forceStateless(static_cast(smallSize))); } -class MockCommandStreamReceiverWithFailingFlushBatchedSubmission : public MockCommandStreamReceiver { - public: - using MockCommandStreamReceiver::MockCommandStreamReceiver; - bool flushBatchedSubmissions() override { - return false; - } -}; - -template -struct MockCommandQueueHwWithOverwrittenCsr : public CommandQueueHw { - using CommandQueueHw::CommandQueueHw; - MockCommandStreamReceiverWithFailingFlushBatchedSubmission *csr; - CommandStreamReceiver &getGpgpuCommandStreamReceiver() const override { return *csr; } -}; - HWTEST_F(CommandQueueHwTest, givenFlushWhenFlushBatchedSubmissionsFailsThenErrorIsRetured) { MockCommandQueueHwWithOverwrittenCsr cmdQueue(context, pClDevice, nullptr, false); MockCommandStreamReceiverWithFailingFlushBatchedSubmission csr(*pDevice->executionEnvironment, 0, pDevice->getDeviceBitfield()); diff --git a/shared/test/common/mocks/mock_command_stream_receiver.h b/shared/test/common/mocks/mock_command_stream_receiver.h index 0585699365..342923ac95 100644 --- a/shared/test/common/mocks/mock_command_stream_receiver.h +++ b/shared/test/common/mocks/mock_command_stream_receiver.h @@ -33,6 +33,7 @@ class MockCommandStreamReceiver : public CommandStreamReceiver { using CommandStreamReceiver::latestFlushedTaskCount; using CommandStreamReceiver::latestSentTaskCount; using CommandStreamReceiver::newResources; + using CommandStreamReceiver::osContext; using CommandStreamReceiver::preemptionAllocation; using CommandStreamReceiver::requiredThreadArbitrationPolicy; using CommandStreamReceiver::tagAddress;