Files
compute-runtime/opencl/source/global_teardown/global_platform_teardown.cpp
Oskar Hubert Weber 9055ae8e54 fix: skip teardown clean up when terminating process on Windows
Per https://learn.microsoft.com/en-us/windows/win32/dlls/dllmain,
it's not safe to clean up resources in DllMain when
fdwReason == DLL_PROCESS_DETACH and lpvReserved != NULL (the process is
terminating), e.g. can result in a hang in some cases.

Related-To: NEO-14121

Signed-off-by: Oskar Hubert Weber <oskar.hubert.weber@intel.com>
2025-07-22 15:13:11 +02:00

29 lines
636 B
C++

/*
* Copyright (C) 2024-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "opencl/source/platform/platform.h"
namespace NEO {
volatile bool wasPlatformTeardownCalled = false;
void globalPlatformSetup() {
platformsImpl = new std::vector<std::unique_ptr<Platform>>;
}
void globalPlatformTeardown(bool processTermination) {
wasPlatformTeardownCalled = true;
if (processTermination) {
for (auto &platform : *platformsImpl) {
platform->devicesCleanup(processTermination);
}
return;
}
delete platformsImpl;
platformsImpl = nullptr;
}
} // namespace NEO