Skip to content

[UR] Logger callback function sink #17095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 10, 2025
Merged
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
16 changes: 16 additions & 0 deletions sycl/source/detail/ur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ void *getAdapterOpaqueData([[maybe_unused]] void *OpaqueDataParam) {

ur_code_location_t codeLocationCallback(void *);

void urLoggerCallback([[maybe_unused]] ur_logger_level_t level, const char *msg,
[[maybe_unused]] void *userData) {
std::cerr << msg << std::endl;
}

namespace ur {
bool trace(TraceLevel Level) {
auto TraceLevelMask = SYCLConfig<SYCL_UR_TRACE>::get();
Expand Down Expand Up @@ -138,6 +143,11 @@ static void initializeAdapters(std::vector<AdapterPtr> &Adapters,
UrFuncInfo<UrApiKind::urAdapterGetInfo> adapterGetInfoInfo;
auto adapterGetInfo =
adapterGetInfoInfo.getFuncPtrFromModule(ur::getURLoaderLibrary());
UrFuncInfo<UrApiKind::urAdapterSetLoggerCallback>
adapterSetLoggerCallbackInfo;
auto adapterSetLoggerCallback =
adapterSetLoggerCallbackInfo.getFuncPtrFromModule(
ur::getURLoaderLibrary());

bool OwnLoaderConfig = false;
// If we weren't provided with a custom config handle create our own.
Expand Down Expand Up @@ -219,6 +229,12 @@ static void initializeAdapters(std::vector<AdapterPtr> &Adapters,
nullptr));
auto syclBackend = UrToSyclBackend(adapterBackend);
Adapters.emplace_back(std::make_shared<Adapter>(UrAdapter, syclBackend));

const char *env_value = std::getenv("UR_LOG_CALLBACK");
if (env_value == nullptr || std::string(env_value) != "disabled") {
CHECK_UR_SUCCESS(adapterSetLoggerCallback(UrAdapter, urLoggerCallback,
nullptr, UR_LOGGER_LEVEL_INFO));
}
}

#ifdef XPTI_ENABLE_INSTRUMENTATION
Expand Down
1 change: 0 additions & 1 deletion sycl/test-e2e/External/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,3 @@ cmake \
make check-sycl-e2e

```

2 changes: 2 additions & 0 deletions sycl/test-e2e/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@
lit_config.note("\tUnset " + var)
llvm_config.with_environment(var, "")

# Disable the UR logger callback sink during test runs as output to SYCL RT can interfere with some tests relying on standard input/output
llvm_config.with_environment("UR_LOG_CALLBACK", "disabled")

# Temporarily modify environment to be the same that we use when running tests
class test_env:
Expand Down
3 changes: 3 additions & 0 deletions sycl/test/Unit/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,6 @@ def find_shlibpath_var():

config.environment["SYCL_CACHE_DIR"] = config.llvm_obj_root + "/sycl_cache"
lit_config.note("SYCL cache directory: {}".format(config.environment["SYCL_CACHE_DIR"]))

# Disable the UR logger callback sink during test runs as output to SYCL RT can interfere with some tests relying on standard input/output
config.environment["UR_LOG_CALLBACK"] = "disabled"
3 changes: 3 additions & 0 deletions sycl/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@
)
)

# Disable the UR logger callback sink during test runs as output to SYCL RT can interfere with some tests relying on standard input/output
llvm_config.with_environment("UR_LOG_CALLBACK", "disabled")

# Dump-only tests do not have clang available
if not dump_only_tests:
llvm_config.use_clang(additional_flags=additional_flags)
Expand Down
98 changes: 98 additions & 0 deletions unified-runtime/include/ur_api.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions unified-runtime/include/ur_api_funcs.def

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions unified-runtime/include/ur_ddi.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions unified-runtime/include/ur_print.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading