Skip to content

Commit b1c6be1

Browse files
bratpiorkaRossBrunton
authored andcommitted
Log sycl-ls error messages related to adapter loading (#17490)
Changes: * change the log level to "error" for all errors related to adapter dependencies during UR adapter loading * enable the printing of UR adapter errors in sycl-ls from platform::get_platforms() using environment variables With this PR, there will be no changes for the user in the default scenario where some adapters exist and some are missing (a missing adapter is not considered an error). In cases where a dependency is missing, the following example message will be displayed: ``` <LOADER>[ERROR]: failed to load adapter 'libur_adapter_level_zero.so.0' with error: libumf.so.0: cannot open shared object file: No such file or directory ``` Here is the message for missing symbols (a case where a dependency is not compatible with the rest of the libraries): ``` <LOADER>[ERROR]: failed to load adapter 'libur_adapter_level_zero.so.0' with error: /home/rrudnick/llvm/build/lib/libumf.so.0: version `UMF_0.10' not found (required by /home/rrudnick/llvm/build/lib/libur_adapter_level_zero.so.0) ```
1 parent c6a3017 commit b1c6be1

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

source/common/linux/ur_lib_loader.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,20 @@ LibLoader::loadAdapterLibrary(const char *name) {
5050
#endif
5151
HMODULE handle = dlopen(name, mode);
5252
if (!handle) {
53-
char *err = dlerror();
54-
logger::info("failed to load adapter '{}' with error: {}", name,
55-
err ? err : "unknown error");
53+
const char *err = dlerror();
54+
55+
// Check if the error string does not contain the adapter name or if it
56+
// contains a "required by" (missing symbol) message.
57+
if (err &&
58+
(strstr(err, name) == NULL || strstr(err, "required by") != NULL)) {
59+
// If the adapter cannot be loaded due to missing dependencies or any
60+
// other related error, it is considered as an error.
61+
logger::error("failed to load adapter '{}' with error: {}", name, err);
62+
} else {
63+
// Simply having the adapter library missing isn't an error.
64+
logger::info("failed to load adapter '{}' with error: {}", name,
65+
err ? err : "unknown error");
66+
}
5667
} else {
5768
#if defined(ADD_FULL_PATH_LOG)
5869
struct link_map *dlinfo_map;

0 commit comments

Comments
 (0)