fix: create hwQueue when reinitialize osContext

Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>

Related-To: NEO-9877
This commit is contained in:
Maciej Plewka 2024-01-04 09:10:49 +00:00 committed by Compute-Runtime-Automation
parent d472cf0a5d
commit 3970f1bc4c
4 changed files with 82 additions and 3 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -58,9 +58,15 @@ void OsContextWin::reInitializeContext() {
bool disableContextCreationFlag = envReader.getSetting("NEO_L0_SYSMAN_NO_CONTEXT_MODE", false);
if (!disableContextCreationFlag) {
if (contextInitialized && (false == this->wddm.skipResourceCleanup())) {
wddm.getWddmInterface()->destroyHwQueue(hardwareQueue.handle);
wddm.destroyContext(wddmContextHandle);
}
UNRECOVERABLE_IF(!wddm.createContext(*this));
auto wddmInterface = wddm.getWddmInterface();
if (wddmInterface->hwQueuesSupported()) {
UNRECOVERABLE_IF(!wddmInterface->createHwQueue(*this));
UNRECOVERABLE_IF(!wddmInterface->createMonitoredFence(*this));
}
}
};

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2020-2023 Intel Corporation
# Copyright (C) 2020-2024 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
@ -117,6 +117,7 @@ endif()
if(WIN32 OR NOT DISABLE_WDDM_LINUX)
list(APPEND NEO_CORE_tests_mocks
${CMAKE_CURRENT_SOURCE_DIR}/mock_wddm.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_wddm_interface.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_wddm_interface20.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_wddm_interface23.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_wddm_residency_allocations_container.h

View File

@ -0,0 +1,24 @@
/*
* Copyright (C) 2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/os_interface/windows/wddm/wddm_interface.h"
#include "shared/test/common/test_macros/mock_method_macros.h"
namespace NEO {
class WddmMockInterface : public WddmInterface {
public:
using WddmInterface::WddmInterface;
ADDMETHOD_NOBASE(createHwQueue, bool, true, (OsContextWin & osContext));
ADDMETHOD_NOBASE_VOIDRETURN(destroyHwQueue, (D3DKMT_HANDLE hwQueue));
ADDMETHOD_NOBASE(createMonitoredFence, bool, true, (OsContextWin & osContext));
ADDMETHOD_NOBASE_VOIDRETURN(destroyMonitorFence, (MonitoredFence & monitorFence));
ADDMETHOD_NOBASE(hwQueuesSupported, bool, false, ());
ADDMETHOD_NOBASE(submit, bool, true, (uint64_t commandBuffer, size_t size, void *commandHeader, WddmSubmitArguments &submitArguments));
};
} // namespace NEO

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -8,6 +8,7 @@
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/engine_descriptor_helper.h"
#include "shared/test/common/mocks/mock_wddm.h"
#include "shared/test/common/mocks/mock_wddm_interface.h"
#include "shared/test/common/os_interface/windows/wddm_fixture.h"
using namespace NEO;
@ -99,6 +100,53 @@ TEST_F(OsContextWinTest, givenWddmOnLinuxThenDirectSubmissionIsNotSupported) {
EXPECT_FALSE(osContext->isDirectSubmissionSupported());
}
TEST_F(OsContextWinTest, givenWddmWhenReinitializeCalledThenHwQueueDestroyCalled) {
auto wddm = static_cast<WddmMock *>(osInterface->getDriverModel()->as<Wddm>());
auto mockWddmInterface = std::make_unique<WddmMockInterface>(*wddm);
auto pMockWddmInterface = mockWddmInterface.get();
wddm->wddmInterface.reset(mockWddmInterface.release());
osContext->reInitializeContext();
EXPECT_EQ(pMockWddmInterface->destroyHwQueueCalled, 1u);
}
TEST_F(OsContextWinTest, givenWddmWithHwQueuesEnabledWhenReinitializeCalledThenCreateHwQueueCalled) {
auto wddm = static_cast<WddmMock *>(osInterface->getDriverModel()->as<Wddm>());
auto mockWddmInterface = std::make_unique<WddmMockInterface>(*wddm);
mockWddmInterface->hwQueuesSupportedResult = true;
auto pMockWddmInterface = mockWddmInterface.get();
wddm->wddmInterface.reset(mockWddmInterface.release());
osContext->reInitializeContext();
EXPECT_EQ(pMockWddmInterface->createHwQueueCalled, 1u);
}
TEST_F(OsContextWinTest, givenWddmWithHwQueuesEnabledWhenReinitializeCalledThenCreateMonitorFenceCalled) {
auto wddm = static_cast<WddmMock *>(osInterface->getDriverModel()->as<Wddm>());
auto mockWddmInterface = std::make_unique<WddmMockInterface>(*wddm);
mockWddmInterface->hwQueuesSupportedResult = true;
auto pMockWddmInterface = mockWddmInterface.get();
wddm->wddmInterface.reset(mockWddmInterface.release());
osContext->reInitializeContext();
EXPECT_EQ(pMockWddmInterface->createMonitoredFenceCalled, 1u);
}
TEST_F(OsContextWinTest, givenWddmWithHwQueuesDisabledWhenReinitializeCalledThenCreateHwQueueNotCalled) {
auto wddm = static_cast<WddmMock *>(osInterface->getDriverModel()->as<Wddm>());
auto mockWddmInterface = std::make_unique<WddmMockInterface>(*wddm);
mockWddmInterface->hwQueuesSupportedResult = false;
auto pMockWddmInterface = mockWddmInterface.get();
wddm->wddmInterface.reset(mockWddmInterface.release());
osContext->reInitializeContext();
EXPECT_EQ(pMockWddmInterface->createHwQueueCalled, 0u);
}
TEST_F(OsContextWinTest, givenWddmWithHwQueuesDisabledWhenReinitializeCalledThenCreateMonitorFenceNotCalled) {
auto wddm = static_cast<WddmMock *>(osInterface->getDriverModel()->as<Wddm>());
auto mockWddmInterface = std::make_unique<WddmMockInterface>(*wddm);
mockWddmInterface->hwQueuesSupportedResult = false;
auto pMockWddmInterface = mockWddmInterface.get();
wddm->wddmInterface.reset(mockWddmInterface.release());
osContext->reInitializeContext();
EXPECT_EQ(pMockWddmInterface->createMonitoredFenceCalled, 0u);
}
struct OsContextWinTestNoCleanup : public WddmTestWithMockGdiDllNoCleanup {
void SetUp() override {
WddmTestWithMockGdiDllNoCleanup::SetUp();