Power Saving Hint Support for Level Zero in Windows

- Added Functionality to pass ze_power_saving_hint_type_t to zeContextCreate
included in the pNext extensions in ze_context_desc_t.
- Enables handling a hint value 0-100 with 0 being no power savings
and 100 being maximum power savings.
- ZE_RESULT_ERROR_INVALID_ENUMERATION is returned given an invalid hint.

Related-To: LOCI-2567

Signed-off-by: Spruit, Neil R <neil.r.spruit@intel.com>
This commit is contained in:
Spruit, Neil R
2021-12-16 02:13:00 +00:00
committed by Compute-Runtime-Automation
parent 635c02e1ff
commit 02f075c541
33 changed files with 386 additions and 59 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -56,3 +56,34 @@ TEST_F(OsContextWinTest, givenWddm20WhenRegisterTrimCallbackIsDisabledThenOsCont
osContext = std::make_unique<OsContextWin>(*osInterface->getDriverModel()->as<Wddm>(), 0u, EngineDescriptorHelper::getDefaultDescriptor(engineTypeUsage, preemptionMode));
EXPECT_NO_THROW(osContext->ensureContextInitialized());
}
TEST_F(OsContextWinTest, givenReinitializeContextWhenContextIsInitThenContextIsDestroyedAndRecreated) {
osContext = std::make_unique<OsContextWin>(*osInterface->getDriverModel()->as<Wddm>(), 0u, EngineDescriptorHelper::getDefaultDescriptor(engineTypeUsage, preemptionMode));
EXPECT_NO_THROW(osContext->reInitializeContext());
EXPECT_NO_THROW(osContext->ensureContextInitialized());
}
TEST_F(OsContextWinTest, givenReinitializeContextWhenContextIsNotInitThenContextIsCreated) {
EXPECT_NO_THROW(osContext->reInitializeContext());
EXPECT_NO_THROW(osContext->ensureContextInitialized());
}
struct OsContextWinTestNoCleanup : public WddmTestWithMockGdiDllNoCleanup {
void SetUp() override {
WddmTestWithMockGdiDllNoCleanup::SetUp();
preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo);
engineTypeUsage = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*defaultHwInfo)[0];
init();
}
PreemptionMode preemptionMode;
EngineTypeUsage engineTypeUsage;
};
TEST_F(OsContextWinTestNoCleanup, givenReinitializeContextWhenContextIsInitThenContextIsNotDestroyed) {
osContext = std::make_unique<OsContextWin>(*osInterface->getDriverModel()->as<Wddm>(), 0u, EngineDescriptorHelper::getDefaultDescriptor(engineTypeUsage, preemptionMode));
EXPECT_TRUE(this->wddm->skipResourceCleanup());
EXPECT_NO_THROW(osContext->reInitializeContext());
EXPECT_NO_THROW(osContext->ensureContextInitialized());
}

View File

@ -226,6 +226,23 @@ TEST_F(Wddm20Tests, whenInitializeWddmThenContextIsCreated) {
EXPECT_TRUE(context != static_cast<D3DKMT_HANDLE>(0));
}
TEST_F(Wddm20Tests, whenCreatingContextWithPowerHintSuccessIsReturned) {
auto newContext = osContext.get();
newContext->setUmdPowerHintValue(1);
EXPECT_EQ(1, newContext->getUmdPowerHintValue());
wddm->createContext(*newContext);
EXPECT_TRUE(wddm->createContext(*newContext));
}
TEST_F(Wddm20Tests, whenInitPrivateDataThenDefaultValuesAreSet) {
auto newContext = osContext.get();
CREATECONTEXT_PVTDATA PrivateData = initPrivateData(*newContext);
EXPECT_FALSE(PrivateData.IsProtectedProcess);
EXPECT_FALSE(PrivateData.IsDwm);
EXPECT_TRUE(PrivateData.GpuVAContext);
EXPECT_FALSE(PrivateData.IsMediaUsage);
}
TEST_F(Wddm20Tests, WhenCreatingAllocationAndDestroyingAllocationThenCorrectResultReturned) {
OsAgnosticMemoryManager mm(*executionEnvironment);
WddmAllocation allocation(0, GraphicsAllocation::AllocationType::UNKNOWN, mm.allocateSystemMemory(100, 0), 100, nullptr, MemoryPool::MemoryNull, 0u, 1u);