File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,18 @@ namespace ur_loader {
1717context_t *getContext () { return context_t::get_direct (); }
1818
1919ur_result_t context_t::init () {
20+ #ifdef _WIN32
21+ // Suppress system errors.
22+ // Tells the system to not display the critical-error-handler message box.
23+ // Instead, the system sends the error to the calling process.
24+ // This is crucial for graceful handling of adapters that couldn't be
25+ // loaded, e.g. due to missing native run-times.
26+ // TODO: add reporting in case of an error.
27+ // NOTE: we restore the old mode to not affect user app behavior.
28+ // See https://github.com/intel/llvm/blob/sycl/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp (preloadLibraries())
29+ UINT SavedMode = SetErrorMode (SEM_FAILCRITICALERRORS);
30+ #endif
31+
2032#ifdef UR_STATIC_ADAPTER_LEVEL_ZERO
2133 // If the adapters were force loaded, it means the user wants to use
2234 // a specific adapter library. Don't load any static adapters.
@@ -35,6 +47,10 @@ ur_result_t context_t::init() {
3547 }
3648 }
3749 }
50+ #ifdef _WIN32
51+ // Restore system error handling.
52+ (void )SetErrorMode (SavedMode);
53+ #endif
3854
3955 forceIntercept = getenv_tobool (" UR_ENABLE_LOADER_INTERCEPT" );
4056
You can’t perform that action at this time.
0 commit comments