Skip to content

Commit 79a185a

Browse files
authored
[SYCL][UR] Log sycl-ls adapter errors in verbose mode (#17651)
Log sycl-ls adapter errors in verbose mode. Additionally, inform the user about verbose mode when no platforms are found.
1 parent 1d0e1eb commit 79a185a

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

sycl/tools/sycl-ls/sycl-ls.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -364,21 +364,21 @@ int main(int argc, char **argv) {
364364
if (DiscardFilters && FilterEnvVars.size())
365365
unsetFilterEnvVars();
366366

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);
367+
// In verbose mode, if UR logging has not already been enabled by the user,
368+
// enable the printing of any errors related to adapter loading.
369+
const char *ur_log_loader_var = std::getenv("UR_LOG_LOADER");
370+
if (verbose && ur_log_loader_var == nullptr)
371+
setenv("UR_LOG_LOADER", "level:info;output:stderr", 1);
375372

376373
const auto &Platforms = platform::get_platforms();
377374

378-
if (orig_ur_log_loader_var == NULL)
375+
if (verbose && ur_log_loader_var == nullptr) {
379376
unsetenv("UR_LOG_LOADER");
380-
else
381-
setenv("UR_LOG_LOADER", orig_ur_log_loader_var_str.c_str(), 1);
377+
} else if (Platforms.size() == 0) {
378+
std::cout
379+
<< "No platforms found - run with '--verbose' to get more details."
380+
<< std::endl;
381+
}
382382

383383
// Keep track of the number of devices per backend
384384
std::map<backend, size_t> DeviceNums;

unified-runtime/source/common/linux/ur_lib_loader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ LibLoader::loadAdapterLibrary(const char *name) {
5858
(strstr(err, name) == NULL || strstr(err, "required by") != NULL)) {
5959
// If the adapter cannot be loaded due to missing dependencies or any
6060
// other related error, it is considered as an error.
61-
logger::error("failed to load adapter '{}' with error: {}", name, err);
61+
logger::info("failed to load adapter '{}' with error: {}", name, err);
6262
} else {
6363
// Simply having the adapter library missing isn't an error.
6464
logger::info("failed to load adapter '{}' with error: {}", name,

0 commit comments

Comments
 (0)