mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-29 09:03:14 +08:00
Updating files modified in 2018 only. Older files remain with old style copyright header Change-Id: Ic99f2e190ad74b4b7f2bd79dd7b9fa5fbe36ec92 Signed-off-by: Artur Harasimiuk <artur.harasimiuk@intel.com>
100 lines
4.5 KiB
C++
100 lines
4.5 KiB
C++
/*
|
|
* Copyright (C) 2018 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#include "runtime/command_stream/preemption.h"
|
|
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
|
#include "unit_tests/os_interface/windows/wddm_fixture.h"
|
|
#include "test.h"
|
|
|
|
using namespace OCLRT;
|
|
|
|
class WddmPreemptionTests : public Test<WddmFixtureWithMockGdiDll> {
|
|
public:
|
|
void SetUp() override {
|
|
WddmFixtureWithMockGdiDll::SetUp();
|
|
const HardwareInfo hwInfo = *platformDevices[0];
|
|
memcpy(&hwInfoTest, &hwInfo, sizeof(hwInfoTest));
|
|
dbgRestorer = new DebugManagerStateRestore();
|
|
}
|
|
|
|
void TearDown() override {
|
|
delete dbgRestorer;
|
|
WddmFixtureWithMockGdiDll::TearDown();
|
|
}
|
|
|
|
void createAndInitWddm(unsigned int forceReturnPreemptionRegKeyValue) {
|
|
wddm = static_cast<WddmMock *>(Wddm::createWddm());
|
|
osInterface = std::make_unique<OSInterface>();
|
|
osInterface->get()->setWddm(wddm);
|
|
auto regReader = new RegistryReaderMock();
|
|
wddm->registryReader.reset(regReader);
|
|
regReader->forceRetValue = forceReturnPreemptionRegKeyValue;
|
|
PreemptionMode preemptionMode = PreemptionHelper::getDefaultPreemptionMode(hwInfoTest);
|
|
wddm->setPreemptionMode(preemptionMode);
|
|
wddm->init();
|
|
osContext = std::make_unique<OsContext>(osInterface.get(), 0u);
|
|
osContextWin = osContext->get();
|
|
}
|
|
|
|
DebugManagerStateRestore *dbgRestorer = nullptr;
|
|
HardwareInfo hwInfoTest;
|
|
};
|
|
|
|
TEST_F(WddmPreemptionTests, givenDevicePreemptionEnabledDebugFlagDontForceWhenPreemptionRegKeySetThenSetGpuTimeoutFlagOn) {
|
|
DebugManager.flags.ForcePreemptionMode.set(-1); // dont force
|
|
hwInfoTest.capabilityTable.defaultPreemptionMode = PreemptionMode::MidThread;
|
|
unsigned int expectedVal = 1u;
|
|
createAndInitWddm(1u);
|
|
EXPECT_EQ(expectedVal, getMockCreateDeviceParamsFcn().Flags.DisableGpuTimeout);
|
|
EXPECT_EQ(expectedVal, getCreateContextDataFcn()->Flags.DisableGpuTimeout);
|
|
}
|
|
|
|
TEST_F(WddmPreemptionTests, givenDevicePreemptionDisabledDebugFlagDontForceWhenPreemptionRegKeySetThenSetGpuTimeoutFlagOff) {
|
|
DebugManager.flags.ForcePreemptionMode.set(-1); // dont force
|
|
hwInfoTest.capabilityTable.defaultPreemptionMode = PreemptionMode::Disabled;
|
|
unsigned int expectedVal = 0u;
|
|
createAndInitWddm(1u);
|
|
EXPECT_EQ(expectedVal, getMockCreateDeviceParamsFcn().Flags.DisableGpuTimeout);
|
|
EXPECT_EQ(expectedVal, getCreateContextDataFcn()->Flags.DisableGpuTimeout);
|
|
}
|
|
|
|
TEST_F(WddmPreemptionTests, givenDevicePreemptionEnabledDebugFlagDontForceWhenPreemptionRegKeyNotSetThenSetGpuTimeoutFlagOff) {
|
|
DebugManager.flags.ForcePreemptionMode.set(-1); // dont force
|
|
hwInfoTest.capabilityTable.defaultPreemptionMode = PreemptionMode::MidThread;
|
|
unsigned int expectedVal = 0u;
|
|
createAndInitWddm(0u);
|
|
EXPECT_EQ(expectedVal, getMockCreateDeviceParamsFcn().Flags.DisableGpuTimeout);
|
|
EXPECT_EQ(expectedVal, getCreateContextDataFcn()->Flags.DisableGpuTimeout);
|
|
}
|
|
|
|
TEST_F(WddmPreemptionTests, givenDevicePreemptionDisabledDebugFlagDontForceWhenPreemptionRegKeyNotSetThenSetGpuTimeoutFlagOff) {
|
|
DebugManager.flags.ForcePreemptionMode.set(-1); // dont force
|
|
hwInfoTest.capabilityTable.defaultPreemptionMode = PreemptionMode::Disabled;
|
|
unsigned int expectedVal = 0u;
|
|
createAndInitWddm(0u);
|
|
EXPECT_EQ(expectedVal, getMockCreateDeviceParamsFcn().Flags.DisableGpuTimeout);
|
|
EXPECT_EQ(expectedVal, getCreateContextDataFcn()->Flags.DisableGpuTimeout);
|
|
}
|
|
|
|
TEST_F(WddmPreemptionTests, givenDevicePreemptionDisabledDebugFlagForcePreemptionWhenPreemptionRegKeySetThenSetGpuTimeoutFlagOn) {
|
|
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::MidThread)); // force preemption
|
|
hwInfoTest.capabilityTable.defaultPreemptionMode = PreemptionMode::Disabled;
|
|
unsigned int expectedVal = 1u;
|
|
createAndInitWddm(1u);
|
|
EXPECT_EQ(expectedVal, getMockCreateDeviceParamsFcn().Flags.DisableGpuTimeout);
|
|
EXPECT_EQ(expectedVal, getCreateContextDataFcn()->Flags.DisableGpuTimeout);
|
|
}
|
|
|
|
TEST_F(WddmPreemptionTests, givenDevicePreemptionDisabledDebugFlagForcePreemptionWhenPreemptionRegKeyNotSetThenSetGpuTimeoutFlagOff) {
|
|
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::MidThread)); // force preemption
|
|
hwInfoTest.capabilityTable.defaultPreemptionMode = PreemptionMode::Disabled;
|
|
unsigned int expectedVal = 0u;
|
|
createAndInitWddm(0u);
|
|
EXPECT_EQ(expectedVal, getMockCreateDeviceParamsFcn().Flags.DisableGpuTimeout);
|
|
EXPECT_EQ(expectedVal, getCreateContextDataFcn()->Flags.DisableGpuTimeout);
|
|
}
|