mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-29 09:03:14 +08:00
Add mechanism to avoid calling gdi calls while process exit
Signed-off-by: Kamil Diedrich <kamil.diedrich@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
673a6244ee
commit
ddd8a08fac
@@ -173,7 +173,7 @@ void CommandStreamReceiver::makeResidentHostPtrAllocation(GraphicsAllocation *gf
|
||||
|
||||
WaitStatus CommandStreamReceiver::waitForTaskCount(uint32_t requiredTaskCount) {
|
||||
auto address = getTagAddress();
|
||||
if (address) {
|
||||
if (!skipResourceCleanup() && address) {
|
||||
this->downloadTagAllocation(requiredTaskCount);
|
||||
return baseWaitFunction(address, WaitParams{false, false, 0}, requiredTaskCount);
|
||||
}
|
||||
@@ -268,10 +268,6 @@ bool CommandStreamReceiver::isGpuHangDetected() const {
|
||||
}
|
||||
|
||||
void CommandStreamReceiver::cleanupResources() {
|
||||
if (this->skipResourceCleanup()) {
|
||||
return;
|
||||
}
|
||||
|
||||
waitForTaskCountAndCleanAllocationList(this->latestFlushedTaskCount, TEMPORARY_ALLOCATION);
|
||||
waitForTaskCountAndCleanAllocationList(this->latestFlushedTaskCount, REUSABLE_ALLOCATION);
|
||||
|
||||
|
||||
@@ -36,12 +36,6 @@ Device::Device(ExecutionEnvironment *executionEnvironment, const uint32_t rootDe
|
||||
}
|
||||
|
||||
Device::~Device() {
|
||||
if (false == commandStreamReceivers.empty()) {
|
||||
if (commandStreamReceivers[0]->skipResourceCleanup()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
finalizeRayTracing();
|
||||
|
||||
DEBUG_BREAK_IF(nullptr == executionEnvironment->memoryManager.get());
|
||||
|
||||
@@ -122,6 +122,14 @@ void ExecutionEnvironment::prepareRootDeviceEnvironments(uint32_t numRootDevices
|
||||
}
|
||||
}
|
||||
|
||||
void ExecutionEnvironment::prepareForCleanup() const {
|
||||
for (auto &rootDeviceEnvironment : rootDeviceEnvironments) {
|
||||
if (rootDeviceEnvironment) {
|
||||
rootDeviceEnvironment->prepareForCleanup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ExecutionEnvironment::prepareRootDeviceEnvironment(const uint32_t rootDeviceIndexForReInit) {
|
||||
rootDeviceEnvironments[rootDeviceIndexForReInit] = std::make_unique<RootDeviceEnvironment>(*this);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ class ExecutionEnvironment : public ReferenceTrackedObject<ExecutionEnvironment>
|
||||
void sortNeoDevices();
|
||||
void sortNeoDevicesDRM();
|
||||
void sortNeoDevicesWDDM();
|
||||
void prepareForCleanup() const;
|
||||
void setDebuggingEnabled() {
|
||||
debuggingEnabled = true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
* Copyright (C) 2019-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -69,6 +69,12 @@ GmmClientContext *RootDeviceEnvironment::getGmmClientContext() const {
|
||||
return gmmHelper->getClientContext();
|
||||
}
|
||||
|
||||
void RootDeviceEnvironment::prepareForCleanup() const {
|
||||
if (osInterface && osInterface->getDriverModel()) {
|
||||
osInterface->getDriverModel()->isDriverAvaliable();
|
||||
}
|
||||
}
|
||||
|
||||
bool RootDeviceEnvironment::initAilConfiguration() {
|
||||
auto ailConfiguration = AILConfiguration::get(hwInfo->platform.eProductFamily);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
* Copyright (C) 2019-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -54,6 +54,7 @@ struct RootDeviceEnvironment {
|
||||
void initOsTime();
|
||||
void initGmm();
|
||||
void initDebugger();
|
||||
MOCKABLE_VIRTUAL void prepareForCleanup() const;
|
||||
MOCKABLE_VIRTUAL bool initAilConfiguration();
|
||||
GmmHelper *getGmmHelper() const;
|
||||
GmmClientContext *getGmmClientContext() const;
|
||||
|
||||
@@ -83,14 +83,19 @@ class DriverModel : public NonCopyableClass {
|
||||
return std::numeric_limits<size_t>::max();
|
||||
}
|
||||
|
||||
virtual bool skipResourceCleanup() const {
|
||||
return false;
|
||||
virtual bool isDriverAvaliable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool skipResourceCleanup() const {
|
||||
return skipResourceCleanupVar;
|
||||
}
|
||||
|
||||
virtual bool isGpuHangDetected(OsContext &osContext) = 0;
|
||||
|
||||
protected:
|
||||
DriverModelType driverModelType;
|
||||
bool skipResourceCleanupVar = false;
|
||||
};
|
||||
|
||||
class OSInterface : public NonCopyableClass {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -10,14 +10,42 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
bool Wddm::skipResourceCleanup() const {
|
||||
NTSTATUS destroyAllocationNoOp(const D3DKMT_DESTROYALLOCATION2 *allocStruct) {
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS waitForSynchronizationObjectFromCpuNoOp(const D3DKMT_WAITFORSYNCHRONIZATIONOBJECTFROMCPU *waitStruct) {
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS destroyPagingQueueNoOp(D3DDDI_DESTROYPAGINGQUEUE *destroyPagingQueue) {
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS destroyDeviceNoOp(const D3DKMT_DESTROYDEVICE *destroyDevice) {
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS closeAdapterNoOp(const D3DKMT_CLOSEADAPTER *closeAdapter) {
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
bool Wddm::isDriverAvaliable() {
|
||||
D3DKMT_GETDEVICESTATE deviceState = {};
|
||||
deviceState.hDevice = device;
|
||||
deviceState.StateType = D3DKMT_DEVICESTATE_PRESENT;
|
||||
|
||||
NTSTATUS status = STATUS_SUCCESS;
|
||||
status = getGdi()->getDeviceState(&deviceState);
|
||||
return status != STATUS_SUCCESS;
|
||||
if (status != STATUS_SUCCESS) {
|
||||
skipResourceCleanupVar = true;
|
||||
getGdi()->destroyAllocation2 = &destroyAllocationNoOp;
|
||||
getGdi()->waitForSynchronizationObjectFromCpu = &waitForSynchronizationObjectFromCpuNoOp;
|
||||
getGdi()->destroyPagingQueue = &destroyPagingQueueNoOp;
|
||||
getGdi()->destroyDevice = &destroyDeviceNoOp;
|
||||
getGdi()->closeAdapter = &closeAdapterNoOp;
|
||||
}
|
||||
return status == STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
bool Wddm::skipResourceCleanup() const {
|
||||
return false;
|
||||
bool Wddm::isDriverAvaliable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -937,14 +937,13 @@ bool Wddm::waitOnGPU(D3DKMT_HANDLE context) {
|
||||
bool Wddm::waitFromCpu(uint64_t lastFenceValue, const MonitoredFence &monitoredFence) {
|
||||
NTSTATUS status = STATUS_SUCCESS;
|
||||
|
||||
if (lastFenceValue > *monitoredFence.cpuAddress) {
|
||||
if (!skipResourceCleanup() && lastFenceValue > *monitoredFence.cpuAddress) {
|
||||
D3DKMT_WAITFORSYNCHRONIZATIONOBJECTFROMCPU waitFromCpu = {};
|
||||
waitFromCpu.ObjectCount = 1;
|
||||
waitFromCpu.ObjectHandleArray = &monitoredFence.fenceHandle;
|
||||
waitFromCpu.FenceValueArray = &lastFenceValue;
|
||||
waitFromCpu.hDevice = device;
|
||||
waitFromCpu.hAsyncEvent = NULL_HANDLE;
|
||||
|
||||
status = getGdi()->waitForSynchronizationObjectFromCpu(&waitFromCpu);
|
||||
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ class Wddm : public DriverModel {
|
||||
PhysicalDevicePciBusInfo getPciBusInfo() const override;
|
||||
|
||||
size_t getMaxMemAllocSize() const override;
|
||||
bool skipResourceCleanup() const override;
|
||||
bool isDriverAvaliable() override;
|
||||
|
||||
static std::vector<std::unique_ptr<HwDeviceId>> discoverDevices(ExecutionEnvironment &executionEnvironment);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user