File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
source/adapters/level_zero Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 1212#include " ur_level_zero.hpp"
1313#include < iomanip>
1414
15+ // As windows order of unloading dlls is reversed from linux, windows will call
16+ // umfTearDown before it could release umf objects in level_zero, so we call
17+ // umfInit on urAdapterGet and umfAdapterTearDown to enforce the teardown of umf
18+ // after umf objects are destructed.
19+ #if defined(_WIN32)
20+ #include < umf.h>
21+ #endif
22+
1523// Due to multiple DLLMain definitions with SYCL, Global Adapter is init at
1624// variable creation.
1725#if defined(_WIN32)
@@ -74,7 +82,14 @@ ur_result_t initPlatforms(PlatformVec &platforms) noexcept try {
7482 return exceptionToResult (std::current_exception ());
7583}
7684
77- ur_result_t adapterStateInit () { return UR_RESULT_SUCCESS; }
85+ ur_result_t adapterStateInit () {
86+
87+ #if defined(_WIN32)
88+ umfInit ();
89+ #endif
90+
91+ return UR_RESULT_SUCCESS;
92+ }
7893
7994ur_adapter_handle_t_::ur_adapter_handle_t_ ()
8095 : logger(logger::get_logger(" level_zero" )) {
@@ -258,6 +273,7 @@ ur_result_t adapterStateTeardown() {
258273 // Due to multiple DLLMain definitions with SYCL, register to cleanup the
259274 // Global Adapter after refcnt is 0
260275#if defined(_WIN32)
276+ umfTearDown ();
261277 std::atexit (globalAdapterOnDemandCleanup);
262278#endif
263279
You can’t perform that action at this time.
0 commit comments