mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Defer OsContext initialization
Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com> Related-To: NEO-5610
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
b01b8ba5ac
commit
5318ff1872
@ -56,7 +56,6 @@ using namespace ::testing;
|
||||
class WddmCommandStreamFixture {
|
||||
public:
|
||||
std::unique_ptr<MockDevice> device;
|
||||
std::unique_ptr<OsContext> osContext;
|
||||
DeviceCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> *csr;
|
||||
MockWddmMemoryManager *memoryManager = nullptr;
|
||||
WddmMock *wddm = nullptr;
|
||||
@ -72,14 +71,11 @@ class WddmCommandStreamFixture {
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
wddm = static_cast<WddmMock *>(executionEnvironment->rootDeviceEnvironments[0]->osInterface->get()->getWddm());
|
||||
device.reset(MockDevice::create<MockDevice>(executionEnvironment, 0u));
|
||||
osContext.reset(OsContext::create(executionEnvironment->rootDeviceEnvironments[0]->osInterface.get(),
|
||||
0, device->getDeviceBitfield(), EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::ThreadGroup,
|
||||
false));
|
||||
osContext->setDefaultContext(true);
|
||||
csr = new WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>(*executionEnvironment, 0, device->getDeviceBitfield());
|
||||
|
||||
device->resetCommandStreamReceiver(csr);
|
||||
ASSERT_NE(nullptr, device);
|
||||
|
||||
csr = new WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>(*executionEnvironment, 0, device->getDeviceBitfield());
|
||||
device->resetCommandStreamReceiver(csr);
|
||||
csr->getOsContext().ensureContextInitialized();
|
||||
}
|
||||
|
||||
virtual void TearDown() {
|
||||
|
@ -26,23 +26,26 @@ struct OsContextWinTest : public WddmTestWithMockGdiDll {
|
||||
};
|
||||
|
||||
TEST_F(OsContextWinTest, givenWddm20WhenCreatingOsContextThenOsContextIsInitialized) {
|
||||
EXPECT_NO_THROW(osContext = std::make_unique<OsContextWin>(*osInterface->get()->getWddm(), 0u, 1, engineTypeUsage, preemptionMode, false));
|
||||
EXPECT_NE(nullptr, osContext);
|
||||
osContext = std::make_unique<OsContextWin>(*osInterface->get()->getWddm(), 0u, 1, engineTypeUsage, preemptionMode, false);
|
||||
EXPECT_NO_THROW(osContext->ensureContextInitialized());
|
||||
}
|
||||
|
||||
TEST_F(OsContextWinTest, givenWddm20WhenCreatingWddmContextFailThenOsContextCreationFails) {
|
||||
wddm->device = INVALID_HANDLE;
|
||||
EXPECT_ANY_THROW(osContext = std::make_unique<OsContextWin>(*osInterface->get()->getWddm(), 0u, 1, engineTypeUsage, preemptionMode, false));
|
||||
osContext = std::make_unique<OsContextWin>(*osInterface->get()->getWddm(), 0u, 1, engineTypeUsage, preemptionMode, false);
|
||||
EXPECT_ANY_THROW(osContext->ensureContextInitialized());
|
||||
}
|
||||
|
||||
TEST_F(OsContextWinTest, givenWddm20WhenCreatingWddmMonitorFenceFailThenOsContextCreationFails) {
|
||||
*getCreateSynchronizationObject2FailCallFcn() = true;
|
||||
EXPECT_ANY_THROW(osContext = std::make_unique<OsContextWin>(*osInterface->get()->getWddm(), 0u, 1, engineTypeUsage, preemptionMode, false));
|
||||
osContext = std::make_unique<OsContextWin>(*osInterface->get()->getWddm(), 0u, 1, engineTypeUsage, preemptionMode, false);
|
||||
EXPECT_ANY_THROW(osContext->ensureContextInitialized());
|
||||
}
|
||||
|
||||
TEST_F(OsContextWinTest, givenWddm20WhenRegisterTrimCallbackFailThenOsContextCreationFails) {
|
||||
*getRegisterTrimNotificationFailCallFcn() = true;
|
||||
EXPECT_ANY_THROW(osContext = std::make_unique<OsContextWin>(*osInterface->get()->getWddm(), 0u, 1, engineTypeUsage, preemptionMode, false));
|
||||
osContext = std::make_unique<OsContextWin>(*osInterface->get()->getWddm(), 0u, 1, engineTypeUsage, preemptionMode, false);
|
||||
EXPECT_ANY_THROW(osContext->ensureContextInitialized());
|
||||
}
|
||||
|
||||
TEST_F(OsContextWinTest, givenWddm20WhenRegisterTrimCallbackIsDisabledThenOsContextIsInitialized) {
|
||||
@ -50,6 +53,6 @@ TEST_F(OsContextWinTest, givenWddm20WhenRegisterTrimCallbackIsDisabledThenOsCont
|
||||
DebugManager.flags.DoNotRegisterTrimCallback.set(true);
|
||||
*getRegisterTrimNotificationFailCallFcn() = true;
|
||||
|
||||
EXPECT_NO_THROW(osContext = std::make_unique<OsContextWin>(*osInterface->get()->getWddm(), 0u, 1, engineTypeUsage, preemptionMode, false));
|
||||
EXPECT_NE(nullptr, osContext);
|
||||
osContext = std::make_unique<OsContextWin>(*osInterface->get()->getWddm(), 0u, 1, engineTypeUsage, preemptionMode, false);
|
||||
EXPECT_NO_THROW(osContext->ensureContextInitialized());
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ TEST(OsContextTest, givenWddmWhenCreateOsContextAfterInitWddmThenOsContextIsInit
|
||||
auto osContext = std::make_unique<OsContextWin>(*wddm, 0u, 1,
|
||||
HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*defaultHwInfo)[0],
|
||||
preemptionMode, false);
|
||||
osContext->ensureContextInitialized();
|
||||
EXPECT_EQ(osContext->getWddm(), wddm);
|
||||
EXPECT_EQ(1u, wddm->registerTrimCallbackResult.called);
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ struct Wddm23TestsWithoutWddmInit : public ::testing::Test, GdiDllFixture {
|
||||
osContext = std::make_unique<OsContextWin>(*wddm, 0u, 1,
|
||||
HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*defaultHwInfo)[0],
|
||||
preemptionMode, false);
|
||||
osContext->ensureContextInitialized();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
|
@ -49,6 +49,7 @@ struct WddmFixture : public Test<MockExecutionEnvironmentGmmFixture> {
|
||||
auto engine = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0];
|
||||
osContext = std::make_unique<OsContextWin>(*osInterface->get()->getWddm(), 0u, 1u, engine, preemptionMode,
|
||||
false);
|
||||
osContext->ensureContextInitialized();
|
||||
mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(wddm->temporaryResources.get());
|
||||
}
|
||||
|
||||
@ -85,6 +86,7 @@ struct WddmFixtureWithMockGdiDll : public GdiDllFixture, public MockExecutionEnv
|
||||
auto engine = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0];
|
||||
osContext = std::make_unique<OsContextWin>(*osInterface->get()->getWddm(), 0u, 1, engine, preemptionMode,
|
||||
false);
|
||||
osContext->ensureContextInitialized();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
|
@ -386,13 +386,14 @@ TEST_F(WddmMemoryManagerSimpleTest, givenNonZeroFenceValuesOnMultipleEnginesRegi
|
||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm2);
|
||||
|
||||
auto hwInfo = executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo();
|
||||
memoryManager->createAndRegisterOsContext(csr.get(), HwHelper::get(hwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[1],
|
||||
deviceBitfield, PreemptionHelper::getDefaultPreemptionMode(*hwInfo),
|
||||
false);
|
||||
OsContext *osContext = memoryManager->createAndRegisterOsContext(csr.get(), HwHelper::get(hwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[1],
|
||||
deviceBitfield, PreemptionHelper::getDefaultPreemptionMode(*hwInfo),
|
||||
false);
|
||||
osContext->ensureContextInitialized();
|
||||
ASSERT_EQ(2u, memoryManager->getRegisteredEnginesCount());
|
||||
|
||||
auto allocation = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties({0u, 32, GraphicsAllocation::AllocationType::BUFFER, mockDeviceBitfield}));
|
||||
auto lastEngineFence = &static_cast<OsContextWin *>(memoryManager->getRegisteredEngines()[1].osContext)->getResidencyController().getMonitoredFence();
|
||||
auto lastEngineFence = &static_cast<OsContextWin *>(osContext)->getResidencyController().getMonitoredFence();
|
||||
allocation->getResidencyData().updateCompletionData(129u, 0u);
|
||||
allocation->getResidencyData().updateCompletionData(152u, 1u);
|
||||
|
||||
|
@ -70,6 +70,7 @@ class MockWddmMemoryManagerFixture {
|
||||
osContext = memoryManager->createAndRegisterOsContext(csr.get(),
|
||||
HwHelper::get(hwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0],
|
||||
1, PreemptionHelper::getDefaultPreemptionMode(*hwInfo), false);
|
||||
osContext->ensureContextInitialized();
|
||||
|
||||
osContext->incRefInternal();
|
||||
mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(wddm->getTemporaryResourcesContainer());
|
||||
|
@ -136,6 +136,7 @@ struct WddmResidencyControllerWithMockWddmTest : public WddmResidencyControllerT
|
||||
osContext = memoryManager->createAndRegisterOsContext(csr.get(),
|
||||
HwHelper::get(hwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0], 1, preemptionMode,
|
||||
false);
|
||||
osContext->ensureContextInitialized();
|
||||
|
||||
osContext->incRefInternal();
|
||||
residencyController = &static_cast<OsContextWin *>(osContext)->getResidencyController();
|
||||
@ -173,6 +174,7 @@ struct WddmResidencyControllerWithGdiAndMemoryManagerTest : ::testing::Test {
|
||||
HwHelper::get(hwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0],
|
||||
1, PreemptionHelper::getDefaultPreemptionMode(*hwInfo),
|
||||
false);
|
||||
osContext->ensureContextInitialized();
|
||||
|
||||
osContext->incRefInternal();
|
||||
|
||||
|
Reference in New Issue
Block a user