Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/sycl-windows-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ permissions: read-all
jobs:
build:
name: Build + LIT
runs-on: [Windows, build]
runs-on: [Windows, build-test]
environment: WindowsCILock
outputs:
build_conclusion: ${{ steps.build.conclusion }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sycl-windows-precommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
matrix:
include:
- name: Intel GEN12 Graphics with Level Zero
runner: '["Windows","gen12"]'
runner: '["Windows","gen12-test"]'
- name: Intel Battlemage Graphics with Level Zero
runner: '["Windows","bmg"]'
uses: ./.github/workflows/sycl-windows-run-tests.yml
Expand Down
34 changes: 31 additions & 3 deletions sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ void *&getDllHandle() {

/// Load the adapter libraries
void preloadLibraries() {
std::cout << "---> one\n"
<< std::endl;
// Suppress system errors.
// Tells the system to not display the critical-error-handler message box.
// Instead, the system sends the error to the calling process.
Expand All @@ -119,44 +121,70 @@ void preloadLibraries() {
// NOTE: we restore the old mode to not affect user app behavior.
//
UINT SavedMode = SetErrorMode(SEM_FAILCRITICALERRORS);
std::cout << "---> one point five \n"
<< std::endl;
// Exclude current directory from DLL search path
if (!SetDllDirectory(L"")) {
assert(false && "Failed to update DLL search path");
}

std::cout << "---> two\n"
<< std::endl;
// this path duplicates sycl/detail/ur.cpp:initializeAdapters
std::filesystem::path LibSYCLDir(getCurrentDSODir());

std::cout << "---> three\n"
<< std::endl;
// When searching for dependencies of the adapters limit the
// list of directories to %windows%\system32 and the directory that contains
// the loaded DLL (the adapter). This is necessary to avoid loading dlls from
// current directory and some other directories which are considered unsafe.
auto loadAdapter = [&](auto adapterName,
DWORD flags = LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR |
LOAD_LIBRARY_SEARCH_SYSTEM32) {

auto path = LibSYCLDir / adapterName;
std::wcout << "---> NAME " << path.wstring() << "\n"
<< std::endl;
return LoadLibraryEx(path.wstring().c_str(), NULL, flags);
};
// We keep the UR Loader handle so it can be fetched by the runtime, but the
// adapter libraries themselves won't be used.
getDllHandle() = loadAdapter(UR_LIBRARY_NAME(loader));
std::cout << "---> four\n"
<< std::endl;
loadAdapter(UR_LIBRARY_NAME(adapter_opencl));
std::cout << "---> five\n"
<< std::endl;
loadAdapter(UR_LIBRARY_NAME(adapter_level_zero));
std::cout << "---> six\n"
<< std::endl;
loadAdapter(UR_LIBRARY_NAME(adapter_level_zero_v2));
std::cout << "---> seven\n"
<< std::endl;
loadAdapter(UR_LIBRARY_NAME(adapter_cuda));
std::cout << "---> eight\n"
<< std::endl;
loadAdapter(UR_LIBRARY_NAME(adapter_hip));
std::cout << "---> nine\n"
<< std::endl;
loadAdapter(UR_LIBRARY_NAME(adapter_native_cpu));
std::cout << "---> ten\n"
<< std::endl;
// Load the Level Zero loader dynamic library to ensure it is loaded during
// the runtime. This is necessary to avoid the level zero loader from being
// unloaded prematurely. the Only trusted loader is the one that is loaded
// from the system32 directory.
LoadLibraryExW(L"ze_loader.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);

std::cout << "---> eleven\n"
<< std::endl;
// Restore system error handling.
(void)SetErrorMode(SavedMode);
std::cout << "---> twelve\n"
<< std::endl;
if (!SetDllDirectory(nullptr)) {
assert(false && "Failed to restore DLL search path");
}
std::cout << "---> thirteen\n"
<< std::endl;
}

/// windows_ur.cpp:getURLoaderLibrary() calls this to get the DLL loaded
Expand Down
Loading