diff --git a/opencl/source/command_queue/command_queue.cpp b/opencl/source/command_queue/command_queue.cpp index 438dea06ed..777702dadd 100644 --- a/opencl/source/command_queue/command_queue.cpp +++ b/opencl/source/command_queue/command_queue.cpp @@ -66,11 +66,11 @@ CommandQueue::CommandQueue(Context *context, ClDevice *device, const cl_queue_pr flushStamp.reset(new FlushStampTracker(true)); if (device) { + auto hwInfo = device->getHardwareInfo(); gpgpuEngine = &device->getDefaultEngine(); - if (gpgpuEngine->commandStreamReceiver->peekTimestampPacketWriteEnabled()) { + if (hwInfo.capabilityTable.blitterOperationsSupported || gpgpuEngine->commandStreamReceiver->peekTimestampPacketWriteEnabled()) { timestampPacketContainer = std::make_unique(); } - auto hwInfo = device->getHardwareInfo(); if (hwInfo.capabilityTable.blitterOperationsSupported) { auto &selectorCopyEngine = device->getDeviceById(0)->getSelectorCopyEngine(); bcsEngine = &device->getDeviceById(0)->getEngine(EngineHelpers::getBcsEngineType(hwInfo, selectorCopyEngine), false); diff --git a/opencl/source/command_queue/enqueue_common.h b/opencl/source/command_queue/enqueue_common.h index 2866f43a9d..390ca74348 100644 --- a/opencl/source/command_queue/enqueue_common.h +++ b/opencl/source/command_queue/enqueue_common.h @@ -202,7 +202,7 @@ void CommandQueueHw::enqueueHandler(Surface **surfacesForResidency, bool enqueueWithBlitAuxTranslation = HwHelperHw::isBlitAuxTranslationRequired(device->getHardwareInfo(), multiDispatchInfo); - if (getGpgpuCommandStreamReceiver().peekTimestampPacketWriteEnabled()) { + if (blitEnqueue || getGpgpuCommandStreamReceiver().peekTimestampPacketWriteEnabled()) { eventsRequest.fillCsrDependencies(csrDeps, getGpgpuCommandStreamReceiver(), CsrDependencies::DependenciesType::OnCsr); auto allocator = getGpgpuCommandStreamReceiver().getTimestampPacketAllocator(); diff --git a/opencl/source/helpers/task_information.cpp b/opencl/source/helpers/task_information.cpp index 8b21cdf517..ee5ebae01b 100644 --- a/opencl/source/helpers/task_information.cpp +++ b/opencl/source/helpers/task_information.cpp @@ -343,7 +343,7 @@ CompletionStamp &CommandWithoutKernel::submit(uint32_t taskLevel, bool terminate false //usePerDssBackedBuffer ); - UNRECOVERABLE_IF(!commandStreamReceiver.peekTimestampPacketWriteEnabled()); + UNRECOVERABLE_IF(!kernelOperation->blitEnqueue && !commandStreamReceiver.peekTimestampPacketWriteEnabled()); eventsRequest.fillCsrDependencies(dispatchFlags.csrDependencies, commandStreamReceiver, CsrDependencies::DependenciesType::OutOfCsr); makeTimestampPacketsResident(commandStreamReceiver); diff --git a/opencl/test/unit_test/command_queue/blit_enqueue_tests.cpp b/opencl/test/unit_test/command_queue/blit_enqueue_tests.cpp index 4bdf6b21c5..99b613a2c8 100644 --- a/opencl/test/unit_test/command_queue/blit_enqueue_tests.cpp +++ b/opencl/test/unit_test/command_queue/blit_enqueue_tests.cpp @@ -22,7 +22,8 @@ using namespace NEO; -struct BlitAuxTranslationTests : public ::testing::Test { +template +struct BlitEnqueueTests : public ::testing::Test { class BcsMockContext : public MockContext { public: BcsMockContext(ClDevice *device) : MockContext(device) { @@ -56,7 +57,7 @@ struct BlitAuxTranslationTests : public ::testing::Test { if (is32bit || !hwHelper.requiresAuxResolves()) { GTEST_SKIP(); } - DebugManager.flags.EnableTimestampPacket.set(1); + DebugManager.flags.EnableTimestampPacket.set(timestampPacketEnabled); DebugManager.flags.EnableBlitterOperationsForReadWriteBuffers.set(1); DebugManager.flags.ForceAuxTranslationMode.set(1); DebugManager.flags.CsrDispatchMode.set(static_cast(DispatchMode::ImmediateDispatch)); @@ -198,6 +199,8 @@ struct BlitAuxTranslationTests : public ::testing::Test { cl_int retVal = CL_SUCCESS; }; +using BlitAuxTranslationTests = BlitEnqueueTests<1>; + HWTEST_TEMPLATED_F(BlitAuxTranslationTests, givenBlitAuxTranslationWhenConstructingCommandBufferThenEnsureCorrectOrder) { using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT; @@ -811,3 +814,37 @@ HWTEST_TEMPLATED_F(BlitAuxTranslationTests, givenBlitTranslationWhenEnqueueIsCal EXPECT_EQ(1u, ultCsr->taskCount); EXPECT_TRUE(ultCsr->recordedDispatchFlags.implicitFlush); } + +using BlitEnqueueWithNoTimestampPacketTests = BlitEnqueueTests<0>; + +HWTEST_TEMPLATED_F(BlitEnqueueWithNoTimestampPacketTests, givenNoTimestampPacketsWritewhenEnqueueingBlitOperationThenEnginesAreSynchronized) { + using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT; + using MI_FLUSH_DW = typename FamilyType::MI_FLUSH_DW; + using WALKER_TYPE = typename FamilyType::WALKER_TYPE; + + const size_t bufferSize = 1u; + auto buffer = createBuffer(bufferSize, false); + auto ultCsr = static_cast *>(gpgpuCsr); + ASSERT_EQ(0u, ultCsr->taskCount); + + setMockKernelArgs(std::array{{buffer.get()}}); + commandQueue->enqueueKernel(mockKernel->mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr); + + char cpuBuffer[bufferSize]{}; + commandQueue->enqueueReadBuffer(buffer.get(), CL_FALSE, 0, bufferSize, cpuBuffer, nullptr, 0, nullptr, nullptr); + commandQueue->finish(); + + auto bcsCommands = getCmdList(bcsCsr->getCS(0)); + auto ccsCommands = getCmdList(commandQueue->getCS(0)); + + auto cmdFound = expectCommand(bcsCommands.begin(), bcsCommands.end()); + + cmdFound = expectMiFlush(cmdFound++, bcsCommands.end()); + auto miflushDwCmd = genCmdCast(*cmdFound); + const auto bcsSignalAddress = miflushDwCmd->getDestinationAddress(); + + cmdFound = expectCommand(ccsCommands.begin(), ccsCommands.end()); + + cmdFound = expectCommand(cmdFound++, ccsCommands.end()); + verifySemaphore(cmdFound, bcsSignalAddress); +} diff --git a/opencl/test/unit_test/command_queue/command_queue_tests.cpp b/opencl/test/unit_test/command_queue/command_queue_tests.cpp index 743c017e43..7d00ef334b 100644 --- a/opencl/test/unit_test/command_queue/command_queue_tests.cpp +++ b/opencl/test/unit_test/command_queue/command_queue_tests.cpp @@ -1117,3 +1117,18 @@ TEST(CommandQueue, GivenCommandQueueWhenEnqueueInitDispatchGlobalsCalledThenSucc nullptr); EXPECT_EQ(CL_SUCCESS, result); } + +TEST(CommandQueue, givenBlitterOperationsSupportedWhenCreatingQueueThenTimestampPacketIsCreated) { + DebugManagerStateRestore restore; + DebugManager.flags.EnableTimestampPacket.set(0); + + MockContext context{}; + HardwareInfo *hwInfo = context.getDevice(0)->getRootDeviceEnvironment().getMutableHardwareInfo(); + if (!HwHelper::get(hwInfo->platform.eDisplayCoreFamily).obtainBlitterPreference(*hwInfo)) { + GTEST_SKIP(); + } + + hwInfo->capabilityTable.blitterOperationsSupported = true; + MockCommandQueue cmdQ(&context, context.getDevice(0), 0); + EXPECT_NE(nullptr, cmdQ.timestampPacketContainer); +}