diff --git a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl index 7c96520df0..9c8885fb41 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl @@ -114,7 +114,7 @@ ze_result_t CommandListCoreFamilyImmediate::executeCommandListImm if (this->isSyncModeQueue) { auto timeoutMicroseconds = NEO::TimeoutControls::maxTimeout; - const auto waitStatus = this->csr->waitForCompletionWithTimeout(false, timeoutMicroseconds, completionStamp.taskCount); + const auto waitStatus = this->csr->waitForCompletionWithTimeout(NEO::WaitParams{false, false, timeoutMicroseconds}, completionStamp.taskCount); if (waitStatus == NEO::WaitStatus::GpuHang) { return ZE_RESULT_ERROR_DEVICE_LOST; } @@ -184,7 +184,7 @@ ze_result_t CommandListCoreFamilyImmediate::appendBarrier( this->csr->flushNonKernelTask(nullptr, 0, 0, args, false, false, false); if (this->isSyncModeQueue) { auto timeoutMicroseconds = NEO::TimeoutControls::maxTimeout; - const auto waitStatus = this->csr->waitForCompletionWithTimeout(false, timeoutMicroseconds, this->csr->peekTaskCount()); + const auto waitStatus = this->csr->waitForCompletionWithTimeout(NEO::WaitParams{false, false, timeoutMicroseconds}, this->csr->peekTaskCount()); if (waitStatus == NEO::WaitStatus::GpuHang) { return ZE_RESULT_ERROR_DEVICE_LOST; } @@ -270,7 +270,7 @@ ze_result_t CommandListCoreFamilyImmediate::appendSignalEvent(ze_ this->csr->flushNonKernelTask(&event->getAllocation(this->device), event->getGpuAddress(this->device), Event::STATE_SIGNALED, args, false, false, false); if (this->isSyncModeQueue) { auto timeoutMicroseconds = NEO::TimeoutControls::maxTimeout; - const auto waitStatus = this->csr->waitForCompletionWithTimeout(false, timeoutMicroseconds, this->csr->peekTaskCount()); + const auto waitStatus = this->csr->waitForCompletionWithTimeout(NEO::WaitParams{false, false, timeoutMicroseconds}, this->csr->peekTaskCount()); if (waitStatus == NEO::WaitStatus::GpuHang) { return ZE_RESULT_ERROR_DEVICE_LOST; } @@ -299,7 +299,7 @@ ze_result_t CommandListCoreFamilyImmediate::appendEventReset(ze_e this->csr->flushNonKernelTask(&event->getAllocation(this->device), event->getGpuAddress(this->device), Event::STATE_CLEARED, args, false, false, false); if (this->isSyncModeQueue) { auto timeoutMicroseconds = NEO::TimeoutControls::maxTimeout; - const auto waitStatus = this->csr->waitForCompletionWithTimeout(false, timeoutMicroseconds, this->csr->peekTaskCount()); + const auto waitStatus = this->csr->waitForCompletionWithTimeout(NEO::WaitParams{false, false, timeoutMicroseconds}, this->csr->peekTaskCount()); if (waitStatus == NEO::WaitStatus::GpuHang) { return ZE_RESULT_ERROR_DEVICE_LOST; } diff --git a/level_zero/core/source/cmdlist/cmdlist_imp.cpp b/level_zero/core/source/cmdlist/cmdlist_imp.cpp index 0718ad3907..202ad09314 100644 --- a/level_zero/core/source/cmdlist/cmdlist_imp.cpp +++ b/level_zero/core/source/cmdlist/cmdlist_imp.cpp @@ -29,7 +29,7 @@ CommandListAllocatorFn commandListFactoryImmediate[IGFX_MAX_PRODUCT] = {}; ze_result_t CommandListImp::destroy() { if (this->cmdListType == CommandListType::TYPE_IMMEDIATE && this->isFlushTaskSubmissionEnabled && !this->isSyncModeQueue) { auto timeoutMicroseconds = NEO::TimeoutControls::maxTimeout; - this->csr->waitForCompletionWithTimeout(false, timeoutMicroseconds, this->csr->peekTaskCount()); + this->csr->waitForCompletionWithTimeout(NEO::WaitParams{false, false, timeoutMicroseconds}, this->csr->peekTaskCount()); } delete this; return ZE_RESULT_SUCCESS; diff --git a/level_zero/core/source/cmdqueue/cmdqueue.cpp b/level_zero/core/source/cmdqueue/cmdqueue.cpp index 85e92ab799..bdad7f8735 100644 --- a/level_zero/core/source/cmdqueue/cmdqueue.cpp +++ b/level_zero/core/source/cmdqueue/cmdqueue.cpp @@ -8,6 +8,7 @@ #include "shared/source/command_stream/command_stream_receiver.h" #include "shared/source/command_stream/csr_definitions.h" #include "shared/source/command_stream/linear_stream.h" +#include "shared/source/command_stream/queue_throttle.h" #include "shared/source/command_stream/wait_status.h" #include "shared/source/debug_settings/debug_settings_manager.h" #include "shared/source/memory_manager/memory_manager.h" @@ -101,7 +102,7 @@ NEO::SubmissionStatus CommandQueueImp::submitBatchBuffer(size_t offset, NEO::Res ze_result_t CommandQueueImp::synchronize(uint64_t timeout) { if ((timeout == std::numeric_limits::max()) && useKmdWaitFunction) { auto &waitPair = buffers.getCurrentFlushStamp(); - const auto waitStatus = csr->waitForTaskCountWithKmdNotifyFallback(waitPair.first, waitPair.second, false, false); + const auto waitStatus = csr->waitForTaskCountWithKmdNotifyFallback(waitPair.first, waitPair.second, false, NEO::QueueThrottle::MEDIUM); if (waitStatus == NEO::WaitStatus::GpuHang) { return ZE_RESULT_ERROR_DEVICE_LOST; } @@ -124,7 +125,7 @@ ze_result_t CommandQueueImp::synchronizeByPollingForTaskCount(uint64_t timeout) timeoutMicroseconds = NEO::TimeoutControls::maxTimeout; } - const auto waitStatus = csr->waitForCompletionWithTimeout(enableTimeout, timeoutMicroseconds, taskCountToWait); + const auto waitStatus = csr->waitForCompletionWithTimeout(NEO::WaitParams{false, enableTimeout, timeoutMicroseconds}, taskCountToWait); if (waitStatus == NEO::WaitStatus::NotReady) { return ZE_RESULT_NOT_READY; } @@ -239,7 +240,7 @@ void CommandQueueImp::CommandBufferManager::switchBuffers(NEO::CommandStreamRece auto completionId = flushId[bufferUse]; if (completionId.second != 0u) { UNRECOVERABLE_IF(csr == nullptr); - csr->waitForTaskCountWithKmdNotifyFallback(completionId.first, completionId.second, false, false); + csr->waitForTaskCountWithKmdNotifyFallback(completionId.first, completionId.second, false, NEO::QueueThrottle::MEDIUM); } } diff --git a/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_2.cpp b/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_2.cpp index a78d3182e9..8d95284c05 100644 --- a/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_2.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_2.cpp @@ -145,16 +145,16 @@ struct SynchronizeCsr : public NEO::UltCommandStreamReceiver { memset(const_cast(CommandStreamReceiver::tagAddress), 0xFFFFFFFF, tagSize * sizeof(uint32_t)); } - WaitStatus waitForCompletionWithTimeout(bool enableTimeout, int64_t timeoutMs, uint32_t taskCountToWait) override { - enableTimeoutSet = enableTimeout; + WaitStatus waitForCompletionWithTimeout(const WaitParams ¶ms, uint32_t taskCountToWait) override { + enableTimeoutSet = params.enableTimeout; waitForComplitionCalledTimes++; partitionCountSet = this->activePartitions; return waitForCompletionWithTimeoutResult; } - WaitStatus waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool quickKmdSleep, bool forcePowerSavingMode) override { + WaitStatus waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool quickKmdSleep, NEO::QueueThrottle throttle) override { waitForTaskCountWithKmdNotifyFallbackCalled++; - return NEO::UltCommandStreamReceiver::waitForTaskCountWithKmdNotifyFallback(taskCountToWait, flushStampToWait, quickKmdSleep, forcePowerSavingMode); + return NEO::UltCommandStreamReceiver::waitForTaskCountWithKmdNotifyFallback(taskCountToWait, flushStampToWait, quickKmdSleep, throttle); } static constexpr size_t tagSize = 128; @@ -407,7 +407,7 @@ struct TestCmdQueueCsr : public NEO::UltCommandStreamReceiver { : NEO::UltCommandStreamReceiver(const_cast(executionEnvironment), 0, deviceBitfield) { } - ADDMETHOD_NOBASE(waitForCompletionWithTimeout, NEO::WaitStatus, NEO::WaitStatus::NotReady, (bool enableTimeout, int64_t timeoutMs, uint32_t taskCountToWait)); + ADDMETHOD_NOBASE(waitForCompletionWithTimeout, NEO::WaitStatus, NEO::WaitStatus::NotReady, (const WaitParams ¶ms, uint32_t taskCountToWait)); }; HWTEST_F(CommandQueueSynchronizeTest, givenSinglePartitionCountWhenWaitFunctionFailsThenReturnNotReady) { diff --git a/opencl/source/command_queue/command_queue.cpp b/opencl/source/command_queue/command_queue.cpp index 1a1e5932ac..e336300787 100644 --- a/opencl/source/command_queue/command_queue.cpp +++ b/opencl/source/command_queue/command_queue.cpp @@ -256,12 +256,10 @@ WaitStatus CommandQueue::waitUntilComplete(uint32_t gpgpuTaskCountToWait, Range< DBG_LOG(LogTaskCounts, __FUNCTION__, "Line: ", __LINE__, "Current taskCount:", getHwTag()); if (!skipWait) { - bool forcePowerSavingMode = this->throttle == QueueThrottle::LOW; - waitStatus = getGpgpuCommandStreamReceiver().waitForTaskCountWithKmdNotifyFallback(gpgpuTaskCountToWait, flushStampToWait, useQuickKmdSleep, - forcePowerSavingMode); + this->getThrottle()); if (waitStatus == WaitStatus::GpuHang) { return WaitStatus::GpuHang; } @@ -276,7 +274,7 @@ WaitStatus CommandQueue::waitUntilComplete(uint32_t gpgpuTaskCountToWait, Range< for (const CopyEngineState ©Engine : copyEnginesToWait) { auto bcsCsr = getBcsCommandStreamReceiver(copyEngine.engineType); - waitStatus = bcsCsr->waitForTaskCountWithKmdNotifyFallback(copyEngine.taskCount, 0, false, false); + waitStatus = bcsCsr->waitForTaskCountWithKmdNotifyFallback(copyEngine.taskCount, 0, false, this->getThrottle()); if (waitStatus == WaitStatus::GpuHang) { return WaitStatus::GpuHang; } diff --git a/opencl/test/unit_test/aub_tests/command_stream/copy_engine_aub_tests_xehp_and_later.h b/opencl/test/unit_test/aub_tests/command_stream/copy_engine_aub_tests_xehp_and_later.h index bf72ae98dd..d772612b60 100644 --- a/opencl/test/unit_test/aub_tests/command_stream/copy_engine_aub_tests_xehp_and_later.h +++ b/opencl/test/unit_test/aub_tests/command_stream/copy_engine_aub_tests_xehp_and_later.h @@ -253,7 +253,7 @@ void CopyEngineXeHPAndLater::givenDstHostPtrWhenBlitC executeBlitCommand(blitProperties, false); - bcsCsr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, false); + bcsCsr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, QueueThrottle::MEDIUM); expectMemoryNotEqual(getGpuAddress(*srcCompressedBuffer), compressiblePattern.get(), bufferSize, 0, 0); expectMemory(dstHostPtr.get(), compressiblePattern.get(), bufferSize, 0, 0); @@ -275,7 +275,7 @@ void CopyEngineXeHPAndLater::givenDstHostPtrWhenBlitC executeBlitCommand(blitProperties, false); - bcsCsr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, false); + bcsCsr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, QueueThrottle::MEDIUM); expectMemory(getGpuAddress(*srcNotCompressedLocalBuffer), compressiblePattern.get(), bufferSize, 0, 0); expectMemory(dstHostPtr.get(), compressiblePattern.get(), bufferSize, 0, 0); @@ -326,7 +326,7 @@ void CopyEngineXeHPAndLater::givenBufferWithOffsetWhe executeBlitCommand(blitProperties, false); - bcsCsr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, false); + bcsCsr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, QueueThrottle::MEDIUM); expectMemoryNotEqual(dstHostPtr.get(), writePattern.get(), offset, 0, 0); expectMemoryNotEqual(ptrOffset(dstHostPtr.get(), 1), ptrOffset(writePattern.get(), offset), bufferSize - offset - 1, 0, 0); @@ -409,7 +409,7 @@ void CopyEngineXeHPAndLater::givenCompressedBufferWhe bcsCsr->getClearColorAllocation()); executeBlitCommand(blitProperties, false); - bcsCsr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, false); + bcsCsr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, QueueThrottle::MEDIUM); expectMemory(getGpuAddress(*buffer), compressiblePattern.get(), bufferSize, 0, 0); } @@ -421,7 +421,7 @@ void CopyEngineXeHPAndLater::givenCompressedBufferWhe bcsCsr->getClearColorAllocation()); executeBlitCommand(blitProperties, false); - bcsCsr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, false); + bcsCsr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, QueueThrottle::MEDIUM); expectMemoryNotEqual(getGpuAddress(*buffer), compressiblePattern.get(), bufferSize, 0, 0); } @@ -492,7 +492,7 @@ void CopyEngineXeHPAndLater::givenReadBufferRectWithO executeBlitCommand(blitProperties, false); - bcsCsr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, false); + bcsCsr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, QueueThrottle::MEDIUM); pSrcMemory = ptrOffset(pSrcMemory, 0); int *destGpuAddress = reinterpret_cast(allocation->getGpuAddress()); @@ -550,7 +550,7 @@ void CopyEngineXeHPAndLater::givenWriteBufferRectWith executeBlitCommand(blitProperties, false); - bcsCsr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, false); + bcsCsr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, QueueThrottle::MEDIUM); pSrcMemory = ptrOffset(pSrcMemory, 0); int *destGpuAddress = reinterpret_cast(allocation->getGpuAddress()); @@ -598,7 +598,7 @@ void CopyEngineXeHPAndLater::givenCopyBufferRectWithO executeBlitCommand(blitProperties, false); - bcsCsr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, false); + bcsCsr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, QueueThrottle::MEDIUM); pSrcMemory = ptrOffset(pSrcMemory, 0); @@ -647,7 +647,7 @@ void CopyEngineXeHPAndLater::givenCopyBufferRectWithB dstSlicePitch, //dstSlicePitch clearColorAllocation); //clearColorAllocation executeBlitCommand(blitProperties, false); - bcsCsr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, false); + bcsCsr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, QueueThrottle::MEDIUM); size_t dstOffset = dstOrigin[0] + dstOrigin[1] * dstRowPitch + dstOrigin[2] * dstSlicePitch; 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 7cdfb00cd8..dba2c8cc72 100644 --- a/opencl/test/unit_test/command_queue/command_queue_tests.cpp +++ b/opencl/test/unit_test/command_queue/command_queue_tests.cpp @@ -960,7 +960,7 @@ class CommandStreamReceiverHwMock : public CommandStreamReceiverHw { const DeviceBitfield deviceBitfield) : CommandStreamReceiverHw(executionEnvironment, rootDeviceIndex, deviceBitfield) {} - WaitStatus waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool forcePowerSavingMode) override { + WaitStatus waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, QueueThrottle throttle) override { waitForTaskCountWithKmdNotifyFallbackCounter++; return waitForTaskCountWithKmdNotifyFallbackReturnValue; } diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_3_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_3_tests.cpp index c5f12c0dae..f32c8dfa4d 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_3_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_3_tests.cpp @@ -688,7 +688,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenWaitForT auto cmdBuffer = cmdBufferList.peekHead(); EXPECT_EQ(1u, cmdBuffer->taskCount); - mockCsr->waitForCompletionWithTimeout(false, 1, 1); + mockCsr->waitForCompletionWithTimeout(WaitParams{false, false, 1}, 1); EXPECT_EQ(1u, mockCsr->peekLatestFlushedTaskCount()); @@ -1889,5 +1889,5 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenWaitForCompletionWithTimeoutI mockCsr.latestSentTaskCount = 1; auto cmdBuffer = std::make_unique(*pDevice); mockCsr.submissionAggregator->recordCommandBuffer(cmdBuffer.release()); - EXPECT_EQ(NEO::WaitStatus::NotReady, mockCsr.waitForCompletionWithTimeout(false, 0, 1)); + EXPECT_EQ(NEO::WaitStatus::NotReady, mockCsr.waitForCompletionWithTimeout(WaitParams{false, false, 0}, 1)); } diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_4_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_4_tests.cpp index 183483972a..e8daa5760f 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_4_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_4_tests.cpp @@ -739,6 +739,24 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenTagValueNotMeetingTaskCountTo CpuIntrinsicsTests::pauseAddress = mockCsr->tagAddress; CpuIntrinsicsTests::pauseValue = taskCountToWait; - const auto ret = mockCsr->waitForCompletionWithTimeout(false, 1, taskCountToWait); + const auto ret = mockCsr->waitForCompletionWithTimeout(WaitParams{false, false, 1}, taskCountToWait); EXPECT_EQ(NEO::WaitStatus::Ready, ret); } + +HWTEST_F(CommandStreamReceiverFlushTaskTests, givenTagValueNotMeetingTaskCountToWaitAndIndefinitelyPollWhenWaitForCompletionThenDoNotCallWaitUtils) { + VariableBackup backupPauseAddress(&CpuIntrinsicsTests::pauseAddress); + VariableBackup backupPauseValue(&CpuIntrinsicsTests::pauseValue); + + auto mockCsr = new MockCsrHw2(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); + pDevice->resetCommandStreamReceiver(mockCsr); + + uint32_t taskCountToWait = 2u; + + *mockCsr->tagAddress = 1u; + + CpuIntrinsicsTests::pauseAddress = mockCsr->tagAddress; + CpuIntrinsicsTests::pauseValue = taskCountToWait; + + const auto ret = mockCsr->waitForCompletionWithTimeout(WaitParams{true, true, 10}, taskCountToWait); + EXPECT_EQ(NEO::WaitStatus::NotReady, ret); +} \ No newline at end of file diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp index 12e6eab3b4..b7cbd715d6 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp @@ -471,7 +471,7 @@ HWTEST_F(UltCommandStreamReceiverTest, givenSinglePartitionWhenCallingWaitKmdNot commandStreamReceiver.callBaseWaitForCompletionWithTimeout = false; commandStreamReceiver.returnWaitForCompletionWithTimeout = NEO::WaitStatus::NotReady; - commandStreamReceiver.waitForTaskCountWithKmdNotifyFallback(0, 0, false, false); + commandStreamReceiver.waitForTaskCountWithKmdNotifyFallback(0, 0, false, QueueThrottle::MEDIUM); EXPECT_EQ(2u, commandStreamReceiver.waitForCompletionWithTimeoutTaskCountCalled); } @@ -480,7 +480,7 @@ HWTEST_F(UltCommandStreamReceiverTest, givenMultiplePartitionsWhenCallingWaitKmd commandStreamReceiver.callBaseWaitForCompletionWithTimeout = false; commandStreamReceiver.returnWaitForCompletionWithTimeout = NEO::WaitStatus::NotReady; - commandStreamReceiver.waitForTaskCountWithKmdNotifyFallback(0, 0, false, false); + commandStreamReceiver.waitForTaskCountWithKmdNotifyFallback(0, 0, false, QueueThrottle::MEDIUM); EXPECT_EQ(2u, commandStreamReceiver.waitForCompletionWithTimeoutTaskCountCalled); } diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_2_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_2_tests.cpp index dd99db74a4..5f23799e99 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_2_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_2_tests.cpp @@ -612,12 +612,12 @@ HWTEST_F(BcsTests, whenBlitFromHostPtrCalledThenCallWaitWithKmdFallback) { using UltCommandStreamReceiver::UltCommandStreamReceiver; WaitStatus waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, - bool useQuickKmdSleep, bool forcePowerSavingMode) override { + bool useQuickKmdSleep, QueueThrottle throttle) override { waitForTaskCountWithKmdNotifyFallbackCalled++; taskCountToWaitPassed = taskCountToWait; flushStampToWaitPassed = flushStampToWait; useQuickKmdSleepPassed = useQuickKmdSleep; - forcePowerSavingModePassed = forcePowerSavingMode; + throttlePassed = throttle; return WaitStatus::Ready; } @@ -625,7 +625,7 @@ HWTEST_F(BcsTests, whenBlitFromHostPtrCalledThenCallWaitWithKmdFallback) { uint32_t taskCountToWaitPassed = 0; uint32_t waitForTaskCountWithKmdNotifyFallbackCalled = 0; bool useQuickKmdSleepPassed = false; - bool forcePowerSavingModePassed = false; + QueueThrottle throttlePassed = QueueThrottle::MEDIUM; }; auto myMockCsr = std::make_unique(*pDevice->getExecutionEnvironment(), pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); @@ -658,7 +658,7 @@ HWTEST_F(BcsTests, whenBlitFromHostPtrCalledThenCallWaitWithKmdFallback) { EXPECT_EQ(myMockCsr->taskCount, myMockCsr->taskCountToWaitPassed); EXPECT_EQ(myMockCsr->flushStamp->peekStamp(), myMockCsr->flushStampToWaitPassed); EXPECT_FALSE(myMockCsr->useQuickKmdSleepPassed); - EXPECT_FALSE(myMockCsr->forcePowerSavingModePassed); + EXPECT_EQ(myMockCsr->throttlePassed, QueueThrottle::MEDIUM); EXPECT_EQ(1u, myMockCsr->activePartitions); } diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_with_aub_dump_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_with_aub_dump_tests.cpp index c7414f2aa0..43d4a1184f 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_with_aub_dump_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_with_aub_dump_tests.cpp @@ -248,11 +248,11 @@ HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenCsrWithAubDumpWhenWait csrWithAubDump.aubCSR.reset(mockAubCsr); EXPECT_FALSE(mockAubCsr->pollForCompletionCalled); - csrWithAubDump.waitForTaskCountWithKmdNotifyFallback(1, 0, false, false); + csrWithAubDump.waitForTaskCountWithKmdNotifyFallback(1, 0, false, QueueThrottle::MEDIUM); EXPECT_TRUE(mockAubCsr->pollForCompletionCalled); csrWithAubDump.aubCSR.reset(nullptr); - csrWithAubDump.waitForTaskCountWithKmdNotifyFallback(1, 0, false, false); + csrWithAubDump.waitForTaskCountWithKmdNotifyFallback(1, 0, false, QueueThrottle::MEDIUM); } HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenCsrWithAubDumpWhenPollForCompletionCalledThenAubCsrPollForCompletionCalled) { diff --git a/opencl/test/unit_test/event/event_tests.cpp b/opencl/test/unit_test/event/event_tests.cpp index ca822193b5..5c8eef221f 100644 --- a/opencl/test/unit_test/event/event_tests.cpp +++ b/opencl/test/unit_test/event/event_tests.cpp @@ -1513,9 +1513,9 @@ struct TestEventCsr : public UltCommandStreamReceiver { TestEventCsr(const ExecutionEnvironment &executionEnvironment, const DeviceBitfield deviceBitfield) : UltCommandStreamReceiver(const_cast(executionEnvironment), 0, deviceBitfield) {} - WaitStatus waitForCompletionWithTimeout(bool enableTimeout, int64_t timeoutMs, uint32_t taskCountToWait) override { + WaitStatus waitForCompletionWithTimeout(const WaitParams ¶ms, uint32_t taskCountToWait) override { waitForCompletionWithTimeoutCalled++; - waitForCompletionWithTimeoutParamsPassed.push_back({enableTimeout, timeoutMs, taskCountToWait}); + waitForCompletionWithTimeoutParamsPassed.push_back({params.enableTimeout, params.waitTimeout, taskCountToWait}); return waitForCompletionWithTimeoutResult; } diff --git a/opencl/test/unit_test/helpers/kmd_notify_tests.cpp b/opencl/test/unit_test/helpers/kmd_notify_tests.cpp index f1ad018790..8b7849e988 100644 --- a/opencl/test/unit_test/helpers/kmd_notify_tests.cpp +++ b/opencl/test/unit_test/helpers/kmd_notify_tests.cpp @@ -89,9 +89,9 @@ struct KmdNotifyTests : public ::testing::Test { bool waitForFlushStampResult = true; StackVec waitForFlushStampParamsPassed{}; - WaitStatus waitForCompletionWithTimeout(bool enableTimeout, int64_t timeoutMs, uint32_t taskCountToWait) override { + WaitStatus waitForCompletionWithTimeout(const WaitParams ¶ms, uint32_t taskCountToWait) override { waitForCompletionWithTimeoutCalled++; - waitForCompletionWithTimeoutParamsPassed.push_back({enableTimeout, timeoutMs, taskCountToWait}); + waitForCompletionWithTimeoutParamsPassed.push_back({params.enableTimeout, params.waitTimeout, taskCountToWait}); return waitForCompletionWithTimeoutResult; } @@ -226,7 +226,7 @@ HWTEST_F(KmdNotifyTests, givenZeroFlushStampWhenWaitIsCalledThenDisableTimeout) EXPECT_TRUE(device->getHardwareInfo().capabilityTable.kmdNotifyProperties.enableKmdNotify); - csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 0, false, false); + csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 0, false, QueueThrottle::MEDIUM); EXPECT_EQ(0u, csr->waitForFlushStampCalled); EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled); EXPECT_EQ(false, csr->waitForCompletionWithTimeoutParamsPassed[0].enableTimeout); @@ -242,7 +242,7 @@ HWTEST_F(KmdNotifyTests, givenNonQuickSleepRequestWhenItsSporadicWaitThenOverrid int64_t timeSinceLastWait = mockKmdNotifyHelper->properties->delayQuickKmdSleepForSporadicWaitsMicroseconds + 1; mockKmdNotifyHelper->lastWaitForCompletionTimestampUs = mockKmdNotifyHelper->getMicrosecondsSinceEpoch() - timeSinceLastWait; - csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, false); + csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, QueueThrottle::MEDIUM); EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled); EXPECT_EQ(expectedDelay, csr->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs); } @@ -253,7 +253,7 @@ HWTEST_F(KmdNotifyTests, givenNonQuickSleepRequestWhenItsNotSporadicWaitThenOver auto expectedDelay = device->getHardwareInfo().capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds; - csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, false); + csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, QueueThrottle::MEDIUM); EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled); EXPECT_EQ(expectedDelay, csr->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs); } @@ -262,7 +262,7 @@ HWTEST_F(KmdNotifyTests, givenKmdNotifyDisabledWhenPowerSavingModeIsRequestedThe overrideKmdNotifyParams(false, 3, false, 2, false, 9999999, false, 0); auto csr = createMockCsr(); - csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, true); + csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, QueueThrottle::LOW); EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled); EXPECT_EQ(true, csr->waitForCompletionWithTimeoutParamsPassed[0].enableTimeout); EXPECT_EQ(1, csr->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs); @@ -298,7 +298,7 @@ HWTEST_F(KmdNotifyTests, givenQuickSleepRequestWhenItsSporadicWaitOptimizationIs auto expectedDelay = device->getHardwareInfo().capabilityTable.kmdNotifyProperties.delayQuickKmdSleepMicroseconds; - csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, true, false); + csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, true, QueueThrottle::MEDIUM); EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled); EXPECT_EQ(expectedDelay, csr->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs); } @@ -309,7 +309,7 @@ HWTEST_F(KmdNotifyTests, givenTaskCountEqualToHwTagWhenWaitCalledThenDontMultipl auto expectedTimeout = device->getHardwareInfo().capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds; - csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, false); + csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, QueueThrottle::MEDIUM); EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled); EXPECT_EQ(true, csr->waitForCompletionWithTimeoutParamsPassed[0].enableTimeout); EXPECT_EQ(expectedTimeout, csr->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs); @@ -321,7 +321,7 @@ HWTEST_F(KmdNotifyTests, givenTaskCountLowerThanHwTagWhenWaitCalledThenDontMulti auto expectedTimeout = device->getHardwareInfo().capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds; - csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, false); + csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false, QueueThrottle::MEDIUM); EXPECT_EQ(1u, csr->waitForCompletionWithTimeoutCalled); EXPECT_EQ(true, csr->waitForCompletionWithTimeoutParamsPassed[0].enableTimeout); EXPECT_EQ(expectedTimeout, csr->waitForCompletionWithTimeoutParamsPassed[0].timeoutMs); @@ -334,7 +334,7 @@ HWTEST_F(KmdNotifyTests, givenDefaultCommandStreamReceiverWhenWaitCalledThenUpda EXPECT_NE(0, mockKmdNotifyHelper->lastWaitForCompletionTimestampUs.load()); EXPECT_EQ(1u, mockKmdNotifyHelper->updateLastWaitForCompletionTimestampCalled); - csr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, false); + csr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, QueueThrottle::MEDIUM); EXPECT_EQ(2u, mockKmdNotifyHelper->updateLastWaitForCompletionTimestampCalled); } @@ -344,7 +344,7 @@ HWTEST_F(KmdNotifyTests, givenDefaultCommandStreamReceiverWithDisabledSporadicWa auto csr = createMockCsr(); EXPECT_EQ(0, mockKmdNotifyHelper->lastWaitForCompletionTimestampUs.load()); - csr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, false); + csr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, QueueThrottle::MEDIUM); EXPECT_EQ(0u, mockKmdNotifyHelper->updateLastWaitForCompletionTimestampCalled); } @@ -366,8 +366,7 @@ TEST_F(KmdNotifyTests, givenTaskCountDiffLowerThanMinimumToCheckAcLineWhenObtain EXPECT_TRUE(taskCountToWait - hwTag < KmdNotifyConstants::minimumTaskCountDiffToCheckAcLine); EXPECT_EQ(10u, KmdNotifyConstants::minimumTaskCountDiffToCheckAcLine); - int64_t timeout = 0; - helper.obtainTimeoutParams(timeout, false, hwTag, taskCountToWait, 1, false, true, false); + helper.obtainTimeoutParams(false, hwTag, taskCountToWait, 1, QueueThrottle::MEDIUM, true, false); EXPECT_EQ(0u, helper.updateAcLineStatusCalled); } @@ -381,8 +380,7 @@ TEST_F(KmdNotifyTests, givenTaskCountDiffGreaterThanMinimumToCheckAcLineAndDisab EXPECT_TRUE(taskCountToWait - hwTag > KmdNotifyConstants::minimumTaskCountDiffToCheckAcLine); EXPECT_EQ(10u, KmdNotifyConstants::minimumTaskCountDiffToCheckAcLine); - int64_t timeout = 0; - helper.obtainTimeoutParams(timeout, false, hwTag, taskCountToWait, 1, false, true, false); + helper.obtainTimeoutParams(false, hwTag, taskCountToWait, 1, QueueThrottle::MEDIUM, true, false); EXPECT_EQ(1u, helper.updateAcLineStatusCalled); } @@ -390,11 +388,20 @@ TEST_F(KmdNotifyTests, givenTaskCountDiffGreaterThanMinimumToCheckAcLineAndDisab TEST_F(KmdNotifyTests, givenKmdWaitModeNotActiveWhenObtainTimeoutParamsThenFalseIsReturned) { MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties)); - int64_t timeout = 0; - auto enableTimeout = helper.obtainTimeoutParams(timeout, false, 1, 1, 1, false, false, false); + auto params = helper.obtainTimeoutParams(false, 1, 1, 1, QueueThrottle::MEDIUM, false, false); - EXPECT_FALSE(enableTimeout); - EXPECT_FALSE(timeout); + EXPECT_FALSE(params.enableTimeout); + EXPECT_FALSE(params.waitTimeout); +} + +TEST_F(KmdNotifyTests, givenHighThrottleWhenObtainTimeoutParamsThenIndefinitelyPollSetToTrue) { + MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties)); + + auto params = helper.obtainTimeoutParams(false, 1, 1, 1, QueueThrottle::HIGH, false, false); + + EXPECT_FALSE(params.enableTimeout); + EXPECT_FALSE(params.waitTimeout); + EXPECT_TRUE(params.indefinitelyPoll); } TEST_F(KmdNotifyTests, givenTaskCountDiffGreaterThanMinimumToCheckAcLineAndEnabledKmdNotifyWhenObtainingTimeoutPropertiesThenDontCheck) { @@ -406,8 +413,7 @@ TEST_F(KmdNotifyTests, givenTaskCountDiffGreaterThanMinimumToCheckAcLineAndEnabl EXPECT_TRUE(taskCountToWait - hwTag > KmdNotifyConstants::minimumTaskCountDiffToCheckAcLine); EXPECT_EQ(10u, KmdNotifyConstants::minimumTaskCountDiffToCheckAcLine); - int64_t timeout = 0; - helper.obtainTimeoutParams(timeout, false, hwTag, taskCountToWait, 1, false, true, false); + helper.obtainTimeoutParams(false, hwTag, taskCountToWait, 1, QueueThrottle::MEDIUM, true, false); EXPECT_EQ(0u, helper.updateAcLineStatusCalled); } @@ -417,11 +423,10 @@ TEST_F(KmdNotifyTests, givenDisabledKmdNotifyMechanismWhenAcLineIsDisconnectedTh MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties)); helper.acLineConnected = false; - int64_t timeout = 0; - bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, 2, false, true, false); + auto params = helper.obtainTimeoutParams(false, 1, 2, 2, QueueThrottle::MEDIUM, true, false); - EXPECT_TRUE(timeoutEnabled); - EXPECT_EQ(KmdNotifyConstants::timeoutInMicrosecondsForDisconnectedAcLine, timeout); + EXPECT_TRUE(params.enableTimeout); + EXPECT_EQ(KmdNotifyConstants::timeoutInMicrosecondsForDisconnectedAcLine, params.waitTimeout); EXPECT_EQ(10000, KmdNotifyConstants::timeoutInMicrosecondsForDisconnectedAcLine); } @@ -431,11 +436,10 @@ TEST_F(KmdNotifyTests, givenEnabledKmdNotifyMechanismWhenAcLineIsDisconnectedThe MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties)); helper.acLineConnected = false; - int64_t timeout = 0; - bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, 2, false, true, false); + auto params = helper.obtainTimeoutParams(false, 1, 2, 2, QueueThrottle::MEDIUM, true, false); - EXPECT_TRUE(timeoutEnabled); - EXPECT_EQ(hwInfo->capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds, timeout); + EXPECT_TRUE(params.enableTimeout); + EXPECT_EQ(hwInfo->capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds, params.waitTimeout); } TEST_F(KmdNotifyTests, givenDisabledKmdNotifyMechanismAndFlushStampIsZeroWhenAcLineIsDisconnectedThenDontForceEnableTimeout) { @@ -443,11 +447,10 @@ TEST_F(KmdNotifyTests, givenDisabledKmdNotifyMechanismAndFlushStampIsZeroWhenAcL MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties)); helper.acLineConnected = false; - int64_t timeout = 0; FlushStamp flushStampToWait = 0; - bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, flushStampToWait, false, true, false); + auto params = helper.obtainTimeoutParams(false, 1, 2, flushStampToWait, QueueThrottle::MEDIUM, true, false); - EXPECT_FALSE(timeoutEnabled); + EXPECT_FALSE(params.enableTimeout); } TEST_F(KmdNotifyTests, givenDisabledKmdNotifyMechanismWhenPowerSavingModeIsSetThenKmdNotifyMechanismIsUsedAndReturnsShortestWaitingTimePossible) { @@ -457,22 +460,20 @@ TEST_F(KmdNotifyTests, givenDisabledKmdNotifyMechanismWhenPowerSavingModeIsSetTh MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties)); helper.acLineConnected = false; - int64_t timeout = 0; FlushStamp flushStampToWait = 1; - bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, flushStampToWait, false, true, false); - EXPECT_TRUE(timeoutEnabled); - EXPECT_EQ(1, timeout); + auto params = helper.obtainTimeoutParams(false, 1, 2, flushStampToWait, QueueThrottle::MEDIUM, true, false); + EXPECT_TRUE(params.enableTimeout); + EXPECT_EQ(1, params.waitTimeout); } TEST_F(KmdNotifyTests, givenDisabledKmdNotifyMechanismWhenPowerSavingModeIsRequestedThenKmdNotifyMechanismIsUsedAndReturnsShortestWaitingTimePossible) { hwInfo->capabilityTable.kmdNotifyProperties.enableKmdNotify = false; MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties)); - int64_t timeout = 0; FlushStamp flushStampToWait = 1; - bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, flushStampToWait, true, true, false); - EXPECT_TRUE(timeoutEnabled); - EXPECT_EQ(1, timeout); + auto params = helper.obtainTimeoutParams(false, 1, 2, flushStampToWait, QueueThrottle::LOW, true, false); + EXPECT_TRUE(params.enableTimeout); + EXPECT_EQ(1, params.waitTimeout); } TEST_F(KmdNotifyTests, givenEnabledKmdNotifyMechanismWhenPowerSavingModeIsSetAndNoFlushStampProvidedWhenParametersAreObtainedThenFalseIsReturned) { @@ -482,11 +483,10 @@ TEST_F(KmdNotifyTests, givenEnabledKmdNotifyMechanismWhenPowerSavingModeIsSetAnd MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties)); helper.acLineConnected = false; - int64_t timeout = 0; FlushStamp flushStampToWait = 0; - bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, flushStampToWait, false, true, false); - EXPECT_FALSE(timeoutEnabled); - EXPECT_EQ(0, timeout); + auto params = helper.obtainTimeoutParams(false, 1, 2, flushStampToWait, QueueThrottle::MEDIUM, true, false); + EXPECT_FALSE(params.enableTimeout); + EXPECT_EQ(0, params.waitTimeout); } TEST_F(KmdNotifyTests, givenEnabledKmdDirectSubmissionNotifyMechanismWhenDirectSubmissionIsEnabledThenSelectDelayTimeoutForDirectSubmission) { @@ -496,11 +496,10 @@ TEST_F(KmdNotifyTests, givenEnabledKmdDirectSubmissionNotifyMechanismWhenDirectS constexpr int64_t expectedTimeout = 20; constexpr bool directSubmission = true; - int64_t timeout = 0; FlushStamp flushStampToWait = 1; - bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, flushStampToWait, false, true, directSubmission); - EXPECT_TRUE(timeoutEnabled); - EXPECT_EQ(expectedTimeout, timeout); + auto params = helper.obtainTimeoutParams(false, 1, 2, flushStampToWait, QueueThrottle::MEDIUM, true, directSubmission); + EXPECT_TRUE(params.enableTimeout); + EXPECT_EQ(expectedTimeout, params.waitTimeout); } TEST_F(KmdNotifyTests, givenEnabledKmdDirectSubmissionNotifyMechanismWhenDirectSubmissionIsDisabledThenSelectBaseDelayTimeout) { @@ -510,11 +509,10 @@ TEST_F(KmdNotifyTests, givenEnabledKmdDirectSubmissionNotifyMechanismWhenDirectS constexpr int64_t expectedTimeout = 150; constexpr bool directSubmission = false; - int64_t timeout = 0; FlushStamp flushStampToWait = 1; - bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, flushStampToWait, false, true, directSubmission); - EXPECT_TRUE(timeoutEnabled); - EXPECT_EQ(expectedTimeout, timeout); + auto params = helper.obtainTimeoutParams(false, 1, 2, flushStampToWait, QueueThrottle::MEDIUM, true, directSubmission); + EXPECT_TRUE(params.enableTimeout); + EXPECT_EQ(expectedTimeout, params.waitTimeout); } TEST_F(KmdNotifyTests, givenDisabledKmdDirectSubmissionNotifyMechanismWhenDirectSubmissionIsEnabledThenSelectBaseDelayTimeout) { @@ -524,9 +522,8 @@ TEST_F(KmdNotifyTests, givenDisabledKmdDirectSubmissionNotifyMechanismWhenDirect constexpr int64_t expectedTimeout = 150; constexpr bool directSubmission = true; - int64_t timeout = 0; FlushStamp flushStampToWait = 1; - bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, flushStampToWait, false, true, directSubmission); - EXPECT_TRUE(timeoutEnabled); - EXPECT_EQ(expectedTimeout, timeout); + auto params = helper.obtainTimeoutParams(false, 1, 2, flushStampToWait, QueueThrottle::MEDIUM, true, directSubmission); + EXPECT_TRUE(params.enableTimeout); + EXPECT_EQ(expectedTimeout, params.waitTimeout); } \ No newline at end of file diff --git a/opencl/test/unit_test/kernel/kernel_tests.cpp b/opencl/test/unit_test/kernel/kernel_tests.cpp index 352945a0a4..a3eea2a9ba 100644 --- a/opencl/test/unit_test/kernel/kernel_tests.cpp +++ b/opencl/test/unit_test/kernel/kernel_tests.cpp @@ -508,7 +508,7 @@ class CommandStreamReceiverMock : public CommandStreamReceiver { return NEO::SubmissionStatus::SUCCESS; } - WaitStatus waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool quickKmdSleep, bool forcePowerSavingMode) override { + WaitStatus waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool quickKmdSleep, QueueThrottle throttle) override { return WaitStatus::Ready; } uint32_t flushBcsTask(const BlitPropertiesContainer &blitPropertiesContainer, bool blocking, bool profilingEnabled, Device &device) override { return taskCount; }; diff --git a/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp b/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp index 48fc02fe57..5181b42d43 100644 --- a/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp +++ b/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp @@ -38,11 +38,11 @@ struct BcsBufferTests : public ::testing::Test { using UltCommandStreamReceiver::UltCommandStreamReceiver; WaitStatus waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, - bool useQuickKmdSleep, bool forcePowerSavingMode) override { + bool useQuickKmdSleep, QueueThrottle throttle) override { EXPECT_EQ(this->latestFlushedTaskCount, taskCountToWait); EXPECT_EQ(0u, flushStampToWait); EXPECT_FALSE(useQuickKmdSleep); - EXPECT_FALSE(forcePowerSavingMode); + EXPECT_EQ(throttle, QueueThrottle::MEDIUM); EXPECT_EQ(1u, this->activePartitions); waitForTaskCountWithKmdNotifyFallbackCalled++; diff --git a/opencl/test/unit_test/mem_obj/mem_obj_destruction_tests.cpp b/opencl/test/unit_test/mem_obj/mem_obj_destruction_tests.cpp index b2f1e7e6f6..b8f8256c7b 100644 --- a/opencl/test/unit_test/mem_obj/mem_obj_destruction_tests.cpp +++ b/opencl/test/unit_test/mem_obj/mem_obj_destruction_tests.cpp @@ -31,9 +31,9 @@ class MyCsr : public UltCommandStreamReceiver { MyCsr(const ExecutionEnvironment &executionEnvironment, const DeviceBitfield deviceBitfield) : UltCommandStreamReceiver(const_cast(executionEnvironment), 0, deviceBitfield) {} - WaitStatus waitForCompletionWithTimeout(bool enableTimeout, int64_t timeoutMs, uint32_t taskCountToWait) override { + WaitStatus waitForCompletionWithTimeout(const WaitParams ¶ms, uint32_t taskCountToWait) override { waitForCompletionWithTimeoutCalled++; - waitForCompletionWithTimeoutParamsPassed.push_back({enableTimeout, timeoutMs, taskCountToWait}); + waitForCompletionWithTimeoutParamsPassed.push_back({params.enableTimeout, params.waitTimeout, taskCountToWait}); *this->getTagAddress() = getTagAddressValue; return waitForCompletionWithTimeoutResult; } diff --git a/shared/source/command_stream/aub_command_stream_receiver_hw.h b/shared/source/command_stream/aub_command_stream_receiver_hw.h index cac8ae1b0d..f8748755fd 100644 --- a/shared/source/command_stream/aub_command_stream_receiver_hw.h +++ b/shared/source/command_stream/aub_command_stream_receiver_hw.h @@ -64,7 +64,7 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw::pollForCompletionImpl() { } template -inline WaitStatus AUBCommandStreamReceiverHw::waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool forcePowerSavingMode) { - const auto result = CommandStreamReceiverSimulatedHw::waitForTaskCountWithKmdNotifyFallback(taskCountToWait, flushStampToWait, useQuickKmdSleep, forcePowerSavingMode); +inline WaitStatus AUBCommandStreamReceiverHw::waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, QueueThrottle throttle) { + const auto result = CommandStreamReceiverSimulatedHw::waitForTaskCountWithKmdNotifyFallback(taskCountToWait, flushStampToWait, useQuickKmdSleep, throttle); pollForCompletion(); return result; diff --git a/shared/source/command_stream/command_stream_receiver.cpp b/shared/source/command_stream/command_stream_receiver.cpp index a9c8ecfbcc..195d929dfd 100644 --- a/shared/source/command_stream/command_stream_receiver.cpp +++ b/shared/source/command_stream/command_stream_receiver.cpp @@ -169,7 +169,7 @@ void CommandStreamReceiver::makeResidentHostPtrAllocation(GraphicsAllocation *gf WaitStatus CommandStreamReceiver::waitForTaskCount(uint32_t requiredTaskCount) { auto address = getTagAddress(); if (address) { - return baseWaitFunction(address, false, 0, requiredTaskCount); + return baseWaitFunction(address, WaitParams{false, false, 0}, requiredTaskCount); } return WaitStatus::Ready; @@ -316,7 +316,7 @@ void CommandStreamReceiver::cleanupResources() { } } -WaitStatus CommandStreamReceiver::waitForCompletionWithTimeout(bool enableTimeout, int64_t timeoutMicroseconds, uint32_t taskCountToWait) { +WaitStatus CommandStreamReceiver::waitForCompletionWithTimeout(const WaitParams ¶ms, uint32_t taskCountToWait) { uint32_t latestSentTaskCount = this->latestFlushedTaskCount; if (latestSentTaskCount < taskCountToWait) { if (!this->flushBatchedSubmissions()) { @@ -325,10 +325,10 @@ WaitStatus CommandStreamReceiver::waitForCompletionWithTimeout(bool enableTimeou } } - return baseWaitFunction(getTagAddress(), enableTimeout, timeoutMicroseconds, taskCountToWait); + return baseWaitFunction(getTagAddress(), params, taskCountToWait); } -WaitStatus CommandStreamReceiver::baseWaitFunction(volatile uint32_t *pollAddress, bool enableTimeout, int64_t timeoutMicroseconds, uint32_t taskCountToWait) { +WaitStatus CommandStreamReceiver::baseWaitFunction(volatile uint32_t *pollAddress, const WaitParams ¶ms, uint32_t taskCountToWait) { std::chrono::microseconds elapsedTimeSinceGpuHangCheck{0}; std::chrono::high_resolution_clock::time_point waitStartTime, lastHangCheckTime, currentTime; int64_t timeDiff = 0; @@ -337,14 +337,13 @@ WaitStatus CommandStreamReceiver::baseWaitFunction(volatile uint32_t *pollAddres if (latestSentTaskCount < taskCountToWait) { this->flushTagUpdate(); } - volatile uint32_t *partitionAddress = pollAddress; waitStartTime = std::chrono::high_resolution_clock::now(); lastHangCheckTime = waitStartTime; for (uint32_t i = 0; i < activePartitions; i++) { - while (*partitionAddress < taskCountToWait && timeDiff <= timeoutMicroseconds) { - if (WaitUtils::waitFunction(partitionAddress, taskCountToWait)) { + while (*partitionAddress < taskCountToWait && timeDiff <= params.waitTimeout) { + if (!params.indefinitelyPoll && WaitUtils::waitFunction(partitionAddress, taskCountToWait)) { break; } @@ -358,7 +357,7 @@ WaitStatus CommandStreamReceiver::baseWaitFunction(volatile uint32_t *pollAddres } } - if (enableTimeout) { + if (params.enableTimeout) { timeDiff = std::chrono::duration_cast(currentTime - waitStartTime).count(); } } diff --git a/shared/source/command_stream/command_stream_receiver.h b/shared/source/command_stream/command_stream_receiver.h index a867fca33f..6c1ba212aa 100644 --- a/shared/source/command_stream/command_stream_receiver.h +++ b/shared/source/command_stream/command_stream_receiver.h @@ -160,9 +160,9 @@ class CommandStreamReceiver { void requestStallingCommandsOnNextFlush() { stallingCommandsOnNextFlushRequired = true; } bool isStallingCommandsOnNextFlushRequired() const { return stallingCommandsOnNextFlushRequired; } - virtual WaitStatus waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool forcePowerSavingMode) = 0; - virtual WaitStatus waitForCompletionWithTimeout(bool enableTimeout, int64_t timeoutMicroseconds, uint32_t taskCountToWait); - WaitStatus baseWaitFunction(volatile uint32_t *pollAddress, bool enableTimeout, int64_t timeoutMicroseconds, uint32_t taskCountToWait); + virtual WaitStatus waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, QueueThrottle throttle) = 0; + virtual WaitStatus waitForCompletionWithTimeout(const WaitParams ¶ms, uint32_t taskCountToWait); + WaitStatus baseWaitFunction(volatile uint32_t *pollAddress, const WaitParams ¶ms, uint32_t taskCountToWait); MOCKABLE_VIRTUAL bool testTaskCountReady(volatile uint32_t *pollAddress, uint32_t taskCountToWait); virtual void downloadAllocations(){}; diff --git a/shared/source/command_stream/command_stream_receiver_hw.h b/shared/source/command_stream/command_stream_receiver_hw.h index e012126d26..9362cc5ad8 100644 --- a/shared/source/command_stream/command_stream_receiver_hw.h +++ b/shared/source/command_stream/command_stream_receiver_hw.h @@ -78,7 +78,7 @@ class CommandStreamReceiverHw : public CommandStreamReceiver { bool isPipelineSelectAlreadyProgrammed() const; void programComputeMode(LinearStream &csr, DispatchFlags &dispatchFlags, const HardwareInfo &hwInfo); - WaitStatus waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool forcePowerSavingMode) override; + WaitStatus waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, QueueThrottle throttle) override; void collectStateBaseAddresPatchInfo( uint64_t commandBufferAddress, diff --git a/shared/source/command_stream/command_stream_receiver_hw_base.inl b/shared/source/command_stream/command_stream_receiver_hw_base.inl index dfeffeeddd..2af179f44f 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_base.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_base.inl @@ -861,22 +861,19 @@ inline size_t CommandStreamReceiverHw::getCmdSizeForPipelineSelect() } template -inline WaitStatus CommandStreamReceiverHw::waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool forcePowerSavingMode) { - int64_t waitTimeout = 0; - bool enableTimeout = false; - - enableTimeout = kmdNotifyHelper->obtainTimeoutParams(waitTimeout, useQuickKmdSleep, *getTagAddress(), taskCountToWait, flushStampToWait, forcePowerSavingMode, this->isKmdWaitModeActive(), - this->isAnyDirectSubmissionEnabled()); +inline WaitStatus CommandStreamReceiverHw::waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, QueueThrottle throttle) { + const auto params = kmdNotifyHelper->obtainTimeoutParams(useQuickKmdSleep, *getTagAddress(), taskCountToWait, flushStampToWait, throttle, this->isKmdWaitModeActive(), + this->isAnyDirectSubmissionEnabled()); PRINT_DEBUG_STRING(DebugManager.flags.LogWaitingForCompletion.get(), stdout, "\nWaiting for task count %u at location %p. Current value: %u\n", taskCountToWait, getTagAddress(), *getTagAddress()); - auto status = waitForCompletionWithTimeout(enableTimeout, waitTimeout, taskCountToWait); + auto status = waitForCompletionWithTimeout(params, taskCountToWait); if (status == WaitStatus::NotReady) { waitForFlushStamp(flushStampToWait); //now call blocking wait, this is to ensure that task count is reached - status = waitForCompletionWithTimeout(false, 0, taskCountToWait); + status = waitForCompletionWithTimeout(WaitParams{false, false, 0}, taskCountToWait); } // If GPU hang occured, then propagate it to the caller. @@ -1120,7 +1117,7 @@ uint32_t CommandStreamReceiverHw::flushBcsTask(const BlitPropertiesCo lock.unlock(); if (blocking) { - waitForTaskCountWithKmdNotifyFallback(newTaskCount, flushStampToWait, false, false); + waitForTaskCountWithKmdNotifyFallback(newTaskCount, flushStampToWait, false, QueueThrottle::MEDIUM); internalAllocationStorage->cleanAllocationList(newTaskCount, TEMPORARY_ALLOCATION); } diff --git a/shared/source/command_stream/command_stream_receiver_with_aub_dump.h b/shared/source/command_stream/command_stream_receiver_with_aub_dump.h index 5d87110cae..ed0853a643 100644 --- a/shared/source/command_stream/command_stream_receiver_with_aub_dump.h +++ b/shared/source/command_stream/command_stream_receiver_with_aub_dump.h @@ -41,7 +41,7 @@ class CommandStreamReceiverWithAUBDump : public BaseCSR { } WaitStatus waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, - bool useQuickKmdSleep, bool forcePowerSavingMode) override; + bool useQuickKmdSleep, QueueThrottle throttle) override; size_t getPreferredTagPoolSize() const override { return 1; } diff --git a/shared/source/command_stream/command_stream_receiver_with_aub_dump.inl b/shared/source/command_stream/command_stream_receiver_with_aub_dump.inl index f5b28e3c31..36a408d754 100644 --- a/shared/source/command_stream/command_stream_receiver_with_aub_dump.inl +++ b/shared/source/command_stream/command_stream_receiver_with_aub_dump.inl @@ -79,12 +79,12 @@ void CommandStreamReceiverWithAUBDump::setupContext(OsContext &osContex template WaitStatus CommandStreamReceiverWithAUBDump::waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, - bool useQuickKmdSleep, bool forcePowerSavingMode) { + bool useQuickKmdSleep, QueueThrottle throttle) { if (aubCSR) { - aubCSR->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, flushStampToWait, useQuickKmdSleep, forcePowerSavingMode); + aubCSR->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, flushStampToWait, useQuickKmdSleep, throttle); } - return BaseCSR::waitForTaskCountWithKmdNotifyFallback(taskCountToWait, flushStampToWait, useQuickKmdSleep, forcePowerSavingMode); + return BaseCSR::waitForTaskCountWithKmdNotifyFallback(taskCountToWait, flushStampToWait, useQuickKmdSleep, throttle); } template diff --git a/shared/source/command_stream/tbx_command_stream_receiver_hw.h b/shared/source/command_stream/tbx_command_stream_receiver_hw.h index 57763a8934..96a362dd55 100644 --- a/shared/source/command_stream/tbx_command_stream_receiver_hw.h +++ b/shared/source/command_stream/tbx_command_stream_receiver_hw.h @@ -43,8 +43,8 @@ class TbxCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw::flushSubmissionsAndDownloadAllocatio } template -WaitStatus TbxCommandStreamReceiverHw::waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool forcePowerSavingMode) { +WaitStatus TbxCommandStreamReceiverHw::waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, QueueThrottle throttle) { flushSubmissionsAndDownloadAllocations(taskCountToWait); - return BaseClass::waitForTaskCountWithKmdNotifyFallback(taskCountToWait, flushStampToWait, useQuickKmdSleep, forcePowerSavingMode); + return BaseClass::waitForTaskCountWithKmdNotifyFallback(taskCountToWait, flushStampToWait, useQuickKmdSleep, throttle); } template -WaitStatus TbxCommandStreamReceiverHw::waitForCompletionWithTimeout(bool enableTimeout, int64_t timeoutMicroseconds, uint32_t taskCountToWait) { +WaitStatus TbxCommandStreamReceiverHw::waitForCompletionWithTimeout(const WaitParams ¶ms, uint32_t taskCountToWait) { flushSubmissionsAndDownloadAllocations(taskCountToWait); - return BaseClass::waitForCompletionWithTimeout(enableTimeout, timeoutMicroseconds, taskCountToWait); + return BaseClass::waitForCompletionWithTimeout(params, taskCountToWait); } template diff --git a/shared/source/command_stream/wait_status.h b/shared/source/command_stream/wait_status.h index 2692d35242..f5a9b156c0 100644 --- a/shared/source/command_stream/wait_status.h +++ b/shared/source/command_stream/wait_status.h @@ -7,6 +7,8 @@ #pragma once +#include + namespace NEO { enum class WaitStatus { @@ -15,4 +17,10 @@ enum class WaitStatus { GpuHang = 2, }; +struct WaitParams { + bool indefinitelyPoll = false; + bool enableTimeout = false; + int64_t waitTimeout = 0; +}; + } // namespace NEO \ No newline at end of file diff --git a/shared/source/helpers/kmd_notify_properties.cpp b/shared/source/helpers/kmd_notify_properties.cpp index b3268c3d65..9f40133c56 100644 --- a/shared/source/helpers/kmd_notify_properties.cpp +++ b/shared/source/helpers/kmd_notify_properties.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2021 Intel Corporation + * Copyright (C) 2018-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -13,25 +13,27 @@ using namespace NEO; -bool KmdNotifyHelper::obtainTimeoutParams(int64_t &timeoutValueOutput, - bool quickKmdSleepRequest, - uint32_t currentHwTag, - uint32_t taskCountToWait, - FlushStamp flushStampToWait, - bool forcePowerSavingMode, - bool kmdWaitModeActive, - bool directSubmissionEnabled) { +WaitParams KmdNotifyHelper::obtainTimeoutParams(bool quickKmdSleepRequest, + uint32_t currentHwTag, + uint32_t taskCountToWait, + FlushStamp flushStampToWait, + QueueThrottle throttle, + bool kmdWaitModeActive, + bool directSubmissionEnabled) { + if (throttle == QueueThrottle::HIGH) { + return WaitParams{true}; + } + if (flushStampToWait == 0) { - return false; + return WaitParams{}; } if (!kmdWaitModeActive) { - return false; + return WaitParams{}; } - if (DebugManager.flags.PowerSavingMode.get() || forcePowerSavingMode) { - timeoutValueOutput = 1; - return true; + if (DebugManager.flags.PowerSavingMode.get() || throttle == QueueThrottle::LOW) { + return WaitParams{false, true, 1}; } int64_t multiplier = (currentHwTag < taskCountToWait) ? static_cast(taskCountToWait - currentHwTag) : 1; @@ -40,18 +42,21 @@ bool KmdNotifyHelper::obtainTimeoutParams(int64_t &timeoutValueOutput, } quickKmdSleepRequest |= applyQuickKmdSleepForSporadicWait(); + WaitParams params; if (!properties->enableKmdNotify && !acLineConnected) { - timeoutValueOutput = KmdNotifyConstants::timeoutInMicrosecondsForDisconnectedAcLine; + params.waitTimeout = KmdNotifyConstants::timeoutInMicrosecondsForDisconnectedAcLine; } else if (quickKmdSleepRequest && properties->enableQuickKmdSleep) { - timeoutValueOutput = properties->delayQuickKmdSleepMicroseconds; + params.waitTimeout = properties->delayQuickKmdSleepMicroseconds; } else if (directSubmissionEnabled && properties->enableQuickKmdSleepForDirectSubmission) { - timeoutValueOutput = properties->delayQuickKmdSleepForDirectSubmissionMicroseconds; + params.waitTimeout = properties->delayQuickKmdSleepForDirectSubmissionMicroseconds; } else { - timeoutValueOutput = getBaseTimeout(multiplier); + params.waitTimeout = getBaseTimeout(multiplier); } - return (properties->enableKmdNotify || !acLineConnected); + params.enableTimeout = (properties->enableKmdNotify || !acLineConnected); + + return params; } bool KmdNotifyHelper::applyQuickKmdSleepForSporadicWait() const { diff --git a/shared/source/helpers/kmd_notify_properties.h b/shared/source/helpers/kmd_notify_properties.h index 277bab3cc0..e1492687e5 100644 --- a/shared/source/helpers/kmd_notify_properties.h +++ b/shared/source/helpers/kmd_notify_properties.h @@ -1,11 +1,13 @@ /* - * Copyright (C) 2018-2021 Intel Corporation + * Copyright (C) 2018-2022 Intel Corporation * * SPDX-License-Identifier: MIT * */ #pragma once +#include "shared/source/command_stream/queue_throttle.h" +#include "shared/source/command_stream/wait_status.h" #include "shared/source/helpers/completion_stamp.h" #include @@ -39,14 +41,13 @@ class KmdNotifyHelper { KmdNotifyHelper(const KmdNotifyProperties *properties) : properties(properties){}; MOCKABLE_VIRTUAL ~KmdNotifyHelper() = default; - bool obtainTimeoutParams(int64_t &timeoutValueOutput, - bool quickKmdSleepRequest, - uint32_t currentHwTag, - uint32_t taskCountToWait, - FlushStamp flushStampToWait, - bool forcePowerSavingMode, - bool kmdWaitModeActive, - bool directSubmissionEnabled); + WaitParams obtainTimeoutParams(bool quickKmdSleepRequest, + uint32_t currentHwTag, + uint32_t taskCountToWait, + FlushStamp flushStampToWait, + QueueThrottle throttle, + bool kmdWaitModeActive, + bool directSubmissionEnabled); bool quickKmdSleepForSporadicWaitsEnabled() const { return properties->enableQuickKmdSleepForSporadicWaits; } MOCKABLE_VIRTUAL void updateLastWaitForCompletionTimestamp(); diff --git a/shared/source/memory_manager/memory_manager.cpp b/shared/source/memory_manager/memory_manager.cpp index 28c14ac152..8b49d6b842 100644 --- a/shared/source/memory_manager/memory_manager.cpp +++ b/shared/source/memory_manager/memory_manager.cpp @@ -709,7 +709,7 @@ void MemoryManager::waitForEnginesCompletion(GraphicsAllocation &graphicsAllocat if (graphicsAllocation.isUsedByOsContext(osContextId) && engine.commandStreamReceiver->getTagAllocation() != nullptr && allocationTaskCount > *engine.commandStreamReceiver->getTagAddress()) { - engine.commandStreamReceiver->waitForCompletionWithTimeout(false, TimeoutControls::maxTimeout, allocationTaskCount); + engine.commandStreamReceiver->waitForCompletionWithTimeout(WaitParams{false, false, TimeoutControls::maxTimeout}, allocationTaskCount); } } } @@ -718,7 +718,7 @@ void MemoryManager::cleanTemporaryAllocationListOnAllEngines(bool waitForComplet for (auto &engine : getRegisteredEngines()) { auto csr = engine.commandStreamReceiver; if (waitForCompletion) { - csr->waitForCompletionWithTimeout(false, 0, csr->peekLatestSentTaskCount()); + csr->waitForCompletionWithTimeout(WaitParams{false, false, 0}, csr->peekLatestSentTaskCount()); } csr->getInternalAllocationStorage()->cleanAllocationList(*csr->getTagAddress(), AllocationUsage::TEMPORARY_ALLOCATION); } diff --git a/shared/source/os_interface/linux/drm_memory_operations_handler_bind.cpp b/shared/source/os_interface/linux/drm_memory_operations_handler_bind.cpp index 8e3afea6b0..a4f833554e 100644 --- a/shared/source/os_interface/linux/drm_memory_operations_handler_bind.cpp +++ b/shared/source/os_interface/linux/drm_memory_operations_handler_bind.cpp @@ -164,7 +164,7 @@ void DrmMemoryOperationsHandlerBind::evictUnusedAllocationsImpl(std::vectorwaitForCompletionWithTimeout(false, 0, engine.commandStreamReceiver->peekLatestFlushedTaskCount()); + engine.commandStreamReceiver->waitForCompletionWithTimeout(WaitParams{false, false, 0}, engine.commandStreamReceiver->peekLatestFlushedTaskCount()); } if (allocation->isUsedByOsContext(engine.osContext->getContextId()) && diff --git a/shared/test/common/libult/ult_command_stream_receiver.h b/shared/test/common/libult/ult_command_stream_receiver.h index 43a8da6b26..173062e3f9 100644 --- a/shared/test/common/libult/ult_command_stream_receiver.h +++ b/shared/test/common/libult/ult_command_stream_receiver.h @@ -174,14 +174,17 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw, publ downloadAllocationCalled = true; } - WaitStatus waitForCompletionWithTimeout(bool enableTimeout, int64_t timeoutMicroseconds, uint32_t taskCountToWait) override { + WaitStatus waitForCompletionWithTimeout(const WaitParams ¶ms, uint32_t taskCountToWait) override { latestWaitForCompletionWithTimeoutTaskCount.store(taskCountToWait); waitForCompletionWithTimeoutTaskCountCalled++; if (callBaseWaitForCompletionWithTimeout) { - return BaseClass::waitForCompletionWithTimeout(enableTimeout, timeoutMicroseconds, taskCountToWait); + return BaseClass::waitForCompletionWithTimeout(params, taskCountToWait); } return returnWaitForCompletionWithTimeout; } + WaitStatus waitForCompletionWithTimeout(bool enableTimeout, int64_t timeoutMicroseconds, uint32_t taskCountToWait) { + return waitForCompletionWithTimeout(WaitParams{false, enableTimeout, timeoutMicroseconds}, taskCountToWait); + } void overrideCsrSizeReqFlags(CsrSizeRequestFlags &flags) { this->csrSizeRequestFlags = flags; } GraphicsAllocation *getPreemptionAllocation() const { return this->preemptionAllocation; } diff --git a/shared/test/common/mocks/mock_aub_csr.h b/shared/test/common/mocks/mock_aub_csr.h index 0e6f337729..321fe0dc33 100644 --- a/shared/test/common/mocks/mock_aub_csr.h +++ b/shared/test/common/mocks/mock_aub_csr.h @@ -122,7 +122,7 @@ struct MockAubCsr : public AUBCommandStreamReceiverHw { expectMemoryCompressedCalled = true; return AUBCommandStreamReceiverHw::expectMemoryCompressed(gfxAddress, srcAddress, length); } - WaitStatus waitForCompletionWithTimeout(bool enableTimeout, int64_t timeoutMicroseconds, uint32_t taskCountToWait) override { + WaitStatus waitForCompletionWithTimeout(const WaitParams ¶ms, uint32_t taskCountToWait) override { return NEO::WaitStatus::Ready; } void addAubComment(const char *message) override { diff --git a/shared/test/common/mocks/mock_command_stream_receiver.h b/shared/test/common/mocks/mock_command_stream_receiver.h index a5635d5770..428f142289 100644 --- a/shared/test/common/mocks/mock_command_stream_receiver.h +++ b/shared/test/common/mocks/mock_command_stream_receiver.h @@ -52,7 +52,7 @@ class MockCommandStreamReceiver : public CommandStreamReceiver { memset(const_cast(CommandStreamReceiver::tagAddress), 0xFFFFFFFF, tagSize * sizeof(uint32_t)); } - WaitStatus waitForCompletionWithTimeout(bool enableTimeout, int64_t timeoutMicroseconds, uint32_t taskCountToWait) override { + WaitStatus waitForCompletionWithTimeout(const WaitParams ¶ms, uint32_t taskCountToWait) override { waitForCompletionWithTimeoutCalled++; return waitForCompletionWithTimeoutReturnValue; } @@ -104,7 +104,11 @@ class MockCommandStreamReceiver : public CommandStreamReceiver { return true; } - WaitStatus waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool quickKmdSleep, bool forcePowerSavingMode) override { + WaitStatus waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool quickKmdSleep, QueueThrottle throttle) override { + return WaitStatus::Ready; + } + + WaitStatus waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool quickKmdSleep, bool forcePowerSavingMode) { return WaitStatus::Ready; } diff --git a/shared/test/unit_test/command_stream/aub_file_stream_tests.cpp b/shared/test/unit_test/command_stream/aub_file_stream_tests.cpp index 271d2f2774..175b5bb94c 100644 --- a/shared/test/unit_test/command_stream/aub_file_stream_tests.cpp +++ b/shared/test/unit_test/command_stream/aub_file_stream_tests.cpp @@ -323,7 +323,7 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenCallingInsertAubWa auto aubExecutionEnvironment = getEnvironment>(true, true, true); auto aubCsr = aubExecutionEnvironment->template getCsr>(); ASSERT_FALSE(aubCsr->pollForCompletionCalled); - aubCsr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, false); + aubCsr->waitForTaskCountWithKmdNotifyFallback(0, 0, false, QueueThrottle::MEDIUM); EXPECT_TRUE(aubCsr->pollForCompletionCalled); } diff --git a/shared/test/unit_test/command_stream/tbx_command_stream_tests.cpp b/shared/test/unit_test/command_stream/tbx_command_stream_tests.cpp index f72250c883..d21485f8f9 100644 --- a/shared/test/unit_test/command_stream/tbx_command_stream_tests.cpp +++ b/shared/test/unit_test/command_stream/tbx_command_stream_tests.cpp @@ -350,7 +350,7 @@ HWTEST_F(TbxCommandSteamSimpleTest, givenTbxCsrWhenCallingWaitForTaskCountWithKm tbxCsr.allocationsForDownload = {&allocation1, &allocation2, &allocation3}; - tbxCsr.waitForTaskCountWithKmdNotifyFallback(0u, 0u, false, false); + tbxCsr.waitForTaskCountWithKmdNotifyFallback(0u, 0u, false, QueueThrottle::MEDIUM); std::set expectedDownloadedAllocations = {tbxCsr.getTagAllocation(), &allocation1, &allocation2, &allocation3}; EXPECT_EQ(expectedDownloadedAllocations, tbxCsr.downloadedAllocations); @@ -376,7 +376,7 @@ HWTEST_F(TbxCommandSteamSimpleTest, givenTbxCsrWhenCallingWaitForCompletionWithT tbxCsr.allocationsForDownload = {&allocation1, &allocation2, &allocation3}; - tbxCsr.waitForCompletionWithTimeout(true, 0, 0); + tbxCsr.waitForCompletionWithTimeout(WaitParams{false, true, 0}, 0); std::set expectedDownloadedAllocations = {tbxCsr.getTagAllocation(), &allocation1, &allocation2, &allocation3}; EXPECT_EQ(expectedDownloadedAllocations, tbxCsr.downloadedAllocations);