|
28 | 28 | #ifdef _WIN32
|
29 | 29 | #include <system_error>
|
30 | 30 | #include <windows.h>
|
| 31 | + |
| 32 | +#define setenv(name, var, ignore) _putenv_s(name, var) |
| 33 | +#define unsetenv(name) _putenv_s(name, "") |
| 34 | +#else |
| 35 | + |
31 | 36 | #endif
|
32 | 37 |
|
33 | 38 | using namespace sycl;
|
@@ -261,11 +266,7 @@ static void printWarningIfFiltersUsed(bool &SuppressNumberPrinting) {
|
261 | 266 | // ONEAPI_DEVICE_SELECTOR, and SYCL_DEVICE_ALLOWLIST.
|
262 | 267 | static void unsetFilterEnvVars() {
|
263 | 268 | for (const auto &it : FilterEnvVars) {
|
264 |
| -#ifdef _WIN32 |
265 |
| - _putenv_s(it.c_str(), ""); |
266 |
| -#else |
267 | 269 | unsetenv(it.c_str());
|
268 |
| -#endif |
269 | 270 | }
|
270 | 271 | }
|
271 | 272 |
|
@@ -363,8 +364,22 @@ int main(int argc, char **argv) {
|
363 | 364 | if (DiscardFilters && FilterEnvVars.size())
|
364 | 365 | unsetFilterEnvVars();
|
365 | 366 |
|
| 367 | + // Store the original UR_LOG_LOADER environment variable and enable printing |
| 368 | + // of any errors related to adapter loading. |
| 369 | + const char *orig_ur_log_loader_var = std::getenv("UR_LOG_LOADER"); |
| 370 | + std::string orig_ur_log_loader_var_str; |
| 371 | + if (orig_ur_log_loader_var != NULL) |
| 372 | + orig_ur_log_loader_var_str.assign(orig_ur_log_loader_var); |
| 373 | + |
| 374 | + setenv("UR_LOG_LOADER", "level:error;output:stderr", 1); |
| 375 | + |
366 | 376 | const auto &Platforms = platform::get_platforms();
|
367 | 377 |
|
| 378 | + if (orig_ur_log_loader_var == NULL) |
| 379 | + unsetenv("UR_LOG_LOADER"); |
| 380 | + else |
| 381 | + setenv("UR_LOG_LOADER", orig_ur_log_loader_var_str.c_str(), 1); |
| 382 | + |
368 | 383 | // Keep track of the number of devices per backend
|
369 | 384 | std::map<backend, size_t> DeviceNums;
|
370 | 385 |
|
|
0 commit comments