Skip to content

Commit bd73e57

Browse files
uditagarwal97bb-ur
authored andcommitted
Lazily initialize GlobalAdapter (#21490)
**Problem** `ur_win_proxy_loader` loads L0 adapter DLL in its `DLLMain`. Global variables are initialized during DLL loading and so is `GlobalAdapter` - which tries to initialize L0 driver (`zeInit`). `zeInit` may spawn threads and it's illegal to spawn threads directly or indirectly from `DLLMain`. This is causing deadlock with some L0 driver versions. **Proposed Solution** Lazily initialize `GlobalAdapter`, just like what we do on Linux.
1 parent 9a298c6 commit bd73e57

1 file changed

Lines changed: 1 addition & 7 deletions

File tree

source/adapters/level_zero/adapter.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,8 @@
2222
#endif
2323

2424
ZeUSMImportExtension ZeUSMImport;
25-
26-
// Due to multiple DLLMain definitions with SYCL, Global Adapter is init at
27-
// variable creation.
28-
#if defined(_WIN32)
29-
ur_adapter_handle_t_ *GlobalAdapter = new ur_adapter_handle_t_();
30-
#else
3125
ur_adapter_handle_t_ *GlobalAdapter;
32-
#endif
26+
3327
// This is a temporary workaround on windows, where UR adapter is teardowned
3428
// before the UR loader, which will result in access violation when we use print
3529
// function as the overrided print function was already released with the UR

0 commit comments

Comments
 (0)