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 12
12
#include " ur_level_zero.hpp"
13
13
#include < iomanip>
14
14
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
+
15
23
// Due to multiple DLLMain definitions with SYCL, Global Adapter is init at
16
24
// variable creation.
17
25
#if defined(_WIN32)
@@ -74,7 +82,14 @@ ur_result_t initPlatforms(PlatformVec &platforms) noexcept try {
74
82
return exceptionToResult (std::current_exception ());
75
83
}
76
84
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
+ }
78
93
79
94
ur_adapter_handle_t_::ur_adapter_handle_t_ ()
80
95
: logger(logger::get_logger(" level_zero" )) {
@@ -258,6 +273,7 @@ ur_result_t adapterStateTeardown() {
258
273
// Due to multiple DLLMain definitions with SYCL, register to cleanup the
259
274
// Global Adapter after refcnt is 0
260
275
#if defined(_WIN32)
276
+ umfTearDown ();
261
277
std::atexit (globalAdapterOnDemandCleanup);
262
278
#endif
263
279
You can’t perform that action at this time.
0 commit comments