Optimize power usage in VA sharing scenarios.

- in VA sharing scenarios driver needs to be as power efficient as possible
- Added new mode to KMD notify helper called maxPowerSavingMode
- in this mode, whenever GPU is not busy, driver will choose non busy wait
path.

Change-Id: I7e4079be995107bea543ffda774ca161ce483944
This commit is contained in:
Mrozek, Michal
2018-07-31 08:38:50 +02:00
committed by sys_ocldev
parent b4b4a306d4
commit d53e1c3979
9 changed files with 85 additions and 4 deletions

View File

@@ -59,6 +59,7 @@ struct KmdNotifyTests : public ::testing::Test {
using KmdNotifyHelper::acLineConnected;
using KmdNotifyHelper::getMicrosecondsSinceEpoch;
using KmdNotifyHelper::lastWaitForCompletionTimestampUs;
using KmdNotifyHelper::maxPowerSavingMode;
using KmdNotifyHelper::properties;
MockKmdNotifyHelper() = delete;
@@ -334,6 +335,25 @@ 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);
EXPECT_TRUE(timeoutEnabled);
EXPECT_EQ(2, timeout);
helper.initMaxPowerSavingMode();
EXPECT_TRUE(helper.maxPowerSavingMode);
timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, 2);
EXPECT_TRUE(timeoutEnabled);
EXPECT_EQ(1, timeout);
}
TEST_F(KmdNotifyTests, givenEnabledKmdNotifyMechanismWhenAcLineIsDisconnectedThenDontChangeTimeoutValue) {
localHwInfo.capabilityTable.kmdNotifyProperties.enableKmdNotify = true;
localHwInfo.capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds = 5;

View File

@@ -22,6 +22,7 @@
#include "gtest/gtest.h"
#include "runtime/context/context.h"
#include "runtime/command_stream/command_stream_receiver.h"
#include "runtime/device/device.h"
#include "runtime/helpers/string.h"
#include "runtime/platform/platform.h"
@@ -196,6 +197,14 @@ TEST(SharingFactoryTests, givenMockFactoryWithSharingWhenAskedThenAddressIsRetur
EXPECT_EQ(reinterpret_cast<void *>(dummyHandler), ptr);
}
TEST(SharingFactoryTests, givenSharingFactoryWhenSharingIsRegisteredThenIsSharingPresentReflectsThatStatus) {
SharingFactoryStateRestore stateRestore;
stateRestore.clearCurrentState();
EXPECT_FALSE(stateRestore.isSharingPresent(SharingType::CLGL_SHARING));
stateRestore.registerSharing<MockSharingBuilderFactory>(SharingType::CLGL_SHARING);
EXPECT_TRUE(stateRestore.isSharingPresent(SharingType::CLGL_SHARING));
}
TEST(Context, givenMockSharingBuilderWhenContextWithInvalidPropertiesThenContextCreateShouldFail) {
SharingFactoryStateRestore stateRestore;
@@ -226,3 +235,35 @@ TEST(Context, givenMockSharingBuilderWhenContextWithInvalidPropertiesThenContext
context.reset(Context::create<Context>(validProperties, deviceVector, nullptr, nullptr, retVal));
EXPECT_NE(nullptr, context.get());
};
TEST(Context, GivenVaContextWhenItIsCreatedItInitializesPowerSavingMode) {
SharingFactoryStateRestore stateRestore;
stateRestore.clearCurrentState();
stateRestore.registerSharing<MockSharingBuilderFactory>(SharingType::VA_SHARING);
std::unique_ptr<MockDevice> device(new MockDevice(*platformDevices[0]));
cl_device_id clDevice = static_cast<cl_device_id>(device.get());
DeviceVector deviceVector((cl_device_id *)&clDevice, 1);
cl_int retVal;
auto pPlatform = OCLRT::platform();
cl_platform_id platformId[1];
platformId[0] = pPlatform;
auto &commandStreamReceiver = device->getCommandStreamReceiver();
auto kmdNotifyHelper = commandStreamReceiver.peekKmdNotifyHelper();
int64_t timeout = 0;
kmdNotifyHelper->obtainTimeoutParams(timeout, true, 1, 10, 2);
EXPECT_NE(1, timeout);
cl_context_properties validProperties[5] = {CL_CONTEXT_PLATFORM, (cl_context_properties)platformId[0],
clContextPropertyMock, mockContextPassFinalize, 0};
std::unique_ptr<Context> ctx(Context::create<Context>(validProperties, deviceVector, nullptr, nullptr, retVal));
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_NE(nullptr, ctx);
kmdNotifyHelper->obtainTimeoutParams(timeout, true, 1, 10, 2);
EXPECT_EQ(1, timeout);
}