From bc35cd250a5b5856a18e09a5bb042a5ac68adbef Mon Sep 17 00:00:00 2001 From: "Mrozek, Michal" Date: Tue, 7 May 2019 14:24:13 +0200 Subject: [PATCH] Do not use max power saving mode in VA sharing scenarios. -This can be achieved by passing CL_QUEUE_THROTTLE_LOW_KHR as throttle hint to command queue. - This gives much better control about the granularity of this feature instead of triggering this for the whole context user may still have power saving mode queues. Change-Id: I066729f963119ddc1f62ad2785c342af2fea588e Signed-off-by: Mrozek, Michal --- .../command_stream/command_stream_receiver.h | 4 -- runtime/context/context.cpp | 3 - runtime/device/device.cpp | 6 -- runtime/device/device.h | 1 - runtime/helpers/kmd_notify_properties.cpp | 4 +- runtime/helpers/kmd_notify_properties.h | 5 -- unit_tests/helpers/kmd_notify_tests.cpp | 20 ------- unit_tests/sharings/sharing_factory_tests.cpp | 56 ------------------- 8 files changed, 1 insertion(+), 98 deletions(-) diff --git a/runtime/command_stream/command_stream_receiver.h b/runtime/command_stream/command_stream_receiver.h index a6dddaa31e..dde0fd297a 100644 --- a/runtime/command_stream/command_stream_receiver.h +++ b/runtime/command_stream/command_stream_receiver.h @@ -146,10 +146,6 @@ class CommandStreamReceiver { bool initializeTagAllocation(); MOCKABLE_VIRTUAL std::unique_lock obtainUniqueOwnership(); - KmdNotifyHelper *peekKmdNotifyHelper() { - return kmdNotifyHelper.get(); - } - bool peekTimestampPacketWriteEnabled() const { return timestampPacketWriteEnabled; } size_t defaultSshSize; diff --git a/runtime/context/context.cpp b/runtime/context/context.cpp index 97d6b8dc5a..110880a511 100644 --- a/runtime/context/context.cpp +++ b/runtime/context/context.cpp @@ -170,9 +170,6 @@ bool Context::createImpl(const cl_context_properties *properties, if (memoryManager->isAsyncDeleterEnabled()) { memoryManager->getDeferredDeleter()->addClient(); } - if (this->sharingFunctions[SharingType::VA_SHARING]) { - device->initMaxPowerSavingMode(); - } } for (auto &device : devices) { diff --git a/runtime/device/device.cpp b/runtime/device/device.cpp index 715e5c39e7..0e43e0a6f5 100644 --- a/runtime/device/device.cpp +++ b/runtime/device/device.cpp @@ -275,12 +275,6 @@ bool Device::isSourceLevelDebuggerActive() const { return deviceInfo.sourceLevelDebuggerActive; } -void Device::initMaxPowerSavingMode() { - for (auto &engine : engines) { - engine.commandStreamReceiver->peekKmdNotifyHelper()->initMaxPowerSavingMode(); - } -} - EngineControl &Device::getEngine(aub_stream::EngineType engineType, bool lowPriority) { for (auto &engine : engines) { if (engine.osContext->getEngineType() == engineType && diff --git a/runtime/device/device.h b/runtime/device/device.h index 068c7bd178..477ae570f3 100644 --- a/runtime/device/device.h +++ b/runtime/device/device.h @@ -65,7 +65,6 @@ class Device : public BaseObject<_cl_device_id> { DeviceInfo *getMutableDeviceInfo(); MOCKABLE_VIRTUAL const WorkaroundTable *getWaTable() const; - void initMaxPowerSavingMode(); void *getSLMWindowStartAddress(); void prepareSLMWindow(); void setForce32BitAddressing(bool value) { diff --git a/runtime/helpers/kmd_notify_properties.cpp b/runtime/helpers/kmd_notify_properties.cpp index b8167eeb50..0cfc78d09c 100644 --- a/runtime/helpers/kmd_notify_properties.cpp +++ b/runtime/helpers/kmd_notify_properties.cpp @@ -35,9 +35,7 @@ bool KmdNotifyHelper::obtainTimeoutParams(int64_t &timeoutValueOutput, quickKmdSleepRequest |= applyQuickKmdSleepForSporadicWait(); - if (maxPowerSavingMode) { - timeoutValueOutput = 1; - } else if (!properties->enableKmdNotify && !acLineConnected) { + if (!properties->enableKmdNotify && !acLineConnected) { timeoutValueOutput = KmdNotifyConstants::timeoutInMicrosecondsForDisconnectedAcLine; } else if (quickKmdSleepRequest && properties->enableQuickKmdSleep) { timeoutValueOutput = properties->delayQuickKmdSleepMicroseconds; diff --git a/runtime/helpers/kmd_notify_properties.h b/runtime/helpers/kmd_notify_properties.h index 55816d33cc..e0daab5e74 100644 --- a/runtime/helpers/kmd_notify_properties.h +++ b/runtime/helpers/kmd_notify_properties.h @@ -50,10 +50,6 @@ class KmdNotifyHelper { static void overrideFromDebugVariable(int32_t debugVariableValue, int64_t &destination); static void overrideFromDebugVariable(int32_t debugVariableValue, bool &destination); - void initMaxPowerSavingMode() { - maxPowerSavingMode = true; - } - protected: bool applyQuickKmdSleepForSporadicWait() const; int64_t getBaseTimeout(const int64_t &multiplier) const; @@ -62,6 +58,5 @@ class KmdNotifyHelper { const KmdNotifyProperties *properties = nullptr; std::atomic lastWaitForCompletionTimestampUs{0}; std::atomic acLineConnected{true}; - bool maxPowerSavingMode = false; }; } // namespace NEO diff --git a/unit_tests/helpers/kmd_notify_tests.cpp b/unit_tests/helpers/kmd_notify_tests.cpp index 7df71cfc8b..8170643425 100644 --- a/unit_tests/helpers/kmd_notify_tests.cpp +++ b/unit_tests/helpers/kmd_notify_tests.cpp @@ -48,7 +48,6 @@ struct KmdNotifyTests : public ::testing::Test { using KmdNotifyHelper::acLineConnected; using KmdNotifyHelper::getMicrosecondsSinceEpoch; using KmdNotifyHelper::lastWaitForCompletionTimestampUs; - using KmdNotifyHelper::maxPowerSavingMode; using KmdNotifyHelper::properties; MockKmdNotifyHelper() = delete; @@ -348,25 +347,6 @@ TEST_F(KmdNotifyTests, givenDisabledKmdNotifyMechanismWhenAcLineIsDisconnectedTh EXPECT_EQ(10000, KmdNotifyConstants::timeoutInMicrosecondsForDisconnectedAcLine); } -TEST_F(KmdNotifyTests, givenKmdNotifyEnabledWhenInitMaxPowerSavingModeIsCalledThenObtainReturnOneAsWaitValue) { - localHwInfo.capabilityTable.kmdNotifyProperties.enableKmdNotify = true; - MockKmdNotifyHelper helper(&(localHwInfo.capabilityTable.kmdNotifyProperties)); - - EXPECT_FALSE(helper.maxPowerSavingMode); - - int64_t timeout = 0; - bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, 2, false); - EXPECT_TRUE(timeoutEnabled); - EXPECT_EQ(2, timeout); - - helper.initMaxPowerSavingMode(); - EXPECT_TRUE(helper.maxPowerSavingMode); - timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, 2, false); - EXPECT_TRUE(timeoutEnabled); - - EXPECT_EQ(1, timeout); -} - TEST_F(KmdNotifyTests, givenEnabledKmdNotifyMechanismWhenAcLineIsDisconnectedThenDontChangeTimeoutValue) { localHwInfo.capabilityTable.kmdNotifyProperties.enableKmdNotify = true; localHwInfo.capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds = 5; diff --git a/unit_tests/sharings/sharing_factory_tests.cpp b/unit_tests/sharings/sharing_factory_tests.cpp index 033aa647bf..c13fcbcf32 100644 --- a/unit_tests/sharings/sharing_factory_tests.cpp +++ b/unit_tests/sharings/sharing_factory_tests.cpp @@ -235,59 +235,3 @@ TEST(Context, givenMockSharingBuilderWhenContextWithInvalidPropertiesThenContext context.reset(Context::create(validProperties, deviceVector, nullptr, nullptr, retVal)); EXPECT_NE(nullptr, context.get()); }; - -TEST(Context, GivenVaContextWhenItIsCreatedItInitializesPowerSavingMode) { - SharingFactoryStateRestore stateRestore; - stateRestore.clearCurrentState(); - stateRestore.registerSharing(SharingType::VA_SHARING); - - auto device = std::make_unique(*platformDevices[0]); - cl_device_id clDevice = static_cast(device.get()); - cl_int retVal; - - cl_platform_id platformId[] = {platform()}; - - auto &commandStreamReceiver = device->getCommandStreamReceiver(); - auto kmdNotifyHelper = commandStreamReceiver.peekKmdNotifyHelper(); - - int64_t timeout = 0; - kmdNotifyHelper->obtainTimeoutParams(timeout, true, 1, 10, 2, false); - EXPECT_NE(1, timeout); - - cl_context_properties validProperties[5] = {CL_CONTEXT_PLATFORM, (cl_context_properties)platformId[0], - clContextPropertyMock, mockContextPassFinalize, 0}; - - std::unique_ptr ctx(Context::create(validProperties, DeviceVector(&clDevice, 1), nullptr, nullptr, retVal)); - EXPECT_EQ(CL_SUCCESS, retVal); - EXPECT_NE(nullptr, ctx); - kmdNotifyHelper->obtainTimeoutParams(timeout, true, 1, 10, 2, false); - EXPECT_EQ(1, timeout); -} - -TEST(Context, GivenNonVaContextWhenItIsCreatedItInitializesPowerSavingMode) { - SharingFactoryStateRestore stateRestore; - stateRestore.clearCurrentState(); - stateRestore.registerSharing(SharingType::CLGL_SHARING); - - auto device = std::make_unique(*platformDevices[0]); - cl_device_id clDevice = static_cast(device.get()); - cl_int retVal; - - cl_platform_id platformId[] = {platform()}; - - auto &commandStreamReceiver = device->getCommandStreamReceiver(); - auto kmdNotifyHelper = commandStreamReceiver.peekKmdNotifyHelper(); - - int64_t timeout = 0; - kmdNotifyHelper->obtainTimeoutParams(timeout, true, 1, 10, 2, false); - EXPECT_NE(1, timeout); - - cl_context_properties validProperties[5] = {CL_CONTEXT_PLATFORM, (cl_context_properties)platformId[0], - clContextPropertyMock, mockContextPassFinalize, 0}; - - std::unique_ptr ctx(Context::create(validProperties, DeviceVector(&clDevice, 1), nullptr, nullptr, retVal)); - EXPECT_EQ(CL_SUCCESS, retVal); - EXPECT_NE(nullptr, ctx); - kmdNotifyHelper->obtainTimeoutParams(timeout, true, 1, 10, 2, false); - EXPECT_NE(1, timeout); -}