diff --git a/sycl/source/detail/ur.cpp b/sycl/source/detail/ur.cpp index 5a799b2145048..ea4be9e979bcc 100644 --- a/sycl/source/detail/ur.cpp +++ b/sycl/source/detail/ur.cpp @@ -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::get(); @@ -138,6 +143,11 @@ static void initializeAdapters(std::vector &Adapters, UrFuncInfo adapterGetInfoInfo; auto adapterGetInfo = adapterGetInfoInfo.getFuncPtrFromModule(ur::getURLoaderLibrary()); + UrFuncInfo + adapterSetLoggerCallbackInfo; + auto adapterSetLoggerCallback = + adapterSetLoggerCallbackInfo.getFuncPtrFromModule( + ur::getURLoaderLibrary()); bool OwnLoaderConfig = false; // If we weren't provided with a custom config handle create our own. @@ -219,6 +229,12 @@ static void initializeAdapters(std::vector &Adapters, nullptr)); auto syclBackend = UrToSyclBackend(adapterBackend); Adapters.emplace_back(std::make_shared(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 diff --git a/sycl/test-e2e/External/README.md b/sycl/test-e2e/External/README.md index 6d7ff53adf197..6b676610c1f2f 100644 --- a/sycl/test-e2e/External/README.md +++ b/sycl/test-e2e/External/README.md @@ -76,4 +76,3 @@ cmake \ make check-sycl-e2e ``` - diff --git a/sycl/test-e2e/lit.cfg.py b/sycl/test-e2e/lit.cfg.py index 222ae37208b59..5e38caf2de246 100644 --- a/sycl/test-e2e/lit.cfg.py +++ b/sycl/test-e2e/lit.cfg.py @@ -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: diff --git a/sycl/test/Unit/lit.cfg.py b/sycl/test/Unit/lit.cfg.py index f68681a5c0dbf..e2e95da2d95e6 100644 --- a/sycl/test/Unit/lit.cfg.py +++ b/sycl/test/Unit/lit.cfg.py @@ -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" diff --git a/sycl/test/lit.cfg.py b/sycl/test/lit.cfg.py index 089395d5c1400..dfe1e6a231616 100644 --- a/sycl/test/lit.cfg.py +++ b/sycl/test/lit.cfg.py @@ -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) diff --git a/unified-runtime/include/ur_api.h b/unified-runtime/include/ur_api.h index 120b12c618250..1da78ba68948f 100644 --- a/unified-runtime/include/ur_api.h +++ b/unified-runtime/include/ur_api.h @@ -457,6 +457,10 @@ typedef enum ur_function_t { UR_FUNCTION_COMMAND_BUFFER_GET_NATIVE_HANDLE_EXP = 264, /// Enumerator for ::urUSMPoolSetInfoExp UR_FUNCTION_USM_POOL_SET_INFO_EXP = 265, + /// Enumerator for ::urAdapterSetLoggerCallback + UR_FUNCTION_ADAPTER_SET_LOGGER_CALLBACK = 266, + /// Enumerator for ::urAdapterSetLoggerCallbackLevel + UR_FUNCTION_ADAPTER_SET_LOGGER_CALLBACK_LEVEL = 267, /// @cond UR_FUNCTION_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -1423,6 +1427,80 @@ typedef enum ur_adapter_backend_t { } ur_adapter_backend_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Minimum level of messages to be processed by the logger. +typedef enum ur_logger_level_t { + /// Debugging messages used for development purposes. + UR_LOGGER_LEVEL_DEBUG = 0, + /// General messages not related to debugging, warnings or errors. + UR_LOGGER_LEVEL_INFO = 1, + /// Used to warn users about potential problems. + UR_LOGGER_LEVEL_WARN = 2, + /// Used when an error has occurred. + UR_LOGGER_LEVEL_ERROR = 3, + /// Restrict logger processing any messages. + UR_LOGGER_LEVEL_QUIET = 4, + /// @cond + UR_LOGGER_LEVEL_FORCE_UINT32 = 0x7fffffff + /// @endcond + +} ur_logger_level_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function to retrieve output from the logger. +typedef void (*ur_logger_callback_t)( + /// [out] Minimum level of messages to be processed by the logger. + ur_logger_level_t level, + /// [in][out] pointer to data to be passed to callback + const char *pLoggerMsg, + /// [in][out] pointer to data to be passed to callback + void *pUserData); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Set a callback function for use by the logger to retrieve logging +/// output. +/// It is a requirement that the callback function is thread safe and the +/// creator of the function will be responsible for this. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hAdapter` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pfnLoggerCallback` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_LOGGER_LEVEL_QUIET < level` +UR_APIEXPORT ur_result_t UR_APICALL urAdapterSetLoggerCallback( + /// [in] handle of the adapter + ur_adapter_handle_t hAdapter, + /// [in] Function pointer to callback from the logger. + ur_logger_callback_t pfnLoggerCallback, + /// [in][out][optional] pointer to data to be passed to callback + void *pUserData, + /// [in] logging level + ur_logger_level_t level); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Set the minimum logging level for the logger Callback function. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hAdapter` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_LOGGER_LEVEL_QUIET < level` +UR_APIEXPORT ur_result_t UR_APICALL urAdapterSetLoggerCallbackLevel( + /// [in] handle of the adapter + ur_adapter_handle_t hAdapter, + /// [in] logging level + ur_logger_level_t level); + #if !defined(__GNUC__) #pragma endregion #endif @@ -12765,6 +12843,26 @@ typedef struct ur_loader_config_set_mocking_enabled_params_t { ur_bool_t *penable; } ur_loader_config_set_mocking_enabled_params_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urAdapterSetLoggerCallback +/// @details Each entry is a pointer to the parameter passed to the function; +/// allowing the callback the ability to modify the parameter's value +typedef struct ur_adapter_set_logger_callback_params_t { + ur_adapter_handle_t *phAdapter; + ur_logger_callback_t *ppfnLoggerCallback; + void **ppUserData; + ur_logger_level_t *plevel; +} ur_adapter_set_logger_callback_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urAdapterSetLoggerCallbackLevel +/// @details Each entry is a pointer to the parameter passed to the function; +/// allowing the callback the ability to modify the parameter's value +typedef struct ur_adapter_set_logger_callback_level_params_t { + ur_adapter_handle_t *phAdapter; + ur_logger_level_t *plevel; +} ur_adapter_set_logger_callback_level_params_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Function parameters for urPlatformGet /// @details Each entry is a pointer to the parameter passed to the function; diff --git a/unified-runtime/include/ur_api_funcs.def b/unified-runtime/include/ur_api_funcs.def index de3e0a5e38d92..33f10870bf8d5 100644 --- a/unified-runtime/include/ur_api_funcs.def +++ b/unified-runtime/include/ur_api_funcs.def @@ -17,6 +17,8 @@ // Auto-generated file, do not edit. +_UR_API(urAdapterSetLoggerCallback) +_UR_API(urAdapterSetLoggerCallbackLevel) _UR_API(urPlatformGet) _UR_API(urPlatformGetInfo) _UR_API(urPlatformGetNativeHandle) diff --git a/unified-runtime/include/ur_ddi.h b/unified-runtime/include/ur_ddi.h index b05f225337ef0..dbec33e21cbe4 100644 --- a/unified-runtime/include/ur_ddi.h +++ b/unified-runtime/include/ur_ddi.h @@ -23,6 +23,43 @@ extern "C" { #endif +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urAdapterSetLoggerCallback +typedef ur_result_t(UR_APICALL *ur_pfnAdapterSetLoggerCallback_t)( + ur_adapter_handle_t, ur_logger_callback_t, void *, ur_logger_level_t); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urAdapterSetLoggerCallbackLevel +typedef ur_result_t(UR_APICALL *ur_pfnAdapterSetLoggerCallbackLevel_t)( + ur_adapter_handle_t, ur_logger_level_t); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Table of Adapter functions pointers +typedef struct ur_adapter_dditable_t { + ur_pfnAdapterSetLoggerCallback_t pfnSetLoggerCallback; + ur_pfnAdapterSetLoggerCallbackLevel_t pfnSetLoggerCallbackLevel; +} ur_adapter_dditable_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's Adapter table +/// with current process' addresses +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::UR_RESULT_ERROR_UNSUPPORTED_VERSION +UR_DLLEXPORT ur_result_t UR_APICALL urGetAdapterProcAddrTable( + /// [in] API version requested + ur_api_version_t version, + /// [in,out] pointer to table of DDI function pointers + ur_adapter_dditable_t *pDdiTable); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urGetAdapterProcAddrTable +typedef ur_result_t(UR_APICALL *ur_pfnGetAdapterProcAddrTable_t)( + ur_api_version_t, ur_adapter_dditable_t *); + /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urPlatformGet typedef ur_result_t(UR_APICALL *ur_pfnPlatformGet_t)(ur_adapter_handle_t, @@ -1966,6 +2003,7 @@ typedef ur_result_t(UR_APICALL *ur_pfnGetDeviceProcAddrTable_t)( /////////////////////////////////////////////////////////////////////////////// /// @brief Container for all DDI tables typedef struct ur_dditable_t { + ur_adapter_dditable_t Adapter; ur_platform_dditable_t Platform; ur_context_dditable_t Context; ur_event_dditable_t Event; diff --git a/unified-runtime/include/ur_print.h b/unified-runtime/include/ur_print.h index 1a133ef4fcde4..533a8b3afeaa8 100644 --- a/unified-runtime/include/ur_print.h +++ b/unified-runtime/include/ur_print.h @@ -142,6 +142,16 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintAdapterBackend(enum ur_adapter_backend_t value, char *buffer, const size_t buff_size, size_t *out_size); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_logger_level_t enum +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL +urPrintLoggerLevel(enum ur_logger_level_t value, char *buffer, + const size_t buff_size, size_t *out_size); + /////////////////////////////////////////////////////////////////////////////// /// @brief Print ur_platform_info_t enum /// @returns @@ -1505,6 +1515,26 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintLoaderConfigSetMockingEnabledParams( const struct ur_loader_config_set_mocking_enabled_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_adapter_set_logger_callback_params_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL urPrintAdapterSetLoggerCallbackParams( + const struct ur_adapter_set_logger_callback_params_t *params, char *buffer, + const size_t buff_size, size_t *out_size); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_adapter_set_logger_callback_level_params_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL urPrintAdapterSetLoggerCallbackLevelParams( + const struct ur_adapter_set_logger_callback_level_params_t *params, + char *buffer, const size_t buff_size, size_t *out_size); + /////////////////////////////////////////////////////////////////////////////// /// @brief Print ur_platform_get_params_t struct /// @returns diff --git a/unified-runtime/include/ur_print.hpp b/unified-runtime/include/ur_print.hpp index 3ba8e1a36496f..c5333f76f478e 100644 --- a/unified-runtime/include/ur_print.hpp +++ b/unified-runtime/include/ur_print.hpp @@ -295,6 +295,7 @@ operator<<(std::ostream &os, inline std::ostream &operator<<(std::ostream &os, enum ur_adapter_info_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_adapter_backend_t value); +inline std::ostream &operator<<(std::ostream &os, enum ur_logger_level_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_platform_info_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_api_version_t value); @@ -1237,6 +1238,12 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_function_t value) { case UR_FUNCTION_USM_POOL_SET_INFO_EXP: os << "UR_FUNCTION_USM_POOL_SET_INFO_EXP"; break; + case UR_FUNCTION_ADAPTER_SET_LOGGER_CALLBACK: + os << "UR_FUNCTION_ADAPTER_SET_LOGGER_CALLBACK"; + break; + case UR_FUNCTION_ADAPTER_SET_LOGGER_CALLBACK_LEVEL: + os << "UR_FUNCTION_ADAPTER_SET_LOGGER_CALLBACK_LEVEL"; + break; default: os << "unknown enumerator"; break; @@ -2356,6 +2363,34 @@ inline std::ostream &operator<<(std::ostream &os, return os; } /////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_logger_level_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<(std::ostream &os, + enum ur_logger_level_t value) { + switch (value) { + case UR_LOGGER_LEVEL_DEBUG: + os << "UR_LOGGER_LEVEL_DEBUG"; + break; + case UR_LOGGER_LEVEL_INFO: + os << "UR_LOGGER_LEVEL_INFO"; + break; + case UR_LOGGER_LEVEL_WARN: + os << "UR_LOGGER_LEVEL_WARN"; + break; + case UR_LOGGER_LEVEL_ERROR: + os << "UR_LOGGER_LEVEL_ERROR"; + break; + case UR_LOGGER_LEVEL_QUIET: + os << "UR_LOGGER_LEVEL_QUIET"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} +/////////////////////////////////////////////////////////////////////////////// /// @brief Print operator for the ur_platform_info_t type /// @returns /// std::ostream & @@ -12375,6 +12410,59 @@ inline std::ostream &operator<<( return os; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_adapter_set_logger_callback_params_t type +/// @returns +/// std::ostream & +inline std::ostream & +operator<<(std::ostream &os, + [[maybe_unused]] const struct ur_adapter_set_logger_callback_params_t + *params) { + + os << ".hAdapter = "; + + ur::details::printPtr(os, *(params->phAdapter)); + + os << ", "; + os << ".pfnLoggerCallback = "; + + os << reinterpret_cast(*(params->ppfnLoggerCallback)); + + os << ", "; + os << ".pUserData = "; + + ur::details::printPtr(os, *(params->ppUserData)); + + os << ", "; + os << ".level = "; + + os << *(params->plevel); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_adapter_set_logger_callback_level_params_t +/// type +/// @returns +/// std::ostream & +inline std::ostream &operator<<( + std::ostream &os, + [[maybe_unused]] const struct ur_adapter_set_logger_callback_level_params_t + *params) { + + os << ".hAdapter = "; + + ur::details::printPtr(os, *(params->phAdapter)); + + os << ", "; + os << ".level = "; + + os << *(params->plevel); + + return os; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Print operator for the ur_platform_get_params_t type /// @returns @@ -20658,6 +20746,12 @@ inline ur_result_t UR_APICALL printFunctionParams(std::ostream &os, case UR_FUNCTION_LOADER_CONFIG_SET_MOCKING_ENABLED: { os << (const struct ur_loader_config_set_mocking_enabled_params_t *)params; } break; + case UR_FUNCTION_ADAPTER_SET_LOGGER_CALLBACK: { + os << (const struct ur_adapter_set_logger_callback_params_t *)params; + } break; + case UR_FUNCTION_ADAPTER_SET_LOGGER_CALLBACK_LEVEL: { + os << (const struct ur_adapter_set_logger_callback_level_params_t *)params; + } break; case UR_FUNCTION_PLATFORM_GET: { os << (const struct ur_platform_get_params_t *)params; } break; diff --git a/unified-runtime/scripts/core/INTRO.rst b/unified-runtime/scripts/core/INTRO.rst index 6939c70755e91..e95bdf8944404 100644 --- a/unified-runtime/scripts/core/INTRO.rst +++ b/unified-runtime/scripts/core/INTRO.rst @@ -202,9 +202,9 @@ By default, no messages are printed. By default, there is a guarantee that *error* messages are flushed immediately. One can change this behavior to flush on lower-level messages. -Loggers redirect messages to *stdout*, *stderr*, or a file (default: *stderr*). +Loggers redirect messages to *stdout*, *stderr*, a file, or a user configurable callback function (default: *stderr*). -All of these logging options can be set with **UR_LOG_LOADER** and **UR_LOG_NULL** environment variables described in the **Environment Variables** section below. +All of these logging options (except the callback) can be set with **UR_LOG_LOADER** and **UR_LOG_NULL** environment variables described in the **Environment Variables** section below. Both of these environment variables have the same syntax for setting logger options: "[level:debug|info|warning|error];[flush:];[output:stdout|stderr|file,]" @@ -232,6 +232,10 @@ An example of an environment variable for setting up the null adapter library wi UR_LOG_NULL="level:warning;output:stdout" +Logging callback +^^^^^^^^^^^^^^^^^^^^^ +An API is available to configure the logging callback function :ref:`urAdapterSetLoggerCallback`. Additionally, the logging level can be set using :ref:`urAdapterSetLoggerCallbackLevel`. + Adapter Discovery --------------------- UR is capable of discovering adapter libraries in the following ways in the listed order: diff --git a/unified-runtime/scripts/core/adapter.yml b/unified-runtime/scripts/core/adapter.yml index d8df466f1a55f..76cf8004c104c 100644 --- a/unified-runtime/scripts/core/adapter.yml +++ b/unified-runtime/scripts/core/adapter.yml @@ -206,3 +206,76 @@ etors: - name: NATIVE_CPU value: "5" desc: "The backend is Native CPU" +--- #-------------------------------------------------------------------------- +type: enum +desc: "Minimum level of messages to be processed by the logger." +class: $xAdapter +name: $x_logger_level_t +etors: + - name: DEBUG + value: "0" + desc: "Debugging messages used for development purposes." + - name: INFO + value: "1" + desc: "General messages not related to debugging, warnings or errors." + - name: WARN + value: "2" + desc: "Used to warn users about potential problems." + - name: ERROR + value: "3" + desc: "Used when an error has occurred." + - name: QUIET + value: "4" + desc: "Restrict logger processing any messages." +--- #-------------------------------------------------------------------------- +type: fptr_typedef +desc: "Callback function to retrieve output from the logger." +name: $x_logger_callback_t +return: "void" +params: + - type: $x_logger_level_t + name: level + desc: "[out] Minimum level of messages to be processed by the logger." + init: DEBUG + - type: const char* + name: pLoggerMsg + desc: "[in][out] pointer to data to be passed to callback" + - type: void* + name: pUserData + desc: "[in][out] pointer to data to be passed to callback" +--- #-------------------------------------------------------------------------- +type: function +desc: | + Set a callback function for use by the logger to retrieve logging output. + It is a requirement that the callback function is thread safe and the + creator of the function will be responsible for this. +class: $xAdapter +name: SetLoggerCallback +decl: static +params: + - type: $x_adapter_handle_t + name: hAdapter + desc: "[in] handle of the adapter" + - type: $x_logger_callback_t + name: pfnLoggerCallback + desc: "[in] Function pointer to callback from the logger." + - type: void* + name: pUserData + desc: "[in][out][optional] pointer to data to be passed to callback" + - type: $x_logger_level_t + name: level + desc: "[in] logging level" + init: 0 +--- #-------------------------------------------------------------------------- +type: function +desc: "Set the minimum logging level for the logger Callback function." +class: $xAdapter +name: SetLoggerCallbackLevel +decl: static +params: + - type: $x_adapter_handle_t + name: hAdapter + desc: "[in] handle of the adapter" + - type: $x_logger_level_t + name: level + desc: "[in] logging level" diff --git a/unified-runtime/scripts/core/registry.yml b/unified-runtime/scripts/core/registry.yml index 6eb982753bfeb..f2e4e1f251e67 100644 --- a/unified-runtime/scripts/core/registry.yml +++ b/unified-runtime/scripts/core/registry.yml @@ -643,6 +643,12 @@ etors: - name: USM_POOL_SET_INFO_EXP desc: Enumerator for $xUSMPoolSetInfoExp value: '265' +- name: ADAPTER_SET_LOGGER_CALLBACK + desc: Enumerator for $xAdapterSetLoggerCallback + value: '266' +- name: ADAPTER_SET_LOGGER_CALLBACK_LEVEL + desc: Enumerator for $xAdapterSetLoggerCallbackLevel + value: '267' --- type: enum desc: Defines structure types diff --git a/unified-runtime/scripts/templates/trcddi.cpp.mako b/unified-runtime/scripts/templates/trcddi.cpp.mako index c391c335a4edf..ca910bfa32e70 100644 --- a/unified-runtime/scripts/templates/trcddi.cpp.mako +++ b/unified-runtime/scripts/templates/trcddi.cpp.mako @@ -54,7 +54,7 @@ namespace ur_tracing_layer getContext()->notify_end(${th.make_func_etor(n, tags, obj)}, "${th.make_func_name(n, tags, obj)}", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, ${th.make_func_etor(n, tags, obj)}, ¶ms); logger.info(" <--- ${th.make_func_name(n, tags, obj)}({}) -> {};\n", args_str.str(), result); diff --git a/unified-runtime/source/adapters/adapter.def.in b/unified-runtime/source/adapters/adapter.def.in index 3c18c78bd180e..944952685791c 100644 --- a/unified-runtime/source/adapters/adapter.def.in +++ b/unified-runtime/source/adapters/adapter.def.in @@ -1,6 +1,7 @@ LIBRARY @TARGET_LIBNAME@ EXPORTS urGetGlobalProcAddrTable + urGetAdapterProcAddrTable urGetBindlessImagesExpProcAddrTable urGetCommandBufferExpProcAddrTable urGetContextProcAddrTable diff --git a/unified-runtime/source/adapters/adapter.map.in b/unified-runtime/source/adapters/adapter.map.in index bb08ae7d88a48..5fe52a579de11 100644 --- a/unified-runtime/source/adapters/adapter.map.in +++ b/unified-runtime/source/adapters/adapter.map.in @@ -1,6 +1,7 @@ @TARGET_LIBNAME@ { global: urGetGlobalProcAddrTable; + urGetAdapterProcAddrTable; urGetBindlessImagesExpProcAddrTable; urGetCommandBufferExpProcAddrTable; urGetContextProcAddrTable; diff --git a/unified-runtime/source/adapters/cuda/adapter.cpp b/unified-runtime/source/adapters/cuda/adapter.cpp index 4bc622d438323..33ee220f252b9 100644 --- a/unified-runtime/source/adapters/cuda/adapter.cpp +++ b/unified-runtime/source/adapters/cuda/adapter.cpp @@ -26,7 +26,7 @@ class ur_legacy_sink : public logger::Sink { this->ostream = &std::cerr; } - virtual void print([[maybe_unused]] logger::Level level, + virtual void print([[maybe_unused]] ur_logger_level_t level, const std::string &msg) override { std::cerr << msg << std::endl; } @@ -39,7 +39,7 @@ class ur_legacy_sink : public logger::Sink { // https://github.com/oneapi-src/unified-runtime/issues/1330 ur_adapter_handle_t_::ur_adapter_handle_t_() : logger(logger::get_logger("cuda", - /*default_log_level*/ logger::Level::ERR)) { + /*default_log_level*/ UR_LOGGER_LEVEL_ERROR)) { Platform = std::make_unique(); if (std::getenv("UR_LOG_CUDA") == nullptr && @@ -116,3 +116,21 @@ UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetInfo(ur_adapter_handle_t, return UR_RESULT_SUCCESS; } + +UR_APIEXPORT ur_result_t UR_APICALL urAdapterSetLoggerCallback( + ur_adapter_handle_t, ur_logger_callback_t pfnLoggerCallback, + void *pUserData, ur_logger_level_t level = UR_LOGGER_LEVEL_QUIET) { + + ur::cuda::adapter->logger.setCallbackSink(pfnLoggerCallback, pUserData, + level); + + return UR_RESULT_SUCCESS; +} + +UR_APIEXPORT ur_result_t UR_APICALL urAdapterSetLoggerCallbackLevel( + ur_adapter_handle_t, ur_logger_level_t level = UR_LOGGER_LEVEL_QUIET) { + + ur::cuda::adapter->logger.setCallbackLevel(level); + + return UR_RESULT_SUCCESS; +} diff --git a/unified-runtime/source/adapters/cuda/enqueue.cpp b/unified-runtime/source/adapters/cuda/enqueue.cpp index e48a1e5ea15f7..9cca40c7ce094 100644 --- a/unified-runtime/source/adapters/cuda/enqueue.cpp +++ b/unified-runtime/source/adapters/cuda/enqueue.cpp @@ -97,10 +97,9 @@ ur_result_t setCuMemAdvise(CUdeviceptr DevPtr, size_t Size, for (auto &UnmappedFlag : UnmappedMemAdviceFlags) { if (URAdviceFlags & UnmappedFlag) { - setErrorMessage("Memory advice ignored because the CUDA backend does not " - "support some of the specified flags", - UR_RESULT_SUCCESS); - return UR_RESULT_ERROR_ADAPTER_SPECIFIC; + logger::warning("Memory advice ignored because the CUDA backend does not " + "support some of the specified flags."); + return UR_RESULT_SUCCESS; } } @@ -1613,19 +1612,17 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMPrefetch( // for managed memory. Therefore, ignore prefetch hint if concurrent managed // memory access is not available. if (!getAttribute(Device, CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS)) { - setErrorMessage("Prefetch hint ignored as device does not support " - "concurrent managed access", - UR_RESULT_SUCCESS); - return UR_RESULT_ERROR_ADAPTER_SPECIFIC; + logger::warning("Prefetch hint ignored as device does not support " + "concurrent managed access."); + return UR_RESULT_SUCCESS; } unsigned int IsManaged; UR_CHECK_ERROR(cuPointerGetAttribute( &IsManaged, CU_POINTER_ATTRIBUTE_IS_MANAGED, (CUdeviceptr)pMem)); if (!IsManaged) { - setErrorMessage("Prefetch hint ignored as prefetch only works with USM", - UR_RESULT_SUCCESS); - return UR_RESULT_ERROR_ADAPTER_SPECIFIC; + logger::warning("Prefetch hint ignored as prefetch only works with USM."); + return UR_RESULT_SUCCESS; } ur_result_t Result = UR_RESULT_SUCCESS; @@ -1675,10 +1672,9 @@ urEnqueueUSMAdvise(ur_queue_handle_t hQueue, const void *pMem, size_t size, (advice & UR_USM_ADVICE_FLAG_DEFAULT)) { ur_device_handle_t Device = hQueue->getDevice(); if (!getAttribute(Device, CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS)) { - setErrorMessage("Mem advise ignored as device does not support " - "concurrent managed access", - UR_RESULT_SUCCESS); - return UR_RESULT_ERROR_ADAPTER_SPECIFIC; + logger::warning("Mem advise ignored as device does not support " + "concurrent managed access."); + return UR_RESULT_SUCCESS; } // TODO: If ptr points to valid system-allocated pageable memory we should diff --git a/unified-runtime/source/adapters/cuda/kernel.cpp b/unified-runtime/source/adapters/cuda/kernel.cpp index e2e03737feed2..eb927374655f5 100644 --- a/unified-runtime/source/adapters/cuda/kernel.cpp +++ b/unified-runtime/source/adapters/cuda/kernel.cpp @@ -397,7 +397,7 @@ urKernelSetArgMemObj(ur_kernel_handle_t hKernel, uint32_t argIndex, arrayDesc.Format != CU_AD_FORMAT_SIGNED_INT32 && arrayDesc.Format != CU_AD_FORMAT_HALF && arrayDesc.Format != CU_AD_FORMAT_FLOAT) { - setErrorMessage("PI CUDA kernels only support images with channel " + setErrorMessage("UR CUDA kernels only support images with channel " "types int32, uint32, float, and half.", UR_RESULT_ERROR_ADAPTER_SPECIFIC); return UR_RESULT_ERROR_ADAPTER_SPECIFIC; diff --git a/unified-runtime/source/adapters/cuda/ur_interface_loader.cpp b/unified-runtime/source/adapters/cuda/ur_interface_loader.cpp index 16f2875102de1..32efb2a10aad6 100644 --- a/unified-runtime/source/adapters/cuda/ur_interface_loader.cpp +++ b/unified-runtime/source/adapters/cuda/ur_interface_loader.cpp @@ -460,6 +460,18 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramExpProcAddrTable( return UR_RESULT_SUCCESS; } +UR_DLLEXPORT ur_result_t UR_APICALL urGetAdapterProcAddrTable( + ur_api_version_t version, ur_adapter_dditable_t *pDdiTable) { + auto result = validateProcInputs(version, pDdiTable); + if (UR_RESULT_SUCCESS != result) { + return result; + } + pDdiTable->pfnSetLoggerCallback = urAdapterSetLoggerCallback; + pDdiTable->pfnSetLoggerCallbackLevel = urAdapterSetLoggerCallbackLevel; + + return UR_RESULT_SUCCESS; +} + #if defined(__cplusplus) } // extern "C" #endif diff --git a/unified-runtime/source/adapters/hip/adapter.cpp b/unified-runtime/source/adapters/hip/adapter.cpp index 414fed4734f6b..180510bc2826e 100644 --- a/unified-runtime/source/adapters/hip/adapter.cpp +++ b/unified-runtime/source/adapters/hip/adapter.cpp @@ -26,7 +26,7 @@ class ur_legacy_sink : public logger::Sink { this->ostream = &std::cerr; } - virtual void print([[maybe_unused]] logger::Level level, + virtual void print([[maybe_unused]] ur_logger_level_t level, const std::string &msg) override { std::cerr << msg << std::endl; } @@ -38,8 +38,8 @@ class ur_legacy_sink : public logger::Sink { // through UR entry points. // https://github.com/oneapi-src/unified-runtime/issues/1330 ur_adapter_handle_t_::ur_adapter_handle_t_() - : logger( - logger::get_logger("hip", /*default_log_level*/ logger::Level::ERR)) { + : logger(logger::get_logger("hip", + /*default_log_level*/ UR_LOGGER_LEVEL_ERROR)) { Platform = std::make_unique(); if (std::getenv("UR_LOG_HIP") != nullptr) return; @@ -107,3 +107,20 @@ UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetInfo(ur_adapter_handle_t, return UR_RESULT_SUCCESS; } + +UR_APIEXPORT ur_result_t UR_APICALL urAdapterSetLoggerCallback( + ur_adapter_handle_t, ur_logger_callback_t pfnLoggerCallback, + void *pUserData, ur_logger_level_t level = UR_LOGGER_LEVEL_QUIET) { + + ur::hip::adapter->logger.setCallbackSink(pfnLoggerCallback, pUserData, level); + + return UR_RESULT_SUCCESS; +} + +UR_APIEXPORT ur_result_t UR_APICALL +urAdapterSetLoggerCallbackLevel(ur_adapter_handle_t, ur_logger_level_t level) { + + ur::hip::adapter->logger.setCallbackLevel(level); + + return UR_RESULT_SUCCESS; +} diff --git a/unified-runtime/source/adapters/hip/enqueue.cpp b/unified-runtime/source/adapters/hip/enqueue.cpp index 849369de4bb90..caa7306c31690 100644 --- a/unified-runtime/source/adapters/hip/enqueue.cpp +++ b/unified-runtime/source/adapters/hip/enqueue.cpp @@ -13,6 +13,7 @@ #include "context.hpp" #include "event.hpp" #include "kernel.hpp" +#include "logger/ur_logger.hpp" #include "memory.hpp" #include "queue.hpp" #include "ur_api.h" @@ -1407,10 +1408,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMPrefetch( // mem_advise. if (!Device->getManagedMemSupport()) { releaseEvent(); - setErrorMessage("mem_advise ignored as device does not support " - "managed memory access", - UR_RESULT_SUCCESS); - return UR_RESULT_ERROR_ADAPTER_SPECIFIC; + logger::warning("mem_advise ignored as device does not support " + "managed memory access."); + return UR_RESULT_SUCCESS; } hipPointerAttribute_t attribs; @@ -1423,9 +1423,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMPrefetch( // async prefetch requires USM pointer (or hip SVM) to work. if (!attribs.isManaged) { releaseEvent(); - setErrorMessage("Prefetch hint ignored as prefetch only works with USM", - UR_RESULT_SUCCESS); - return UR_RESULT_ERROR_ADAPTER_SPECIFIC; + logger::warning("Prefetch hint ignored as prefetch only works with USM."); + return UR_RESULT_SUCCESS; } UR_CHECK_ERROR( @@ -1480,10 +1479,9 @@ urEnqueueUSMAdvise(ur_queue_handle_t hQueue, const void *pMem, size_t size, // mem_advise. if (!Device->getManagedMemSupport()) { releaseEvent(); - setErrorMessage("mem_advise ignored as device does not support " - "managed memory access", - UR_RESULT_SUCCESS); - return UR_RESULT_ERROR_ADAPTER_SPECIFIC; + logger::warning("mem_advise ignored as device does not support " + "managed memory access."); + return UR_RESULT_SUCCESS; } // Passing MEM_ADVICE_SET/MEM_ADVICE_CLEAR_PREFERRED_LOCATION to @@ -1498,10 +1496,9 @@ urEnqueueUSMAdvise(ur_queue_handle_t hQueue, const void *pMem, size_t size, UR_USM_ADVICE_FLAG_DEFAULT)) { if (!Device->getConcurrentManagedAccess()) { releaseEvent(); - setErrorMessage("mem_advise ignored as device does not support " - "concurrent managed access", - UR_RESULT_SUCCESS); - return UR_RESULT_ERROR_ADAPTER_SPECIFIC; + logger::warning("mem_advise ignored as device does not support " + "concurrent memory access."); + return UR_RESULT_SUCCESS; } // TODO: If pMem points to valid system-allocated pageable memory, we @@ -1519,10 +1516,9 @@ urEnqueueUSMAdvise(ur_queue_handle_t hQueue, const void *pMem, size_t size, if (auto ptrAttribs = getPointerAttributes(pMem); !ptrAttribs || !ptrAttribs->isManaged) { releaseEvent(); - setErrorMessage("mem_advise is ignored as the pointer argument is not " - "a shared USM pointer", - UR_RESULT_SUCCESS); - return UR_RESULT_ERROR_ADAPTER_SPECIFIC; + logger::warning("mem_advise is ignored as the pointer argument is not " + "a shared USM pointer."); + return UR_RESULT_SUCCESS; } const auto DeviceID = Device->get(); @@ -1549,10 +1545,9 @@ urEnqueueUSMAdvise(ur_queue_handle_t hQueue, const void *pMem, size_t size, // the runtime. if (Result == UR_RESULT_ERROR_INVALID_ENUMERATION) { releaseEvent(); - setErrorMessage("mem_advise is ignored as the advice argument is not " - "supported by this device", - UR_RESULT_SUCCESS); - return UR_RESULT_ERROR_ADAPTER_SPECIFIC; + logger::warning("mem_advise is ignored as the advice argument is not " + "supported by this device."); + return UR_RESULT_SUCCESS; } UR_CHECK_ERROR(Result); } diff --git a/unified-runtime/source/adapters/hip/ur_interface_loader.cpp b/unified-runtime/source/adapters/hip/ur_interface_loader.cpp index d360c5c11bb1e..b7df579c68ece 100644 --- a/unified-runtime/source/adapters/hip/ur_interface_loader.cpp +++ b/unified-runtime/source/adapters/hip/ur_interface_loader.cpp @@ -452,6 +452,18 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramExpProcAddrTable( return UR_RESULT_SUCCESS; } +UR_DLLEXPORT ur_result_t UR_APICALL urGetAdapterProcAddrTable( + ur_api_version_t version, ur_adapter_dditable_t *pDdiTable) { + auto result = validateProcInputs(version, pDdiTable); + if (UR_RESULT_SUCCESS != result) { + return result; + } + pDdiTable->pfnSetLoggerCallback = urAdapterSetLoggerCallback; + pDdiTable->pfnSetLoggerCallbackLevel = urAdapterSetLoggerCallbackLevel; + + return UR_RESULT_SUCCESS; +} + #if defined(__cplusplus) } // extern "C" #endif diff --git a/unified-runtime/source/adapters/level_zero/adapter.cpp b/unified-runtime/source/adapters/level_zero/adapter.cpp index 4339aed2a2299..2de540e879efb 100644 --- a/unified-runtime/source/adapters/level_zero/adapter.cpp +++ b/unified-runtime/source/adapters/level_zero/adapter.cpp @@ -41,7 +41,7 @@ class ur_legacy_sink : public logger::Sink { this->ostream = &std::cerr; } - virtual void print([[maybe_unused]] logger::Level level, + virtual void print([[maybe_unused]] ur_logger_level_t level, const std::string &msg) override { fprintf(stderr, "%s", msg.c_str()); } @@ -739,4 +739,26 @@ ur_result_t urAdapterGetInfo(ur_adapter_handle_t, ur_adapter_info_t PropName, return UR_RESULT_SUCCESS; } + +UR_APIEXPORT ur_result_t UR_APICALL urAdapterSetLoggerCallback( + ur_adapter_handle_t, ur_logger_callback_t pfnLoggerCallback, + void *pUserData, ur_logger_level_t level = UR_LOGGER_LEVEL_QUIET) { + + if (GlobalAdapter) { + GlobalAdapter->logger.setCallbackSink(pfnLoggerCallback, pUserData, level); + } + + return UR_RESULT_SUCCESS; +} + +UR_APIEXPORT ur_result_t UR_APICALL +urAdapterSetLoggerCallbackLevel(ur_adapter_handle_t, ur_logger_level_t level) { + + if (GlobalAdapter) { + GlobalAdapter->logger.setCallbackLevel(level); + } + + return UR_RESULT_SUCCESS; +} + } // namespace ur::level_zero diff --git a/unified-runtime/source/adapters/level_zero/ur_interface_loader.cpp b/unified-runtime/source/adapters/level_zero/ur_interface_loader.cpp index ede76fa63baf8..28a1301d7254f 100644 --- a/unified-runtime/source/adapters/level_zero/ur_interface_loader.cpp +++ b/unified-runtime/source/adapters/level_zero/ur_interface_loader.cpp @@ -48,6 +48,20 @@ UR_APIEXPORT ur_result_t UR_APICALL urGetGlobalProcAddrTable( return result; } +UR_APIEXPORT ur_result_t UR_APICALL urGetAdapterProcAddrTable( + ur_api_version_t version, ur_adapter_dditable_t *pDdiTable) { + auto result = validateProcInputs(version, pDdiTable); + if (UR_RESULT_SUCCESS != result) { + return result; + } + + pDdiTable->pfnSetLoggerCallback = ur::level_zero::urAdapterSetLoggerCallback; + pDdiTable->pfnSetLoggerCallbackLevel = + ur::level_zero::urAdapterSetLoggerCallbackLevel; + + return result; +} + UR_APIEXPORT ur_result_t UR_APICALL urGetBindlessImagesExpProcAddrTable( ur_api_version_t version, ur_bindless_images_exp_dditable_t *pDdiTable) { auto result = validateProcInputs(version, pDdiTable); @@ -549,6 +563,10 @@ ur_result_t urAdapterGetDdiTables(ur_dditable_t *ddi) { &ddi->Global); if (result != UR_RESULT_SUCCESS) return result; + result = ur::level_zero::urGetAdapterProcAddrTable(UR_API_VERSION_CURRENT, + &ddi->Adapter); + if (result != UR_RESULT_SUCCESS) + return result; result = ur::level_zero::urGetBindlessImagesExpProcAddrTable( UR_API_VERSION_CURRENT, &ddi->BindlessImagesExp); if (result != UR_RESULT_SUCCESS) diff --git a/unified-runtime/source/adapters/level_zero/ur_interface_loader.hpp b/unified-runtime/source/adapters/level_zero/ur_interface_loader.hpp index 216f79f4afbf3..7174fba5757fc 100644 --- a/unified-runtime/source/adapters/level_zero/ur_interface_loader.hpp +++ b/unified-runtime/source/adapters/level_zero/ur_interface_loader.hpp @@ -21,6 +21,12 @@ ur_result_t urAdapterGetLastError(ur_adapter_handle_t hAdapter, ur_result_t urAdapterGetInfo(ur_adapter_handle_t hAdapter, ur_adapter_info_t propName, size_t propSize, void *pPropValue, size_t *pPropSizeRet); +ur_result_t urAdapterSetLoggerCallback(ur_adapter_handle_t hAdapter, + ur_logger_callback_t pfnLoggerCallback, + void *pUserData, + ur_logger_level_t level); +ur_result_t urAdapterSetLoggerCallbackLevel(ur_adapter_handle_t hAdapter, + ur_logger_level_t level); ur_result_t urPlatformGet(ur_adapter_handle_t hAdapter, uint32_t NumEntries, ur_platform_handle_t *phPlatforms, uint32_t *pNumPlatforms); diff --git a/unified-runtime/source/adapters/mock/ur_mockddi.cpp b/unified-runtime/source/adapters/mock/ur_mockddi.cpp index 9632ce986701a..03ee006d1da8b 100644 --- a/unified-runtime/source/adapters/mock/ur_mockddi.cpp +++ b/unified-runtime/source/adapters/mock/ur_mockddi.cpp @@ -261,6 +261,102 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGetInfo( return exceptionToResult(std::current_exception()); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterSetLoggerCallback +__urdlllocal ur_result_t UR_APICALL urAdapterSetLoggerCallback( + /// [in] handle of the adapter + ur_adapter_handle_t hAdapter, + /// [in] Function pointer to callback from the logger. + ur_logger_callback_t pfnLoggerCallback, + /// [in][out][optional] pointer to data to be passed to callback + void *pUserData, + /// [in] logging level + ur_logger_level_t level) try { + ur_result_t result = UR_RESULT_SUCCESS; + + ur_adapter_set_logger_callback_params_t params = { + &hAdapter, &pfnLoggerCallback, &pUserData, &level}; + + auto beforeCallback = reinterpret_cast( + mock::getCallbacks().get_before_callback("urAdapterSetLoggerCallback")); + if (beforeCallback) { + result = beforeCallback(¶ms); + if (result != UR_RESULT_SUCCESS) { + return result; + } + } + + auto replaceCallback = reinterpret_cast( + mock::getCallbacks().get_replace_callback("urAdapterSetLoggerCallback")); + if (replaceCallback) { + result = replaceCallback(¶ms); + } else { + + result = UR_RESULT_SUCCESS; + } + + if (result != UR_RESULT_SUCCESS) { + return result; + } + + auto afterCallback = reinterpret_cast( + mock::getCallbacks().get_after_callback("urAdapterSetLoggerCallback")); + if (afterCallback) { + return afterCallback(¶ms); + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterSetLoggerCallbackLevel +__urdlllocal ur_result_t UR_APICALL urAdapterSetLoggerCallbackLevel( + /// [in] handle of the adapter + ur_adapter_handle_t hAdapter, + /// [in] logging level + ur_logger_level_t level) try { + ur_result_t result = UR_RESULT_SUCCESS; + + ur_adapter_set_logger_callback_level_params_t params = {&hAdapter, &level}; + + auto beforeCallback = reinterpret_cast( + mock::getCallbacks().get_before_callback( + "urAdapterSetLoggerCallbackLevel")); + if (beforeCallback) { + result = beforeCallback(¶ms); + if (result != UR_RESULT_SUCCESS) { + return result; + } + } + + auto replaceCallback = reinterpret_cast( + mock::getCallbacks().get_replace_callback( + "urAdapterSetLoggerCallbackLevel")); + if (replaceCallback) { + result = replaceCallback(¶ms); + } else { + + result = UR_RESULT_SUCCESS; + } + + if (result != UR_RESULT_SUCCESS) { + return result; + } + + auto afterCallback = reinterpret_cast( + mock::getCallbacks().get_after_callback( + "urAdapterSetLoggerCallbackLevel")); + if (afterCallback) { + return afterCallback(¶ms); + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urPlatformGet __urdlllocal ur_result_t UR_APICALL urPlatformGet( @@ -11682,6 +11778,37 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGlobalProcAddrTable( return exceptionToResult(std::current_exception()); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's Adapter table +/// with current process' addresses +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::UR_RESULT_ERROR_UNSUPPORTED_VERSION +UR_DLLEXPORT ur_result_t UR_APICALL urGetAdapterProcAddrTable( + /// [in] API version requested + ur_api_version_t version, + /// [in,out] pointer to table of DDI function pointers + ur_adapter_dditable_t *pDdiTable) try { + if (nullptr == pDdiTable) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (driver::d_context.version < version) + return UR_RESULT_ERROR_UNSUPPORTED_VERSION; + + ur_result_t result = UR_RESULT_SUCCESS; + + pDdiTable->pfnSetLoggerCallback = driver::urAdapterSetLoggerCallback; + + pDdiTable->pfnSetLoggerCallbackLevel = + driver::urAdapterSetLoggerCallbackLevel; + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's BindlessImagesExp table /// with current process' addresses diff --git a/unified-runtime/source/adapters/native_cpu/adapter.cpp b/unified-runtime/source/adapters/native_cpu/adapter.cpp index 1af605286ed22..9d2f780c95438 100644 --- a/unified-runtime/source/adapters/native_cpu/adapter.cpp +++ b/unified-runtime/source/adapters/native_cpu/adapter.cpp @@ -66,3 +66,20 @@ UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetInfo(ur_adapter_handle_t, return UR_RESULT_SUCCESS; } + +UR_APIEXPORT ur_result_t UR_APICALL urAdapterSetLoggerCallback( + ur_adapter_handle_t, ur_logger_callback_t pfnLoggerCallback, + void *pUserData, ur_logger_level_t level = UR_LOGGER_LEVEL_QUIET) { + + Adapter.logger.setCallbackSink(pfnLoggerCallback, pUserData, level); + + return UR_RESULT_SUCCESS; +} + +UR_APIEXPORT ur_result_t UR_APICALL +urAdapterSetLoggerCallbackLevel(ur_adapter_handle_t, ur_logger_level_t level) { + + Adapter.logger.setCallbackLevel(level); + + return UR_RESULT_SUCCESS; +} diff --git a/unified-runtime/source/adapters/native_cpu/ur_interface_loader.cpp b/unified-runtime/source/adapters/native_cpu/ur_interface_loader.cpp index ca158f82ee07b..8543428b4f314 100644 --- a/unified-runtime/source/adapters/native_cpu/ur_interface_loader.cpp +++ b/unified-runtime/source/adapters/native_cpu/ur_interface_loader.cpp @@ -432,4 +432,17 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramExpProcAddrTable( return UR_RESULT_SUCCESS; } + +UR_DLLEXPORT ur_result_t UR_APICALL urGetAdapterProcAddrTable( + ur_api_version_t version, ur_adapter_dditable_t *pDdiTable) { + auto result = validateProcInputs(version, pDdiTable); + if (UR_RESULT_SUCCESS != result) { + return result; + } + pDdiTable->pfnSetLoggerCallback = urAdapterSetLoggerCallback; + pDdiTable->pfnSetLoggerCallbackLevel = urAdapterSetLoggerCallbackLevel; + + return UR_RESULT_SUCCESS; +} + } // extern "C" diff --git a/unified-runtime/source/adapters/opencl/adapter.cpp b/unified-runtime/source/adapters/opencl/adapter.cpp index 365723f14e977..0fb1453d23a21 100644 --- a/unified-runtime/source/adapters/opencl/adapter.cpp +++ b/unified-runtime/source/adapters/opencl/adapter.cpp @@ -137,3 +137,24 @@ UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetInfo(ur_adapter_handle_t, return UR_RESULT_SUCCESS; } + +UR_APIEXPORT ur_result_t UR_APICALL urAdapterSetLoggerCallback( + ur_adapter_handle_t, ur_logger_callback_t pfnLoggerCallback, + void *pUserData, ur_logger_level_t level = UR_LOGGER_LEVEL_QUIET) { + + if (adapter) { + adapter->log.setCallbackSink(pfnLoggerCallback, pUserData, level); + } + + return UR_RESULT_SUCCESS; +} + +UR_APIEXPORT ur_result_t UR_APICALL +urAdapterSetLoggerCallbackLevel(ur_adapter_handle_t, ur_logger_level_t level) { + + if (adapter) { + adapter->log.setCallbackLevel(level); + } + + return UR_RESULT_SUCCESS; +} diff --git a/unified-runtime/source/adapters/opencl/common.cpp b/unified-runtime/source/adapters/opencl/common.cpp index 8c2786d7cb32e..5047e61ab9355 100644 --- a/unified-runtime/source/adapters/opencl/common.cpp +++ b/unified-runtime/source/adapters/opencl/common.cpp @@ -16,14 +16,6 @@ namespace cl_adapter { thread_local int32_t ErrorMessageCode = 0; thread_local char ErrorMessage[MaxMessageSize]{}; -[[maybe_unused]] void setErrorMessage(const char *Message, int32_t ErrorCode) { - assert(strlen(Message) < cl_adapter::MaxMessageSize); - // Copy at most MaxMessageSize - 1 bytes to ensure the resultant string is - // always null terminated. - strncpy(cl_adapter::ErrorMessage, Message, MaxMessageSize - 1); - - ErrorMessageCode = ErrorCode; -} } // namespace cl_adapter ur_result_t mapCLErrorToUR(cl_int Result) { diff --git a/unified-runtime/source/adapters/opencl/ur_interface_loader.cpp b/unified-runtime/source/adapters/opencl/ur_interface_loader.cpp index 72e6140526f7d..9ef88e97f6dcb 100644 --- a/unified-runtime/source/adapters/opencl/ur_interface_loader.cpp +++ b/unified-runtime/source/adapters/opencl/ur_interface_loader.cpp @@ -440,6 +440,19 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramExpProcAddrTable( return UR_RESULT_SUCCESS; } + +UR_DLLEXPORT ur_result_t UR_APICALL urGetAdapterProcAddrTable( + ur_api_version_t version, ur_adapter_dditable_t *pDdiTable) { + auto result = validateProcInputs(version, pDdiTable); + if (UR_RESULT_SUCCESS != result) { + return result; + } + pDdiTable->pfnSetLoggerCallback = urAdapterSetLoggerCallback; + pDdiTable->pfnSetLoggerCallbackLevel = urAdapterSetLoggerCallbackLevel; + + return UR_RESULT_SUCCESS; +} + #if defined(__cplusplus) } // extern "C" #endif diff --git a/unified-runtime/source/common/logger/ur_level.hpp b/unified-runtime/source/common/logger/ur_level.hpp index b8225a7de80dc..4eb1790f25f9f 100644 --- a/unified-runtime/source/common/logger/ur_level.hpp +++ b/unified-runtime/source/common/logger/ur_level.hpp @@ -8,22 +8,21 @@ #include #include +#include namespace logger { -enum class Level { DEBUG, INFO, WARN, ERR, QUIET }; - -inline constexpr auto level_to_str(Level level) { +inline constexpr auto level_to_str(ur_logger_level_t level) { switch (level) { - case Level::DEBUG: + case UR_LOGGER_LEVEL_DEBUG: return "DEBUG"; - case Level::INFO: + case UR_LOGGER_LEVEL_INFO: return "INFO"; - case Level::WARN: + case UR_LOGGER_LEVEL_WARN: return "WARNING"; - case Level::ERR: + case UR_LOGGER_LEVEL_ERROR: return "ERROR"; - case Level::QUIET: + case UR_LOGGER_LEVEL_QUIET: return "QUIET"; default: return ""; @@ -31,20 +30,20 @@ inline constexpr auto level_to_str(Level level) { } inline auto str_to_level(std::string name) { - struct lvl_name { + struct level_name { std::string name; - Level lvl; + ur_logger_level_t level; }; - const lvl_name lvl_names[] = {{"debug", Level::DEBUG}, - {"info", Level::INFO}, - {"warning", Level::WARN}, - {"error", Level::ERR}, - {"quiet", Level::QUIET}}; + const level_name level_names[] = {{"debug", UR_LOGGER_LEVEL_DEBUG}, + {"info", UR_LOGGER_LEVEL_INFO}, + {"warning", UR_LOGGER_LEVEL_WARN}, + {"error", UR_LOGGER_LEVEL_ERROR}, + {"quiet", UR_LOGGER_LEVEL_QUIET}}; - for (auto const &item : lvl_names) { + for (auto const &item : level_names) { if (item.name.compare(name) == 0) { - return item.lvl; + return item.level; } } throw std::invalid_argument( diff --git a/unified-runtime/source/common/logger/ur_logger.hpp b/unified-runtime/source/common/logger/ur_logger.hpp index 9d640be0e280a..d5aa7409ff0a4 100644 --- a/unified-runtime/source/common/logger/ur_logger.hpp +++ b/unified-runtime/source/common/logger/ur_logger.hpp @@ -14,13 +14,14 @@ namespace logger { -Logger create_logger(std::string logger_name, bool skip_prefix = false, - bool skip_linebreak = false, - logger::Level default_log_level = logger::Level::QUIET); +Logger +create_logger(std::string logger_name, bool skip_prefix = false, + bool skip_linebreak = false, + ur_logger_level_t default_log_level = UR_LOGGER_LEVEL_QUIET); inline Logger & get_logger(std::string name = "common", - logger::Level default_log_level = logger::Level::QUIET) { + ur_logger_level_t default_log_level = UR_LOGGER_LEVEL_QUIET) { static Logger logger = create_logger(std::move(name), /*skip_prefix*/ false, /*slip_linebreak*/ false, default_log_level); @@ -31,22 +32,22 @@ inline void init(const std::string &name) { get_logger(name.c_str()); } template inline void debug(const char *format, Args &&...args) { - get_logger().log(logger::Level::DEBUG, format, std::forward(args)...); + get_logger().log(UR_LOGGER_LEVEL_DEBUG, format, std::forward(args)...); } template inline void info(const char *format, Args &&...args) { - get_logger().log(logger::Level::INFO, format, std::forward(args)...); + get_logger().log(UR_LOGGER_LEVEL_INFO, format, std::forward(args)...); } template inline void warning(const char *format, Args &&...args) { - get_logger().log(logger::Level::WARN, format, std::forward(args)...); + get_logger().log(UR_LOGGER_LEVEL_WARN, format, std::forward(args)...); } template inline void error(const char *format, Args &&...args) { - get_logger().log(logger::Level::ERR, format, std::forward(args)...); + get_logger().log(UR_LOGGER_LEVEL_ERROR, format, std::forward(args)...); } template @@ -57,29 +58,32 @@ inline void always(const char *format, Args &&...args) { template inline void debug(const logger::LegacyMessage &p, const char *format, Args &&...args) { - get_logger().log(p, logger::Level::DEBUG, format, + get_logger().log(p, UR_LOGGER_LEVEL_DEBUG, format, std::forward(args)...); } template inline void info(logger::LegacyMessage p, const char *format, Args &&...args) { - get_logger().log(p, logger::Level::INFO, format, std::forward(args)...); + get_logger().log(p, UR_LOGGER_LEVEL_INFO, format, + std::forward(args)...); } template inline void warning(logger::LegacyMessage p, const char *format, Args &&...args) { - get_logger().log(p, logger::Level::WARN, format, std::forward(args)...); + get_logger().log(p, UR_LOGGER_LEVEL_WARN, format, + std::forward(args)...); } template inline void error(logger::LegacyMessage p, const char *format, Args &&...args) { - get_logger().log(p, logger::Level::ERR, format, std::forward(args)...); + get_logger().log(p, UR_LOGGER_LEVEL_ERROR, format, + std::forward(args)...); } -inline void setLevel(logger::Level level) { get_logger().setLevel(level); } +inline void setLevel(ur_logger_level_t level) { get_logger().setLevel(level); } -inline void setFlushLevel(logger::Level level) { +inline void setFlushLevel(ur_logger_level_t level) { get_logger().setFlushLevel(level); } @@ -115,21 +119,19 @@ template inline std::string toHex(T t) { /// to be printed immediately as they occur /// - output: stderr inline Logger create_logger(std::string logger_name, bool skip_prefix, - bool skip_linebreak, - logger::Level default_log_level) { + bool skip_linebreak, ur_logger_level_t level) { std::transform(logger_name.begin(), logger_name.end(), logger_name.begin(), ::toupper); - const auto default_flush_level = logger::Level::ERR; + const std::string env_var_name = "UR_LOG_" + logger_name; + const auto default_flush_level = UR_LOGGER_LEVEL_ERROR; const std::string default_output = "stderr"; - auto level = default_log_level; auto flush_level = default_flush_level; std::unique_ptr sink; - auto env_var_name = "UR_LOG_" + logger_name; try { auto map = getenv_to_map(env_var_name.c_str()); if (!map.has_value()) { - return Logger(default_log_level, + return Logger(level, std::make_unique( std::move(logger_name), skip_prefix, skip_linebreak)); } @@ -148,7 +150,7 @@ inline Logger create_logger(std::string logger_name, bool skip_prefix, map->erase(kv); } - std::vector values = {std::move(default_output)}; + std::vector values = {default_output}; kv = map->find("output"); if (kv != map->end()) { values = kv->second; @@ -158,7 +160,7 @@ inline Logger create_logger(std::string logger_name, bool skip_prefix, if (!map->empty()) { std::cerr << "Wrong logger environment variable parameter: '" << map->begin()->first << "'. Default logger options are set."; - return Logger(default_log_level, + return Logger(level, std::make_unique( std::move(logger_name), skip_prefix, skip_linebreak)); } @@ -171,10 +173,11 @@ inline Logger create_logger(std::string logger_name, bool skip_prefix, std::cerr << "Error when creating a logger instance from the '" << env_var_name << "' environment variable:\n" << e.what() << std::endl; - return Logger(default_log_level, + return Logger(level, std::make_unique( std::move(logger_name), skip_prefix, skip_linebreak)); } + sink->setFlushLevel(flush_level); return Logger(level, std::move(sink)); diff --git a/unified-runtime/source/common/logger/ur_logger_details.hpp b/unified-runtime/source/common/logger/ur_logger_details.hpp index 1247ba2cbea40..e917c31622da0 100644 --- a/unified-runtime/source/common/logger/ur_logger_details.hpp +++ b/unified-runtime/source/common/logger/ur_logger_details.hpp @@ -19,36 +19,40 @@ struct LegacyMessage { class Logger { public: - Logger(std::unique_ptr sink) : sink(std::move(sink)) { - this->level = logger::Level::QUIET; - } - - Logger(logger::Level level, std::unique_ptr sink) - : level(level), sink(std::move(sink)) {} - - Logger &operator=(Logger &&) = default; - ~Logger() = default; - - void setLevel(logger::Level level) { this->level = level; } - - logger::Level getLevel() { return this->level; } - - void setFlushLevel(logger::Level level) { - if (sink) { - this->sink->setFlushLevel(level); + Logger(std::unique_ptr sink, + std::unique_ptr callbackSink = nullptr) + : standardSinkLevel(UR_LOGGER_LEVEL_QUIET), standardSink(std::move(sink)), + callbackSinkLevel(UR_LOGGER_LEVEL_QUIET), + callbackSink(std::move(callbackSink)) {} + + Logger(ur_logger_level_t level = UR_LOGGER_LEVEL_QUIET, + std::unique_ptr sink = nullptr, + ur_logger_level_t callbackSinkLevel = UR_LOGGER_LEVEL_QUIET, + std::unique_ptr callbackSink = nullptr) + : standardSinkLevel(level), standardSink(std::move(sink)), + callbackSinkLevel(callbackSinkLevel), + callbackSink(std::move(callbackSink)) {} + + void setLevel(ur_logger_level_t level) { this->standardSinkLevel = level; } + + ur_logger_level_t getLevel() { return this->standardSinkLevel; } + + void setFlushLevel(ur_logger_level_t level) { + if (standardSink) { + this->standardSink->setFlushLevel(level); } } template void debug(const char *format, Args &&...args) { - log(logger::Level::DEBUG, format, std::forward(args)...); + log(UR_LOGGER_LEVEL_DEBUG, format, std::forward(args)...); } template void info(const char *format, Args &&...args) { - log(logger::Level::INFO, format, std::forward(args)...); + log(UR_LOGGER_LEVEL_INFO, format, std::forward(args)...); } template void warning(const char *format, Args &&...args) { - log(logger::Level::WARN, format, std::forward(args)...); + log(UR_LOGGER_LEVEL_WARN, format, std::forward(args)...); } template void warn(const char *format, Args &&...args) { @@ -56,72 +60,94 @@ class Logger { } template void error(const char *format, Args &&...args) { - log(logger::Level::ERR, format, std::forward(args)...); + log(UR_LOGGER_LEVEL_ERROR, format, std::forward(args)...); } template void always(const char *format, Args &&...args) { - if (sink) { - sink->log(logger::Level::QUIET, format, std::forward(args)...); + if (standardSink) { + standardSink->log(UR_LOGGER_LEVEL_QUIET, format, + std::forward(args)...); } } template void debug(const logger::LegacyMessage &p, const char *format, Args &&...args) { - log(p, logger::Level::DEBUG, format, std::forward(args)...); + log(p, UR_LOGGER_LEVEL_DEBUG, format, std::forward(args)...); } template void info(const logger::LegacyMessage &p, const char *format, Args &&...args) { - log(p, logger::Level::INFO, format, std::forward(args)...); + log(p, UR_LOGGER_LEVEL_INFO, format, std::forward(args)...); } template void warning(const logger::LegacyMessage &p, const char *format, Args &&...args) { - log(p, logger::Level::WARN, format, std::forward(args)...); + log(p, UR_LOGGER_LEVEL_WARN, format, std::forward(args)...); } template void error(const logger::LegacyMessage &p, const char *format, Args &&...args) { - log(p, logger::Level::ERR, format, std::forward(args)...); + log(p, UR_LOGGER_LEVEL_ERROR, format, std::forward(args)...); } template - void log(logger::Level level, const char *format, Args &&...args) { + void log(ur_logger_level_t level, const char *format, Args &&...args) { log(logger::LegacyMessage(format), level, format, std::forward(args)...); } template - void log(const logger::LegacyMessage &p, logger::Level level, + void log(const logger::LegacyMessage &p, ur_logger_level_t level, const char *format, Args &&...args) { - if (!sink) { - return; + if (callbackSink && level >= this->callbackSinkLevel) { + callbackSink->log(level, format, std::forward(args)...); } - if (isLegacySink) { - sink->log(level, p.message, std::forward(args)...); - return; - } - if (level < this->level) { - return; - } + if (standardSink) { + if (isLegacySink) { + standardSink->log(level, p.message, std::forward(args)...); + return; + } - sink->log(level, format, std::forward(args)...); + if (level < this->standardSinkLevel) { + return; + } + standardSink->log(level, format, std::forward(args)...); + } } void setLegacySink(std::unique_ptr legacySink) { this->isLegacySink = true; - this->sink = std::move(legacySink); + this->standardSink = std::move(legacySink); + } + + void setCallbackSink(ur_logger_callback_t callBack, void *pUserData, + ur_logger_level_t level = UR_LOGGER_LEVEL_QUIET) { + if (!callbackSink) { + callbackSink = std::make_unique("UR_LOG_CALLBACK"); + } + + if (callBack) { + callbackSink->setCallback(callBack, pUserData); + callbackSinkLevel = level; + } + } + + void setCallbackLevel(ur_logger_level_t level) { + this->callbackSinkLevel = level; } private: - logger::Level level; - std::unique_ptr sink; + ur_logger_level_t standardSinkLevel; + std::unique_ptr standardSink; bool isLegacySink = false; + + ur_logger_level_t callbackSinkLevel; + std::unique_ptr callbackSink; }; } // namespace logger diff --git a/unified-runtime/source/common/logger/ur_sinks.hpp b/unified-runtime/source/common/logger/ur_sinks.hpp index 8f580bc04d6c7..0fdb0e966309b 100644 --- a/unified-runtime/source/common/logger/ur_sinks.hpp +++ b/unified-runtime/source/common/logger/ur_sinks.hpp @@ -8,10 +8,12 @@ #define UR_SINKS_HPP 1 #include +#include #include #include #include +#include "ur_api.h" #include "ur_filesystem_resolved.hpp" #include "ur_level.hpp" #include "ur_print.hpp" @@ -25,9 +27,9 @@ inline bool isTearDowned = false; class Sink { public: template - void log(logger::Level level, const char *fmt, Args &&...args) { + void log(ur_logger_level_t level, const char *fmt, Args &&...args) { std::ostringstream buffer; - if (!skip_prefix && level != logger::Level::QUIET) { + if (!skip_prefix && level != UR_LOGGER_LEVEL_QUIET) { buffer << "<" << logger_name << ">" << "[" << level_to_str(level) << "]: "; } @@ -50,23 +52,23 @@ class Sink { #endif } - void setFlushLevel(logger::Level level) { this->flush_level = level; } + void setFlushLevel(ur_logger_level_t level) { this->flush_level = level; } virtual ~Sink() = default; protected: std::ostream *ostream; - logger::Level flush_level; + ur_logger_level_t flush_level; Sink(std::string logger_name, bool skip_prefix = false, bool skip_linebreak = false) : logger_name(std::move(logger_name)), skip_prefix(skip_prefix), skip_linebreak(skip_linebreak) { ostream = nullptr; - flush_level = logger::Level::ERR; + flush_level = UR_LOGGER_LEVEL_ERROR; } - virtual void print(logger::Level level, const std::string &msg) { + virtual void print(ur_logger_level_t level, const std::string &msg) { std::scoped_lock lock(output_mutex); *ostream << msg; if (level >= flush_level) { @@ -157,8 +159,8 @@ class StdoutSink : public Sink { this->ostream = &std::cout; } - StdoutSink(std::string logger_name, Level flush_lvl, bool skip_prefix = false, - bool skip_linebreak = false) + StdoutSink(std::string logger_name, ur_logger_level_t flush_lvl, + bool skip_prefix = false, bool skip_linebreak = false) : StdoutSink(std::move(logger_name), skip_prefix, skip_linebreak) { this->flush_level = flush_lvl; } @@ -174,8 +176,8 @@ class StderrSink : public Sink { this->ostream = &std::cerr; } - StderrSink(std::string logger_name, Level flush_lvl, bool skip_prefix, - bool skip_linebreak) + StderrSink(std::string logger_name, ur_logger_level_t flush_lvl, + bool skip_prefix, bool skip_linebreak) : StderrSink(std::move(logger_name), skip_prefix, skip_linebreak) { this->flush_level = flush_lvl; } @@ -198,8 +200,9 @@ class FileSink : public Sink { this->ostream = &ofstream; } - FileSink(std::string logger_name, filesystem::path file_path, Level flush_lvl, - bool skip_prefix = false, bool skip_linebreak = false) + FileSink(std::string logger_name, filesystem::path file_path, + ur_logger_level_t flush_lvl, bool skip_prefix = false, + bool skip_linebreak = false) : FileSink(std::move(logger_name), std::move(file_path), skip_prefix, skip_linebreak) { this->flush_level = flush_lvl; @@ -211,6 +214,36 @@ class FileSink : public Sink { std::ofstream ofstream; }; +class CallbackSink : public Sink { +public: + CallbackSink(std::string logger_name, bool skip_prefix = false, + bool skip_linebreak = false) + : Sink(std::move(logger_name), skip_prefix, skip_linebreak) {} + + CallbackSink(std::string logger_name, ur_logger_level_t flush_lvl, + bool skip_prefix, bool skip_linebreak) + : CallbackSink(std::move(logger_name), skip_prefix, skip_linebreak) { + this->flush_level = flush_lvl; + } + + ~CallbackSink() = default; + + void setCallback(ur_logger_callback_t cb, void *pUserData) { + callback = cb; + userData = pUserData; + } + +private: + ur_logger_callback_t callback = nullptr; + void *userData = nullptr; + + virtual void print(ur_logger_level_t level, const std::string &msg) override { + if (callback) { + callback(level, msg.c_str(), userData); + } + } +}; + inline std::unique_ptr sink_from_str(std::string logger_name, std::string name, filesystem::path file_path = "", diff --git a/unified-runtime/source/loader/layers/sanitizer/ur_sanitizer_layer.cpp b/unified-runtime/source/loader/layers/sanitizer/ur_sanitizer_layer.cpp index 9c57308c99d1a..b1d0e67085600 100644 --- a/unified-runtime/source/loader/layers/sanitizer/ur_sanitizer_layer.cpp +++ b/unified-runtime/source/loader/layers/sanitizer/ur_sanitizer_layer.cpp @@ -27,7 +27,7 @@ context_t *getContext() { /////////////////////////////////////////////////////////////////////////////// context_t::context_t() : logger(logger::create_logger("sanitizer", false, false, - logger::Level::WARN)) {} + UR_LOGGER_LEVEL_WARN)) {} ur_result_t context_t::tearDown() { switch (enabledType) { diff --git a/unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp b/unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp index e0a617d1b2213..eb44285c18389 100644 --- a/unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp +++ b/unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp @@ -49,7 +49,7 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGet( getContext()->notify_end(UR_FUNCTION_ADAPTER_GET, "urAdapterGet", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ADAPTER_GET, ¶ms); logger.info(" <--- urAdapterGet({}) -> {};\n", args_str.str(), result); @@ -80,7 +80,7 @@ __urdlllocal ur_result_t UR_APICALL urAdapterRelease( getContext()->notify_end(UR_FUNCTION_ADAPTER_RELEASE, "urAdapterRelease", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ADAPTER_RELEASE, ¶ms); @@ -113,7 +113,7 @@ __urdlllocal ur_result_t UR_APICALL urAdapterRetain( getContext()->notify_end(UR_FUNCTION_ADAPTER_RETAIN, "urAdapterRetain", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ADAPTER_RETAIN, ¶ms); @@ -152,7 +152,7 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGetLastError( getContext()->notify_end(UR_FUNCTION_ADAPTER_GET_LAST_ERROR, "urAdapterGetLastError", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ADAPTER_GET_LAST_ERROR, ¶ms); @@ -200,7 +200,7 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGetInfo( getContext()->notify_end(UR_FUNCTION_ADAPTER_GET_INFO, "urAdapterGetInfo", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ADAPTER_GET_INFO, ¶ms); @@ -211,6 +211,88 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGetInfo( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterSetLoggerCallback +__urdlllocal ur_result_t UR_APICALL urAdapterSetLoggerCallback( + /// [in] handle of the adapter + ur_adapter_handle_t hAdapter, + /// [in] Function pointer to callback from the logger. + ur_logger_callback_t pfnLoggerCallback, + /// [in][out][optional] pointer to data to be passed to callback + void *pUserData, + /// [in] logging level + ur_logger_level_t level) { + auto pfnSetLoggerCallback = + getContext()->urDdiTable.Adapter.pfnSetLoggerCallback; + + if (nullptr == pfnSetLoggerCallback) + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ur_adapter_set_logger_callback_params_t params = { + &hAdapter, &pfnLoggerCallback, &pUserData, &level}; + uint64_t instance = + getContext()->notify_begin(UR_FUNCTION_ADAPTER_SET_LOGGER_CALLBACK, + "urAdapterSetLoggerCallback", ¶ms); + + auto &logger = getContext()->logger; + logger.info(" ---> urAdapterSetLoggerCallback\n"); + + ur_result_t result = + pfnSetLoggerCallback(hAdapter, pfnLoggerCallback, pUserData, level); + + getContext()->notify_end(UR_FUNCTION_ADAPTER_SET_LOGGER_CALLBACK, + "urAdapterSetLoggerCallback", ¶ms, &result, + instance); + + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { + std::ostringstream args_str; + ur::extras::printFunctionParams( + args_str, UR_FUNCTION_ADAPTER_SET_LOGGER_CALLBACK, ¶ms); + logger.info(" <--- urAdapterSetLoggerCallback({}) -> {};\n", + args_str.str(), result); + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterSetLoggerCallbackLevel +__urdlllocal ur_result_t UR_APICALL urAdapterSetLoggerCallbackLevel( + /// [in] handle of the adapter + ur_adapter_handle_t hAdapter, + /// [in] logging level + ur_logger_level_t level) { + auto pfnSetLoggerCallbackLevel = + getContext()->urDdiTable.Adapter.pfnSetLoggerCallbackLevel; + + if (nullptr == pfnSetLoggerCallbackLevel) + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ur_adapter_set_logger_callback_level_params_t params = {&hAdapter, &level}; + uint64_t instance = + getContext()->notify_begin(UR_FUNCTION_ADAPTER_SET_LOGGER_CALLBACK_LEVEL, + "urAdapterSetLoggerCallbackLevel", ¶ms); + + auto &logger = getContext()->logger; + logger.info(" ---> urAdapterSetLoggerCallbackLevel\n"); + + ur_result_t result = pfnSetLoggerCallbackLevel(hAdapter, level); + + getContext()->notify_end(UR_FUNCTION_ADAPTER_SET_LOGGER_CALLBACK_LEVEL, + "urAdapterSetLoggerCallbackLevel", ¶ms, &result, + instance); + + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { + std::ostringstream args_str; + ur::extras::printFunctionParams( + args_str, UR_FUNCTION_ADAPTER_SET_LOGGER_CALLBACK_LEVEL, ¶ms); + logger.info(" <--- urAdapterSetLoggerCallbackLevel({}) -> {};\n", + args_str.str(), result); + } + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urPlatformGet __urdlllocal ur_result_t UR_APICALL urPlatformGet( @@ -245,7 +327,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGet( getContext()->notify_end(UR_FUNCTION_PLATFORM_GET, "urPlatformGet", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PLATFORM_GET, ¶ms); @@ -292,7 +374,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetInfo( getContext()->notify_end(UR_FUNCTION_PLATFORM_GET_INFO, "urPlatformGetInfo", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PLATFORM_GET_INFO, ¶ms); @@ -328,7 +410,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetApiVersion( "urPlatformGetApiVersion", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_PLATFORM_GET_API_VERSION, ¶ms); @@ -367,7 +449,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetNativeHandle( "urPlatformGetNativeHandle", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_PLATFORM_GET_NATIVE_HANDLE, ¶ms); @@ -411,7 +493,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( "urPlatformCreateWithNativeHandle", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_PLATFORM_CREATE_WITH_NATIVE_HANDLE, ¶ms); @@ -454,7 +536,7 @@ __urdlllocal ur_result_t UR_APICALL urPlatformGetBackendOption( "urPlatformGetBackendOption", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_PLATFORM_GET_BACKEND_OPTION, ¶ms); @@ -503,7 +585,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGet( getContext()->notify_end(UR_FUNCTION_DEVICE_GET, "urDeviceGet", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_DEVICE_GET, ¶ms); logger.info(" <--- urDeviceGet({}) -> {};\n", args_str.str(), result); @@ -550,7 +632,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetInfo( getContext()->notify_end(UR_FUNCTION_DEVICE_GET_INFO, "urDeviceGetInfo", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_DEVICE_GET_INFO, ¶ms); @@ -582,7 +664,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceRetain( getContext()->notify_end(UR_FUNCTION_DEVICE_RETAIN, "urDeviceRetain", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_DEVICE_RETAIN, ¶ms); @@ -614,7 +696,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceRelease( getContext()->notify_end(UR_FUNCTION_DEVICE_RELEASE, "urDeviceRelease", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_DEVICE_RELEASE, ¶ms); @@ -659,7 +741,7 @@ __urdlllocal ur_result_t UR_APICALL urDevicePartition( getContext()->notify_end(UR_FUNCTION_DEVICE_PARTITION, "urDevicePartition", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_DEVICE_PARTITION, ¶ms); @@ -704,7 +786,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceSelectBinary( getContext()->notify_end(UR_FUNCTION_DEVICE_SELECT_BINARY, "urDeviceSelectBinary", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_DEVICE_SELECT_BINARY, ¶ms); @@ -740,7 +822,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetNativeHandle( "urDeviceGetNativeHandle", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_DEVICE_GET_NATIVE_HANDLE, ¶ms); @@ -784,7 +866,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( "urDeviceCreateWithNativeHandle", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_DEVICE_CREATE_WITH_NATIVE_HANDLE, ¶ms); @@ -828,7 +910,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetGlobalTimestamps( "urDeviceGetGlobalTimestamps", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_DEVICE_GET_GLOBAL_TIMESTAMPS, ¶ms); @@ -869,7 +951,7 @@ __urdlllocal ur_result_t UR_APICALL urContextCreate( getContext()->notify_end(UR_FUNCTION_CONTEXT_CREATE, "urContextCreate", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_CONTEXT_CREATE, ¶ms); @@ -901,7 +983,7 @@ __urdlllocal ur_result_t UR_APICALL urContextRetain( getContext()->notify_end(UR_FUNCTION_CONTEXT_RETAIN, "urContextRetain", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_CONTEXT_RETAIN, ¶ms); @@ -933,7 +1015,7 @@ __urdlllocal ur_result_t UR_APICALL urContextRelease( getContext()->notify_end(UR_FUNCTION_CONTEXT_RELEASE, "urContextRelease", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_CONTEXT_RELEASE, ¶ms); @@ -982,7 +1064,7 @@ __urdlllocal ur_result_t UR_APICALL urContextGetInfo( getContext()->notify_end(UR_FUNCTION_CONTEXT_GET_INFO, "urContextGetInfo", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_CONTEXT_GET_INFO, ¶ms); @@ -1019,7 +1101,7 @@ __urdlllocal ur_result_t UR_APICALL urContextGetNativeHandle( "urContextGetNativeHandle", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_CONTEXT_GET_NATIVE_HANDLE, ¶ms); @@ -1069,7 +1151,7 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( "urContextCreateWithNativeHandle", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_CONTEXT_CREATE_WITH_NATIVE_HANDLE, ¶ms); @@ -1110,7 +1192,7 @@ __urdlllocal ur_result_t UR_APICALL urContextSetExtendedDeleter( "urContextSetExtendedDeleter", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_CONTEXT_SET_EXTENDED_DELETER, ¶ms); @@ -1155,7 +1237,7 @@ __urdlllocal ur_result_t UR_APICALL urMemImageCreate( getContext()->notify_end(UR_FUNCTION_MEM_IMAGE_CREATE, "urMemImageCreate", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_MEM_IMAGE_CREATE, ¶ms); @@ -1198,7 +1280,7 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreate( getContext()->notify_end(UR_FUNCTION_MEM_BUFFER_CREATE, "urMemBufferCreate", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_MEM_BUFFER_CREATE, ¶ms); @@ -1231,7 +1313,7 @@ __urdlllocal ur_result_t UR_APICALL urMemRetain( getContext()->notify_end(UR_FUNCTION_MEM_RETAIN, "urMemRetain", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_MEM_RETAIN, ¶ms); logger.info(" <--- urMemRetain({}) -> {};\n", args_str.str(), result); @@ -1262,7 +1344,7 @@ __urdlllocal ur_result_t UR_APICALL urMemRelease( getContext()->notify_end(UR_FUNCTION_MEM_RELEASE, "urMemRelease", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_MEM_RELEASE, ¶ms); logger.info(" <--- urMemRelease({}) -> {};\n", args_str.str(), result); @@ -1303,7 +1385,7 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferPartition( getContext()->notify_end(UR_FUNCTION_MEM_BUFFER_PARTITION, "urMemBufferPartition", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_MEM_BUFFER_PARTITION, ¶ms); @@ -1341,7 +1423,7 @@ __urdlllocal ur_result_t UR_APICALL urMemGetNativeHandle( getContext()->notify_end(UR_FUNCTION_MEM_GET_NATIVE_HANDLE, "urMemGetNativeHandle", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_MEM_GET_NATIVE_HANDLE, ¶ms); @@ -1385,7 +1467,7 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreateWithNativeHandle( "urMemBufferCreateWithNativeHandle", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_MEM_BUFFER_CREATE_WITH_NATIVE_HANDLE, ¶ms); @@ -1433,7 +1515,7 @@ __urdlllocal ur_result_t UR_APICALL urMemImageCreateWithNativeHandle( "urMemImageCreateWithNativeHandle", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_MEM_IMAGE_CREATE_WITH_NATIVE_HANDLE, ¶ms); @@ -1481,7 +1563,7 @@ __urdlllocal ur_result_t UR_APICALL urMemGetInfo( getContext()->notify_end(UR_FUNCTION_MEM_GET_INFO, "urMemGetInfo", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_MEM_GET_INFO, ¶ms); @@ -1528,7 +1610,7 @@ __urdlllocal ur_result_t UR_APICALL urMemImageGetInfo( getContext()->notify_end(UR_FUNCTION_MEM_IMAGE_GET_INFO, "urMemImageGetInfo", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_MEM_IMAGE_GET_INFO, ¶ms); @@ -1565,7 +1647,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerCreate( getContext()->notify_end(UR_FUNCTION_SAMPLER_CREATE, "urSamplerCreate", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_SAMPLER_CREATE, ¶ms); @@ -1597,7 +1679,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerRetain( getContext()->notify_end(UR_FUNCTION_SAMPLER_RETAIN, "urSamplerRetain", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_SAMPLER_RETAIN, ¶ms); @@ -1629,7 +1711,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerRelease( getContext()->notify_end(UR_FUNCTION_SAMPLER_RELEASE, "urSamplerRelease", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_SAMPLER_RELEASE, ¶ms); @@ -1673,7 +1755,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetInfo( getContext()->notify_end(UR_FUNCTION_SAMPLER_GET_INFO, "urSamplerGetInfo", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_SAMPLER_GET_INFO, ¶ms); @@ -1710,7 +1792,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerGetNativeHandle( "urSamplerGetNativeHandle", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_SAMPLER_GET_NATIVE_HANDLE, ¶ms); @@ -1754,7 +1836,7 @@ __urdlllocal ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( "urSamplerCreateWithNativeHandle", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_SAMPLER_CREATE_WITH_NATIVE_HANDLE, ¶ms); @@ -1796,7 +1878,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMHostAlloc( getContext()->notify_end(UR_FUNCTION_USM_HOST_ALLOC, "urUSMHostAlloc", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_HOST_ALLOC, ¶ms); @@ -1840,7 +1922,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMDeviceAlloc( getContext()->notify_end(UR_FUNCTION_USM_DEVICE_ALLOC, "urUSMDeviceAlloc", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_DEVICE_ALLOC, ¶ms); @@ -1885,7 +1967,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMSharedAlloc( getContext()->notify_end(UR_FUNCTION_USM_SHARED_ALLOC, "urUSMSharedAlloc", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_SHARED_ALLOC, ¶ms); @@ -1920,7 +2002,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMFree( getContext()->notify_end(UR_FUNCTION_USM_FREE, "urUSMFree", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_FREE, ¶ms); logger.info(" <--- urUSMFree({}) -> {};\n", args_str.str(), result); @@ -1964,7 +2046,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMGetMemAllocInfo( getContext()->notify_end(UR_FUNCTION_USM_GET_MEM_ALLOC_INFO, "urUSMGetMemAllocInfo", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_USM_GET_MEM_ALLOC_INFO, ¶ms); @@ -2002,7 +2084,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolCreate( getContext()->notify_end(UR_FUNCTION_USM_POOL_CREATE, "urUSMPoolCreate", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_POOL_CREATE, ¶ms); @@ -2034,7 +2116,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolRetain( getContext()->notify_end(UR_FUNCTION_USM_POOL_RETAIN, "urUSMPoolRetain", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_POOL_RETAIN, ¶ms); @@ -2066,7 +2148,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolRelease( getContext()->notify_end(UR_FUNCTION_USM_POOL_RELEASE, "urUSMPoolRelease", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_POOL_RELEASE, ¶ms); @@ -2110,7 +2192,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolGetInfo( getContext()->notify_end(UR_FUNCTION_USM_POOL_GET_INFO, "urUSMPoolGetInfo", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_POOL_GET_INFO, ¶ms); @@ -2164,7 +2246,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemGranularityGetInfo( "urVirtualMemGranularityGetInfo", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_VIRTUAL_MEM_GRANULARITY_GET_INFO, ¶ms); @@ -2207,7 +2289,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemReserve( getContext()->notify_end(UR_FUNCTION_VIRTUAL_MEM_RESERVE, "urVirtualMemReserve", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_VIRTUAL_MEM_RESERVE, ¶ms); @@ -2244,7 +2326,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemFree( getContext()->notify_end(UR_FUNCTION_VIRTUAL_MEM_FREE, "urVirtualMemFree", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_VIRTUAL_MEM_FREE, ¶ms); @@ -2289,7 +2371,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemMap( getContext()->notify_end(UR_FUNCTION_VIRTUAL_MEM_MAP, "urVirtualMemMap", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_VIRTUAL_MEM_MAP, ¶ms); @@ -2325,7 +2407,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemUnmap( getContext()->notify_end(UR_FUNCTION_VIRTUAL_MEM_UNMAP, "urVirtualMemUnmap", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_VIRTUAL_MEM_UNMAP, ¶ms); @@ -2365,7 +2447,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemSetAccess( getContext()->notify_end(UR_FUNCTION_VIRTUAL_MEM_SET_ACCESS, "urVirtualMemSetAccess", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_VIRTUAL_MEM_SET_ACCESS, ¶ms); @@ -2417,7 +2499,7 @@ __urdlllocal ur_result_t UR_APICALL urVirtualMemGetInfo( getContext()->notify_end(UR_FUNCTION_VIRTUAL_MEM_GET_INFO, "urVirtualMemGetInfo", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_VIRTUAL_MEM_GET_INFO, ¶ms); @@ -2461,7 +2543,7 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemCreate( getContext()->notify_end(UR_FUNCTION_PHYSICAL_MEM_CREATE, "urPhysicalMemCreate", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PHYSICAL_MEM_CREATE, ¶ms); @@ -2494,7 +2576,7 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemRetain( getContext()->notify_end(UR_FUNCTION_PHYSICAL_MEM_RETAIN, "urPhysicalMemRetain", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PHYSICAL_MEM_RETAIN, ¶ms); @@ -2527,7 +2609,7 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemRelease( getContext()->notify_end(UR_FUNCTION_PHYSICAL_MEM_RELEASE, "urPhysicalMemRelease", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PHYSICAL_MEM_RELEASE, ¶ms); @@ -2574,7 +2656,7 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemGetInfo( getContext()->notify_end(UR_FUNCTION_PHYSICAL_MEM_GET_INFO, "urPhysicalMemGetInfo", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PHYSICAL_MEM_GET_INFO, ¶ms); @@ -2617,7 +2699,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithIL( getContext()->notify_end(UR_FUNCTION_PROGRAM_CREATE_WITH_IL, "urProgramCreateWithIL", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_PROGRAM_CREATE_WITH_IL, ¶ms); @@ -2672,7 +2754,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithBinary( "urProgramCreateWithBinary", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_PROGRAM_CREATE_WITH_BINARY, ¶ms); @@ -2709,7 +2791,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuild( getContext()->notify_end(UR_FUNCTION_PROGRAM_BUILD, "urProgramBuild", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PROGRAM_BUILD, ¶ms); @@ -2745,7 +2827,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramCompile( getContext()->notify_end(UR_FUNCTION_PROGRAM_COMPILE, "urProgramCompile", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PROGRAM_COMPILE, ¶ms); @@ -2791,7 +2873,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramLink( getContext()->notify_end(UR_FUNCTION_PROGRAM_LINK, "urProgramLink", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PROGRAM_LINK, ¶ms); @@ -2823,7 +2905,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramRetain( getContext()->notify_end(UR_FUNCTION_PROGRAM_RETAIN, "urProgramRetain", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PROGRAM_RETAIN, ¶ms); @@ -2855,7 +2937,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramRelease( getContext()->notify_end(UR_FUNCTION_PROGRAM_RELEASE, "urProgramRelease", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PROGRAM_RELEASE, ¶ms); @@ -2901,7 +2983,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetFunctionPointer( "urProgramGetFunctionPointer", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_PROGRAM_GET_FUNCTION_POINTER, ¶ms); @@ -2951,7 +3033,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetGlobalVariablePointer( "urProgramGetGlobalVariablePointer", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_PROGRAM_GET_GLOBAL_VARIABLE_POINTER, ¶ms); @@ -3000,7 +3082,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetInfo( getContext()->notify_end(UR_FUNCTION_PROGRAM_GET_INFO, "urProgramGetInfo", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PROGRAM_GET_INFO, ¶ms); @@ -3050,7 +3132,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetBuildInfo( getContext()->notify_end(UR_FUNCTION_PROGRAM_GET_BUILD_INFO, "urProgramGetBuildInfo", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_PROGRAM_GET_BUILD_INFO, ¶ms); @@ -3093,7 +3175,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramSetSpecializationConstants( "urProgramSetSpecializationConstants", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_PROGRAM_SET_SPECIALIZATION_CONSTANTS, ¶ms); @@ -3130,7 +3212,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramGetNativeHandle( "urProgramGetNativeHandle", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_PROGRAM_GET_NATIVE_HANDLE, ¶ms); @@ -3174,7 +3256,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithNativeHandle( "urProgramCreateWithNativeHandle", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_PROGRAM_CREATE_WITH_NATIVE_HANDLE, ¶ms); @@ -3211,7 +3293,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelCreate( getContext()->notify_end(UR_FUNCTION_KERNEL_CREATE, "urKernelCreate", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_KERNEL_CREATE, ¶ms); @@ -3255,7 +3337,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgValue( getContext()->notify_end(UR_FUNCTION_KERNEL_SET_ARG_VALUE, "urKernelSetArgValue", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_KERNEL_SET_ARG_VALUE, ¶ms); @@ -3295,7 +3377,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgLocal( getContext()->notify_end(UR_FUNCTION_KERNEL_SET_ARG_LOCAL, "urKernelSetArgLocal", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_KERNEL_SET_ARG_LOCAL, ¶ms); @@ -3344,7 +3426,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetInfo( getContext()->notify_end(UR_FUNCTION_KERNEL_GET_INFO, "urKernelGetInfo", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_KERNEL_GET_INFO, ¶ms); @@ -3390,7 +3472,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetGroupInfo( getContext()->notify_end(UR_FUNCTION_KERNEL_GET_GROUP_INFO, "urKernelGetGroupInfo", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_KERNEL_GET_GROUP_INFO, ¶ms); @@ -3439,7 +3521,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetSubGroupInfo( "urKernelGetSubGroupInfo", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_KERNEL_GET_SUB_GROUP_INFO, ¶ms); @@ -3472,7 +3554,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelRetain( getContext()->notify_end(UR_FUNCTION_KERNEL_RETAIN, "urKernelRetain", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_KERNEL_RETAIN, ¶ms); @@ -3504,7 +3586,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelRelease( getContext()->notify_end(UR_FUNCTION_KERNEL_RELEASE, "urKernelRelease", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_KERNEL_RELEASE, ¶ms); @@ -3545,7 +3627,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgPointer( getContext()->notify_end(UR_FUNCTION_KERNEL_SET_ARG_POINTER, "urKernelSetArgPointer", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_KERNEL_SET_ARG_POINTER, ¶ms); @@ -3589,7 +3671,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetExecInfo( getContext()->notify_end(UR_FUNCTION_KERNEL_SET_EXEC_INFO, "urKernelSetExecInfo", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_KERNEL_SET_EXEC_INFO, ¶ms); @@ -3630,7 +3712,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgSampler( getContext()->notify_end(UR_FUNCTION_KERNEL_SET_ARG_SAMPLER, "urKernelSetArgSampler", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_KERNEL_SET_ARG_SAMPLER, ¶ms); @@ -3671,7 +3753,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgMemObj( getContext()->notify_end(UR_FUNCTION_KERNEL_SET_ARG_MEM_OBJ, "urKernelSetArgMemObj", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_KERNEL_SET_ARG_MEM_OBJ, ¶ms); @@ -3713,7 +3795,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetSpecializationConstants( "urKernelSetSpecializationConstants", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_KERNEL_SET_SPECIALIZATION_CONSTANTS, ¶ms); @@ -3749,7 +3831,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetNativeHandle( "urKernelGetNativeHandle", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_KERNEL_GET_NATIVE_HANDLE, ¶ms); @@ -3795,7 +3877,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelCreateWithNativeHandle( "urKernelCreateWithNativeHandle", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_KERNEL_CREATE_WITH_NATIVE_HANDLE, ¶ms); @@ -3850,7 +3932,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelGetSuggestedLocalWorkSize( "urKernelGetSuggestedLocalWorkSize", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_KERNEL_GET_SUGGESTED_LOCAL_WORK_SIZE, ¶ms); @@ -3894,7 +3976,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetInfo( getContext()->notify_end(UR_FUNCTION_QUEUE_GET_INFO, "urQueueGetInfo", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_QUEUE_GET_INFO, ¶ms); @@ -3933,7 +4015,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueCreate( getContext()->notify_end(UR_FUNCTION_QUEUE_CREATE, "urQueueCreate", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_QUEUE_CREATE, ¶ms); @@ -3965,7 +4047,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueRetain( getContext()->notify_end(UR_FUNCTION_QUEUE_RETAIN, "urQueueRetain", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_QUEUE_RETAIN, ¶ms); @@ -3997,7 +4079,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueRelease( getContext()->notify_end(UR_FUNCTION_QUEUE_RELEASE, "urQueueRelease", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_QUEUE_RELEASE, ¶ms); @@ -4035,7 +4117,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueGetNativeHandle( "urQueueGetNativeHandle", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_QUEUE_GET_NATIVE_HANDLE, ¶ms); @@ -4081,7 +4163,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueCreateWithNativeHandle( "urQueueCreateWithNativeHandle", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_QUEUE_CREATE_WITH_NATIVE_HANDLE, ¶ms); @@ -4114,7 +4196,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueFinish( getContext()->notify_end(UR_FUNCTION_QUEUE_FINISH, "urQueueFinish", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_QUEUE_FINISH, ¶ms); @@ -4146,7 +4228,7 @@ __urdlllocal ur_result_t UR_APICALL urQueueFlush( getContext()->notify_end(UR_FUNCTION_QUEUE_FLUSH, "urQueueFlush", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_QUEUE_FLUSH, ¶ms); logger.info(" <--- urQueueFlush({}) -> {};\n", args_str.str(), result); @@ -4188,7 +4270,7 @@ __urdlllocal ur_result_t UR_APICALL urEventGetInfo( getContext()->notify_end(UR_FUNCTION_EVENT_GET_INFO, "urEventGetInfo", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_EVENT_GET_INFO, ¶ms); @@ -4233,7 +4315,7 @@ __urdlllocal ur_result_t UR_APICALL urEventGetProfilingInfo( "urEventGetProfilingInfo", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_EVENT_GET_PROFILING_INFO, ¶ms); @@ -4269,7 +4351,7 @@ __urdlllocal ur_result_t UR_APICALL urEventWait( getContext()->notify_end(UR_FUNCTION_EVENT_WAIT, "urEventWait", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_EVENT_WAIT, ¶ms); logger.info(" <--- urEventWait({}) -> {};\n", args_str.str(), result); @@ -4300,7 +4382,7 @@ __urdlllocal ur_result_t UR_APICALL urEventRetain( getContext()->notify_end(UR_FUNCTION_EVENT_RETAIN, "urEventRetain", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_EVENT_RETAIN, ¶ms); @@ -4332,7 +4414,7 @@ __urdlllocal ur_result_t UR_APICALL urEventRelease( getContext()->notify_end(UR_FUNCTION_EVENT_RELEASE, "urEventRelease", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_EVENT_RELEASE, ¶ms); @@ -4367,7 +4449,7 @@ __urdlllocal ur_result_t UR_APICALL urEventGetNativeHandle( "urEventGetNativeHandle", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_EVENT_GET_NATIVE_HANDLE, ¶ms); @@ -4411,7 +4493,7 @@ __urdlllocal ur_result_t UR_APICALL urEventCreateWithNativeHandle( "urEventCreateWithNativeHandle", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_EVENT_CREATE_WITH_NATIVE_HANDLE, ¶ms); @@ -4451,7 +4533,7 @@ __urdlllocal ur_result_t UR_APICALL urEventSetCallback( getContext()->notify_end(UR_FUNCTION_EVENT_SET_CALLBACK, "urEventSetCallback", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_EVENT_SET_CALLBACK, ¶ms); @@ -4523,7 +4605,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueKernelLaunch( getContext()->notify_end(UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH, "urEnqueueKernelLaunch", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH, ¶ms); @@ -4570,7 +4652,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueEventsWait( getContext()->notify_end(UR_FUNCTION_ENQUEUE_EVENTS_WAIT, "urEnqueueEventsWait", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ENQUEUE_EVENTS_WAIT, ¶ms); @@ -4620,7 +4702,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueEventsWaitWithBarrier( "urEnqueueEventsWaitWithBarrier", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_EVENTS_WAIT_WITH_BARRIER, ¶ms); @@ -4680,7 +4762,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferRead( "urEnqueueMemBufferRead", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ, ¶ms); @@ -4740,7 +4822,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferWrite( "urEnqueueMemBufferWrite", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE, ¶ms); @@ -4816,7 +4898,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferReadRect( "urEnqueueMemBufferReadRect", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_MEM_BUFFER_READ_RECT, ¶ms); @@ -4893,7 +4975,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferWriteRect( "urEnqueueMemBufferWriteRect", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_MEM_BUFFER_WRITE_RECT, ¶ms); @@ -4952,7 +5034,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferCopy( "urEnqueueMemBufferCopy", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY, ¶ms); @@ -5024,7 +5106,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferCopyRect( "urEnqueueMemBufferCopyRect", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_MEM_BUFFER_COPY_RECT, ¶ms); @@ -5089,7 +5171,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferFill( "urEnqueueMemBufferFill", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_MEM_BUFFER_FILL, ¶ms); @@ -5154,7 +5236,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageRead( getContext()->notify_end(UR_FUNCTION_ENQUEUE_MEM_IMAGE_READ, "urEnqueueMemImageRead", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_MEM_IMAGE_READ, ¶ms); @@ -5220,7 +5302,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageWrite( "urEnqueueMemImageWrite", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_MEM_IMAGE_WRITE, ¶ms); @@ -5281,7 +5363,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageCopy( getContext()->notify_end(UR_FUNCTION_ENQUEUE_MEM_IMAGE_COPY, "urEnqueueMemImageCopy", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_MEM_IMAGE_COPY, ¶ms); @@ -5343,7 +5425,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferMap( getContext()->notify_end(UR_FUNCTION_ENQUEUE_MEM_BUFFER_MAP, "urEnqueueMemBufferMap", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_MEM_BUFFER_MAP, ¶ms); @@ -5394,7 +5476,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemUnmap( getContext()->notify_end(UR_FUNCTION_ENQUEUE_MEM_UNMAP, "urEnqueueMemUnmap", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ENQUEUE_MEM_UNMAP, ¶ms); @@ -5452,7 +5534,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMFill( getContext()->notify_end(UR_FUNCTION_ENQUEUE_USM_FILL, "urEnqueueUSMFill", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ENQUEUE_USM_FILL, ¶ms); @@ -5508,7 +5590,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMMemcpy( getContext()->notify_end(UR_FUNCTION_ENQUEUE_USM_MEMCPY, "urEnqueueUSMMemcpy", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ENQUEUE_USM_MEMCPY, ¶ms); @@ -5561,7 +5643,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMPrefetch( getContext()->notify_end(UR_FUNCTION_ENQUEUE_USM_PREFETCH, "urEnqueueUSMPrefetch", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ENQUEUE_USM_PREFETCH, ¶ms); @@ -5604,7 +5686,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMAdvise( getContext()->notify_end(UR_FUNCTION_ENQUEUE_USM_ADVISE, "urEnqueueUSMAdvise", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ENQUEUE_USM_ADVISE, ¶ms); @@ -5668,7 +5750,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMFill2D( getContext()->notify_end(UR_FUNCTION_ENQUEUE_USM_FILL_2D, "urEnqueueUSMFill2D", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ENQUEUE_USM_FILL_2D, ¶ms); @@ -5734,7 +5816,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMMemcpy2D( getContext()->notify_end(UR_FUNCTION_ENQUEUE_USM_MEMCPY_2D, "urEnqueueUSMMemcpy2D", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ENQUEUE_USM_MEMCPY_2D, ¶ms); @@ -5799,7 +5881,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableWrite( "urEnqueueDeviceGlobalVariableWrite", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_WRITE, ¶ms); @@ -5864,7 +5946,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableRead( "urEnqueueDeviceGlobalVariableRead", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_READ, ¶ms); @@ -5928,7 +6010,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueReadHostPipe( getContext()->notify_end(UR_FUNCTION_ENQUEUE_READ_HOST_PIPE, "urEnqueueReadHostPipe", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_READ_HOST_PIPE, ¶ms); @@ -5994,7 +6076,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueWriteHostPipe( "urEnqueueWriteHostPipe", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_WRITE_HOST_PIPE, ¶ms); @@ -6051,7 +6133,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMDeviceAllocExp( "urEnqueueUSMDeviceAllocExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_USM_DEVICE_ALLOC_EXP, ¶ms); @@ -6108,7 +6190,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMSharedAllocExp( "urEnqueueUSMSharedAllocExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_USM_SHARED_ALLOC_EXP, ¶ms); @@ -6165,7 +6247,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMHostAllocExp( "urEnqueueUSMHostAllocExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_USM_HOST_ALLOC_EXP, ¶ms); @@ -6213,7 +6295,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMFreeExp( getContext()->notify_end(UR_FUNCTION_ENQUEUE_USM_FREE_EXP, "urEnqueueUSMFreeExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_ENQUEUE_USM_FREE_EXP, ¶ms); @@ -6254,7 +6336,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolCreateExp( getContext()->notify_end(UR_FUNCTION_USM_POOL_CREATE_EXP, "urUSMPoolCreateExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_POOL_CREATE_EXP, ¶ms); @@ -6291,7 +6373,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolDestroyExp( getContext()->notify_end(UR_FUNCTION_USM_POOL_DESTROY_EXP, "urUSMPoolDestroyExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_POOL_DESTROY_EXP, ¶ms); @@ -6332,7 +6414,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolGetDefaultDevicePoolExp( "urUSMPoolGetDefaultDevicePoolExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_USM_POOL_GET_DEFAULT_DEVICE_POOL_EXP, ¶ms); @@ -6373,7 +6455,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolGetInfoExp( getContext()->notify_end(UR_FUNCTION_USM_POOL_GET_INFO_EXP, "urUSMPoolGetInfoExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_POOL_GET_INFO_EXP, ¶ms); @@ -6413,7 +6495,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolSetInfoExp( getContext()->notify_end(UR_FUNCTION_USM_POOL_SET_INFO_EXP, "urUSMPoolSetInfoExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_POOL_SET_INFO_EXP, ¶ms); @@ -6454,7 +6536,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolSetDevicePoolExp( "urUSMPoolSetDevicePoolExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_USM_POOL_SET_DEVICE_POOL_EXP, ¶ms); @@ -6495,7 +6577,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolGetDevicePoolExp( "urUSMPoolGetDevicePoolExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_USM_POOL_GET_DEVICE_POOL_EXP, ¶ms); @@ -6536,7 +6618,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolTrimToExp( getContext()->notify_end(UR_FUNCTION_USM_POOL_TRIM_TO_EXP, "urUSMPoolTrimToExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_POOL_TRIM_TO_EXP, ¶ms); @@ -6589,7 +6671,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMPitchedAllocExp( getContext()->notify_end(UR_FUNCTION_USM_PITCHED_ALLOC_EXP, "urUSMPitchedAllocExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_PITCHED_ALLOC_EXP, ¶ms); @@ -6634,7 +6716,7 @@ urBindlessImagesUnsampledImageHandleDestroyExp( "urBindlessImagesUnsampledImageHandleDestroyExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, @@ -6682,7 +6764,7 @@ urBindlessImagesSampledImageHandleDestroyExp( "urBindlessImagesSampledImageHandleDestroyExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_HANDLE_DESTROY_EXP, @@ -6730,7 +6812,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( "urBindlessImagesImageAllocateExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_IMAGE_ALLOCATE_EXP, ¶ms); @@ -6771,7 +6853,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( "urBindlessImagesImageFreeExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_IMAGE_FREE_EXP, ¶ms); @@ -6819,7 +6901,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP, "urBindlessImagesUnsampledImageCreateExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_CREATE_EXP, @@ -6872,7 +6954,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( "urBindlessImagesSampledImageCreateExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_SAMPLED_IMAGE_CREATE_EXP, @@ -6952,7 +7034,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp( "urBindlessImagesImageCopyExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_IMAGE_COPY_EXP, ¶ms); @@ -6998,7 +7080,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( "urBindlessImagesImageGetInfoExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_IMAGE_GET_INFO_EXP, ¶ms); @@ -7044,7 +7126,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( "urBindlessImagesMipmapGetLevelExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_GET_LEVEL_EXP, ¶ms); @@ -7085,7 +7167,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( "urBindlessImagesMipmapFreeExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_MIPMAP_FREE_EXP, ¶ms); @@ -7134,7 +7216,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportExternalMemoryExp( UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_MEMORY_EXP, "urBindlessImagesImportExternalMemoryExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_MEMORY_EXP, @@ -7184,7 +7266,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( "urBindlessImagesMapExternalArrayExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_ARRAY_EXP, ¶ms); @@ -7232,7 +7314,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMapExternalLinearMemoryExp( UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_LINEAR_MEMORY_EXP, "urBindlessImagesMapExternalLinearMemoryExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_LINEAR_MEMORY_EXP, @@ -7276,7 +7358,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseExternalMemoryExp( UR_FUNCTION_BINDLESS_IMAGES_RELEASE_EXTERNAL_MEMORY_EXP, "urBindlessImagesReleaseExternalMemoryExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_RELEASE_EXTERNAL_MEMORY_EXP, @@ -7325,7 +7407,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImportExternalSemaphoreExp( UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_EXP, "urBindlessImagesImportExternalSemaphoreExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_EXP, @@ -7370,7 +7452,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseExternalSemaphoreExp( "urBindlessImagesReleaseExternalSemaphoreExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_RELEASE_EXTERNAL_SEMAPHORE_EXP, @@ -7434,7 +7516,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesWaitExternalSemaphoreExp( UR_FUNCTION_BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP, "urBindlessImagesWaitExternalSemaphoreExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP, @@ -7497,7 +7579,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSignalExternalSemaphoreExp( UR_FUNCTION_BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP, "urBindlessImagesSignalExternalSemaphoreExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP, @@ -7542,7 +7624,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferCreateExp( "urCommandBufferCreateExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_CREATE_EXP, ¶ms); @@ -7577,7 +7659,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferRetainExp( "urCommandBufferRetainExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_RETAIN_EXP, ¶ms); @@ -7612,7 +7694,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferReleaseExp( "urCommandBufferReleaseExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_RELEASE_EXP, ¶ms); @@ -7648,7 +7730,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferFinalizeExp( "urCommandBufferFinalizeExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_FINALIZE_EXP, ¶ms); @@ -7744,7 +7826,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp( "urCommandBufferAppendKernelLaunchExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_KERNEL_LAUNCH_EXP, ¶ms); @@ -7819,7 +7901,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendUSMMemcpyExp( "urCommandBufferAppendUSMMemcpyExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_MEMCPY_EXP, ¶ms); @@ -7897,7 +7979,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendUSMFillExp( "urCommandBufferAppendUSMFillExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_FILL_EXP, ¶ms); @@ -7978,7 +8060,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyExp( UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_COPY_EXP, "urCommandBufferAppendMemBufferCopyExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_COPY_EXP, @@ -8057,7 +8139,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferWriteExp( UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_WRITE_EXP, "urCommandBufferAppendMemBufferWriteExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_WRITE_EXP, @@ -8136,7 +8218,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferReadExp( UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_READ_EXP, "urCommandBufferAppendMemBufferReadExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_READ_EXP, @@ -8231,7 +8313,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyRectExp( UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_COPY_RECT_EXP, "urCommandBufferAppendMemBufferCopyRectExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_COPY_RECT_EXP, @@ -8330,7 +8412,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferWriteRectExp( UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_WRITE_RECT_EXP, "urCommandBufferAppendMemBufferWriteRectExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_WRITE_RECT_EXP, @@ -8428,7 +8510,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferReadRectExp( UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_READ_RECT_EXP, "urCommandBufferAppendMemBufferReadRectExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_READ_RECT_EXP, @@ -8511,7 +8593,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendMemBufferFillExp( UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_FILL_EXP, "urCommandBufferAppendMemBufferFillExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_MEM_BUFFER_FILL_EXP, @@ -8587,7 +8669,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendUSMPrefetchExp( "urCommandBufferAppendUSMPrefetchExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_PREFETCH_EXP, ¶ms); @@ -8662,7 +8744,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendUSMAdviseExp( "urCommandBufferAppendUSMAdviseExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_ADVISE_EXP, ¶ms); @@ -8721,7 +8803,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferAppendNativeCommandExp( "urCommandBufferAppendNativeCommandExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_APPEND_NATIVE_COMMAND_EXP, @@ -8775,7 +8857,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueCommandBufferExp( "urEnqueueCommandBufferExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_COMMAND_BUFFER_EXP, ¶ms); @@ -8819,7 +8901,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferUpdateKernelLaunchExp( "urCommandBufferUpdateKernelLaunchExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_UPDATE_KERNEL_LAUNCH_EXP, ¶ms); @@ -8858,7 +8940,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferUpdateSignalEventExp( "urCommandBufferUpdateSignalEventExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_UPDATE_SIGNAL_EVENT_EXP, ¶ms); @@ -8902,7 +8984,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferUpdateWaitEventsExp( "urCommandBufferUpdateWaitEventsExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_UPDATE_WAIT_EVENTS_EXP, ¶ms); @@ -8948,7 +9030,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferGetInfoExp( "urCommandBufferGetInfoExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_GET_INFO_EXP, ¶ms); @@ -8988,7 +9070,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferGetNativeHandleExp( "urCommandBufferGetNativeHandleExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_COMMAND_BUFFER_GET_NATIVE_HANDLE_EXP, ¶ms); @@ -9064,7 +9146,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueCooperativeKernelLaunchExp( "urEnqueueCooperativeKernelLaunchExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_COOPERATIVE_KERNEL_LAUNCH_EXP, ¶ms); @@ -9122,7 +9204,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSuggestMaxCooperativeGroupCountExp( UR_FUNCTION_KERNEL_SUGGEST_MAX_COOPERATIVE_GROUP_COUNT_EXP, "urKernelSuggestMaxCooperativeGroupCountExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_KERNEL_SUGGEST_MAX_COOPERATIVE_GROUP_COUNT_EXP, @@ -9184,7 +9266,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueTimestampRecordingExp( "urEnqueueTimestampRecordingExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_TIMESTAMP_RECORDING_EXP, ¶ms); @@ -9267,7 +9349,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueKernelLaunchCustomExp( "urEnqueueKernelLaunchCustomExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH_CUSTOM_EXP, ¶ms); @@ -9307,7 +9389,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuildExp( getContext()->notify_end(UR_FUNCTION_PROGRAM_BUILD_EXP, "urProgramBuildExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PROGRAM_BUILD_EXP, ¶ms); @@ -9347,7 +9429,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramCompileExp( getContext()->notify_end(UR_FUNCTION_PROGRAM_COMPILE_EXP, "urProgramCompileExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PROGRAM_COMPILE_EXP, ¶ms); @@ -9398,7 +9480,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramLinkExp( getContext()->notify_end(UR_FUNCTION_PROGRAM_LINK_EXP, "urProgramLinkExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_PROGRAM_LINK_EXP, ¶ms); @@ -9435,7 +9517,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMImportExp( getContext()->notify_end(UR_FUNCTION_USM_IMPORT_EXP, "urUSMImportExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_IMPORT_EXP, ¶ms); @@ -9469,7 +9551,7 @@ __urdlllocal ur_result_t UR_APICALL urUSMReleaseExp( getContext()->notify_end(UR_FUNCTION_USM_RELEASE_EXP, "urUSMReleaseExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams(args_str, UR_FUNCTION_USM_RELEASE_EXP, ¶ms); @@ -9507,7 +9589,7 @@ __urdlllocal ur_result_t UR_APICALL urUsmP2PEnablePeerAccessExp( "urUsmP2PEnablePeerAccessExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_USM_P2P_ENABLE_PEER_ACCESS_EXP, ¶ms); @@ -9546,7 +9628,7 @@ __urdlllocal ur_result_t UR_APICALL urUsmP2PDisablePeerAccessExp( "urUsmP2PDisablePeerAccessExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_USM_P2P_DISABLE_PEER_ACCESS_EXP, ¶ms); @@ -9601,7 +9683,7 @@ __urdlllocal ur_result_t UR_APICALL urUsmP2PPeerAccessGetInfoExp( "urUsmP2PPeerAccessGetInfoExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_USM_P2P_PEER_ACCESS_GET_INFO_EXP, ¶ms); @@ -9653,7 +9735,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueEventsWaitWithBarrierExt( "urEnqueueEventsWaitWithBarrierExt", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_EVENTS_WAIT_WITH_BARRIER_EXT, ¶ms); @@ -9726,7 +9808,7 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueNativeCommandExp( "urEnqueueNativeCommandExp", ¶ms, &result, instance); - if (logger.getLevel() <= logger::Level::INFO) { + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { std::ostringstream args_str; ur::extras::printFunctionParams( args_str, UR_FUNCTION_ENQUEUE_NATIVE_COMMAND_EXP, ¶ms); @@ -9781,6 +9863,42 @@ __urdlllocal ur_result_t UR_APICALL urGetGlobalProcAddrTable( return result; } /////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's Adapter table +/// with current process' addresses +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::UR_RESULT_ERROR_UNSUPPORTED_VERSION +__urdlllocal ur_result_t UR_APICALL urGetAdapterProcAddrTable( + /// [in] API version requested + ur_api_version_t version, + /// [in,out] pointer to table of DDI function pointers + ur_adapter_dditable_t *pDdiTable) { + auto &dditable = ur_tracing_layer::getContext()->urDdiTable.Adapter; + + if (nullptr == pDdiTable) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != + UR_MAJOR_VERSION(version) || + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > + UR_MINOR_VERSION(version)) + return UR_RESULT_ERROR_UNSUPPORTED_VERSION; + + ur_result_t result = UR_RESULT_SUCCESS; + + dditable.pfnSetLoggerCallback = pDdiTable->pfnSetLoggerCallback; + pDdiTable->pfnSetLoggerCallback = + ur_tracing_layer::urAdapterSetLoggerCallback; + + dditable.pfnSetLoggerCallbackLevel = pDdiTable->pfnSetLoggerCallbackLevel; + pDdiTable->pfnSetLoggerCallbackLevel = + ur_tracing_layer::urAdapterSetLoggerCallbackLevel; + + return result; +} +/////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's BindlessImagesExp table /// with current process' addresses /// @@ -11039,6 +11157,11 @@ ur_result_t context_t::init(ur_dditable_t *dditable, &dditable->Global); } + if (UR_RESULT_SUCCESS == result) { + result = ur_tracing_layer::urGetAdapterProcAddrTable(UR_API_VERSION_CURRENT, + &dditable->Adapter); + } + if (UR_RESULT_SUCCESS == result) { result = ur_tracing_layer::urGetBindlessImagesExpProcAddrTable( UR_API_VERSION_CURRENT, &dditable->BindlessImagesExp); diff --git a/unified-runtime/source/loader/layers/validation/ur_valddi.cpp b/unified-runtime/source/loader/layers/validation/ur_valddi.cpp index 07ca8cd3cd92a..73be8d39d9ce3 100644 --- a/unified-runtime/source/loader/layers/validation/ur_valddi.cpp +++ b/unified-runtime/source/loader/layers/validation/ur_valddi.cpp @@ -196,6 +196,78 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGetInfo( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterSetLoggerCallback +__urdlllocal ur_result_t UR_APICALL urAdapterSetLoggerCallback( + /// [in] handle of the adapter + ur_adapter_handle_t hAdapter, + /// [in] Function pointer to callback from the logger. + ur_logger_callback_t pfnLoggerCallback, + /// [in][out][optional] pointer to data to be passed to callback + void *pUserData, + /// [in] logging level + ur_logger_level_t level) { + auto pfnSetLoggerCallback = + getContext()->urDdiTable.Adapter.pfnSetLoggerCallback; + + if (nullptr == pfnSetLoggerCallback) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (getContext()->enableParameterValidation) { + if (NULL == pfnLoggerCallback) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL == hAdapter) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + + if (UR_LOGGER_LEVEL_QUIET < level) + return UR_RESULT_ERROR_INVALID_ENUMERATION; + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(hAdapter)) { + getContext()->refCountContext->logInvalidReference(hAdapter); + } + + ur_result_t result = + pfnSetLoggerCallback(hAdapter, pfnLoggerCallback, pUserData, level); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterSetLoggerCallbackLevel +__urdlllocal ur_result_t UR_APICALL urAdapterSetLoggerCallbackLevel( + /// [in] handle of the adapter + ur_adapter_handle_t hAdapter, + /// [in] logging level + ur_logger_level_t level) { + auto pfnSetLoggerCallbackLevel = + getContext()->urDdiTable.Adapter.pfnSetLoggerCallbackLevel; + + if (nullptr == pfnSetLoggerCallbackLevel) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (getContext()->enableParameterValidation) { + if (NULL == hAdapter) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + + if (UR_LOGGER_LEVEL_QUIET < level) + return UR_RESULT_ERROR_INVALID_ENUMERATION; + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(hAdapter)) { + getContext()->refCountContext->logInvalidReference(hAdapter); + } + + ur_result_t result = pfnSetLoggerCallbackLevel(hAdapter, level); + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urPlatformGet __urdlllocal ur_result_t UR_APICALL urPlatformGet( @@ -10651,6 +10723,43 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGlobalProcAddrTable( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's Adapter table +/// with current process' addresses +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::UR_RESULT_ERROR_UNSUPPORTED_VERSION +UR_DLLEXPORT ur_result_t UR_APICALL urGetAdapterProcAddrTable( + /// [in] API version requested + ur_api_version_t version, + /// [in,out] pointer to table of DDI function pointers + ur_adapter_dditable_t *pDdiTable) { + auto &dditable = ur_validation_layer::getContext()->urDdiTable.Adapter; + + if (nullptr == pDdiTable) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != + UR_MAJOR_VERSION(version) || + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > + UR_MINOR_VERSION(version)) + return UR_RESULT_ERROR_UNSUPPORTED_VERSION; + + ur_result_t result = UR_RESULT_SUCCESS; + + dditable.pfnSetLoggerCallback = pDdiTable->pfnSetLoggerCallback; + pDdiTable->pfnSetLoggerCallback = + ur_validation_layer::urAdapterSetLoggerCallback; + + dditable.pfnSetLoggerCallbackLevel = pDdiTable->pfnSetLoggerCallbackLevel; + pDdiTable->pfnSetLoggerCallbackLevel = + ur_validation_layer::urAdapterSetLoggerCallbackLevel; + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's BindlessImagesExp table /// with current process' addresses @@ -11956,6 +12065,11 @@ ur_result_t context_t::init(ur_dditable_t *dditable, UR_API_VERSION_CURRENT, &dditable->Global); } + if (UR_RESULT_SUCCESS == result) { + result = ur_validation_layer::urGetAdapterProcAddrTable( + UR_API_VERSION_CURRENT, &dditable->Adapter); + } + if (UR_RESULT_SUCCESS == result) { result = ur_validation_layer::urGetBindlessImagesExpProcAddrTable( UR_API_VERSION_CURRENT, &dditable->BindlessImagesExp); diff --git a/unified-runtime/source/loader/loader.def.in b/unified-runtime/source/loader/loader.def.in index b00caf1e8e4ed..7a50a1ed98e1d 100644 --- a/unified-runtime/source/loader/loader.def.in +++ b/unified-runtime/source/loader/loader.def.in @@ -5,6 +5,8 @@ EXPORTS urAdapterGetLastError urAdapterRelease urAdapterRetain + urAdapterSetLoggerCallback + urAdapterSetLoggerCallbackLevel urBindlessImagesImageAllocateExp urBindlessImagesImageCopyExp urBindlessImagesImageFreeExp @@ -105,6 +107,7 @@ EXPORTS urEventRetain urEventSetCallback urEventWait + urGetAdapterProcAddrTable urGetBindlessImagesExpProcAddrTable urGetCommandBufferExpProcAddrTable urGetContextProcAddrTable @@ -179,6 +182,8 @@ EXPORTS urPrintAdapterInfo urPrintAdapterReleaseParams urPrintAdapterRetainParams + urPrintAdapterSetLoggerCallbackLevelParams + urPrintAdapterSetLoggerCallbackParams urPrintApiVersion urPrintBaseDesc urPrintBaseProperties @@ -388,6 +393,7 @@ EXPORTS urPrintLoaderConfigSetMockingEnabledParams urPrintLoaderInitParams urPrintLoaderTearDownParams + urPrintLoggerLevel urPrintMapFlags urPrintMemBufferCreateParams urPrintMemBufferCreateWithNativeHandleParams diff --git a/unified-runtime/source/loader/loader.map.in b/unified-runtime/source/loader/loader.map.in index b735d66a07602..f01263532eb8f 100644 --- a/unified-runtime/source/loader/loader.map.in +++ b/unified-runtime/source/loader/loader.map.in @@ -5,6 +5,8 @@ urAdapterGetLastError; urAdapterRelease; urAdapterRetain; + urAdapterSetLoggerCallback; + urAdapterSetLoggerCallbackLevel; urBindlessImagesImageAllocateExp; urBindlessImagesImageCopyExp; urBindlessImagesImageFreeExp; @@ -105,6 +107,7 @@ urEventRetain; urEventSetCallback; urEventWait; + urGetAdapterProcAddrTable; urGetBindlessImagesExpProcAddrTable; urGetCommandBufferExpProcAddrTable; urGetContextProcAddrTable; @@ -179,6 +182,8 @@ urPrintAdapterInfo; urPrintAdapterReleaseParams; urPrintAdapterRetainParams; + urPrintAdapterSetLoggerCallbackLevelParams; + urPrintAdapterSetLoggerCallbackParams; urPrintApiVersion; urPrintBaseDesc; urPrintBaseProperties; @@ -388,6 +393,7 @@ urPrintLoaderConfigSetMockingEnabledParams; urPrintLoaderInitParams; urPrintLoaderTearDownParams; + urPrintLoggerLevel; urPrintMapFlags; urPrintMemBufferCreateParams; urPrintMemBufferCreateWithNativeHandleParams; diff --git a/unified-runtime/source/loader/ur_ldrddi.cpp b/unified-runtime/source/loader/ur_ldrddi.cpp index 519a4b89e5d37..23fa016df8c4a 100644 --- a/unified-runtime/source/loader/ur_ldrddi.cpp +++ b/unified-runtime/source/loader/ur_ldrddi.cpp @@ -186,6 +186,63 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGetInfo( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterSetLoggerCallback +__urdlllocal ur_result_t UR_APICALL urAdapterSetLoggerCallback( + /// [in] handle of the adapter + ur_adapter_handle_t hAdapter, + /// [in] Function pointer to callback from the logger. + ur_logger_callback_t pfnLoggerCallback, + /// [in][out][optional] pointer to data to be passed to callback + void *pUserData, + /// [in] logging level + ur_logger_level_t level) { + ur_result_t result = UR_RESULT_SUCCESS; + + [[maybe_unused]] auto context = getContext(); + + // extract platform's function pointer table + auto dditable = reinterpret_cast(hAdapter)->dditable; + auto pfnSetLoggerCallback = dditable->ur.Adapter.pfnSetLoggerCallback; + if (nullptr == pfnSetLoggerCallback) + return UR_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to platform handle + hAdapter = reinterpret_cast(hAdapter)->handle; + + // forward to device-platform + result = pfnSetLoggerCallback(hAdapter, pfnLoggerCallback, pUserData, level); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urAdapterSetLoggerCallbackLevel +__urdlllocal ur_result_t UR_APICALL urAdapterSetLoggerCallbackLevel( + /// [in] handle of the adapter + ur_adapter_handle_t hAdapter, + /// [in] logging level + ur_logger_level_t level) { + ur_result_t result = UR_RESULT_SUCCESS; + + [[maybe_unused]] auto context = getContext(); + + // extract platform's function pointer table + auto dditable = reinterpret_cast(hAdapter)->dditable; + auto pfnSetLoggerCallbackLevel = + dditable->ur.Adapter.pfnSetLoggerCallbackLevel; + if (nullptr == pfnSetLoggerCallbackLevel) + return UR_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to platform handle + hAdapter = reinterpret_cast(hAdapter)->handle; + + // forward to device-platform + result = pfnSetLoggerCallbackLevel(hAdapter, level); + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urPlatformGet __urdlllocal ur_result_t UR_APICALL urPlatformGet( @@ -9979,6 +10036,61 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGlobalProcAddrTable( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's Adapter table +/// with current process' addresses +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::UR_RESULT_ERROR_UNSUPPORTED_VERSION +UR_DLLEXPORT ur_result_t UR_APICALL urGetAdapterProcAddrTable( + /// [in] API version requested + ur_api_version_t version, + /// [in,out] pointer to table of DDI function pointers + ur_adapter_dditable_t *pDdiTable) { + if (nullptr == pDdiTable) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (ur_loader::getContext()->version < version) + return UR_RESULT_ERROR_UNSUPPORTED_VERSION; + + ur_result_t result = UR_RESULT_SUCCESS; + + // Load the device-platform DDI tables + for (auto &platform : ur_loader::getContext()->platforms) { + // statically linked adapter inside of the loader + if (platform.handle == nullptr) + continue; + + if (platform.initStatus != UR_RESULT_SUCCESS) + continue; + auto getTable = reinterpret_cast( + ur_loader::LibLoader::getFunctionPtr(platform.handle.get(), + "urGetAdapterProcAddrTable")); + if (!getTable) + continue; + platform.initStatus = getTable(version, &platform.dditable.ur.Adapter); + } + + if (UR_RESULT_SUCCESS == result) { + if (ur_loader::getContext()->platforms.size() != 1 || + ur_loader::getContext()->forceIntercept) { + // return pointers to loader's DDIs + pDdiTable->pfnSetLoggerCallback = ur_loader::urAdapterSetLoggerCallback; + pDdiTable->pfnSetLoggerCallbackLevel = + ur_loader::urAdapterSetLoggerCallbackLevel; + } else { + // return pointers directly to platform's DDIs + *pDdiTable = + ur_loader::getContext()->platforms.front().dditable.ur.Adapter; + } + } + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's BindlessImagesExp table /// with current process' addresses diff --git a/unified-runtime/source/loader/ur_libapi.cpp b/unified-runtime/source/loader/ur_libapi.cpp index a69ef8f785386..966d26a4d8e56 100644 --- a/unified-runtime/source/loader/ur_libapi.cpp +++ b/unified-runtime/source/loader/ur_libapi.cpp @@ -484,6 +484,69 @@ ur_result_t UR_APICALL urAdapterGetInfo( return exceptionToResult(std::current_exception()); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Set a callback function for use by the logger to retrieve logging +/// output. +/// It is a requirement that the callback function is thread safe and the +/// creator of the function will be responsible for this. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hAdapter` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pfnLoggerCallback` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_LOGGER_LEVEL_QUIET < level` +ur_result_t UR_APICALL urAdapterSetLoggerCallback( + /// [in] handle of the adapter + ur_adapter_handle_t hAdapter, + /// [in] Function pointer to callback from the logger. + ur_logger_callback_t pfnLoggerCallback, + /// [in][out][optional] pointer to data to be passed to callback + void *pUserData, + /// [in] logging level + ur_logger_level_t level) try { + auto pfnSetLoggerCallback = + ur_lib::getContext()->urDdiTable.Adapter.pfnSetLoggerCallback; + if (nullptr == pfnSetLoggerCallback) + return UR_RESULT_ERROR_UNINITIALIZED; + + return pfnSetLoggerCallback(hAdapter, pfnLoggerCallback, pUserData, level); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Set the minimum logging level for the logger Callback function. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hAdapter` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_LOGGER_LEVEL_QUIET < level` +ur_result_t UR_APICALL urAdapterSetLoggerCallbackLevel( + /// [in] handle of the adapter + ur_adapter_handle_t hAdapter, + /// [in] logging level + ur_logger_level_t level) try { + auto pfnSetLoggerCallbackLevel = + ur_lib::getContext()->urDdiTable.Adapter.pfnSetLoggerCallbackLevel; + if (nullptr == pfnSetLoggerCallbackLevel) + return UR_RESULT_ERROR_UNINITIALIZED; + + return pfnSetLoggerCallbackLevel(hAdapter, level); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Retrieves all available platforms for the given adapters /// diff --git a/unified-runtime/source/loader/ur_libddi.cpp b/unified-runtime/source/loader/ur_libddi.cpp index c3e9b613ae359..085aca70c50b3 100644 --- a/unified-runtime/source/loader/ur_libddi.cpp +++ b/unified-runtime/source/loader/ur_libddi.cpp @@ -27,6 +27,11 @@ __urdlllocal ur_result_t context_t::ddiInit() { urGetGlobalProcAddrTable(UR_API_VERSION_CURRENT, &urDdiTable.Global); } + if (UR_RESULT_SUCCESS == result) { + result = + urGetAdapterProcAddrTable(UR_API_VERSION_CURRENT, &urDdiTable.Adapter); + } + if (UR_RESULT_SUCCESS == result) { result = urGetBindlessImagesExpProcAddrTable(UR_API_VERSION_CURRENT, &urDdiTable.BindlessImagesExp); diff --git a/unified-runtime/source/loader/ur_print.cpp b/unified-runtime/source/loader/ur_print.cpp index 9748ee552995b..bf64377f0255e 100644 --- a/unified-runtime/source/loader/ur_print.cpp +++ b/unified-runtime/source/loader/ur_print.cpp @@ -130,6 +130,13 @@ ur_result_t urPrintAdapterBackend(enum ur_adapter_backend_t value, char *buffer, return str_copy(&ss, buffer, buff_size, out_size); } +ur_result_t urPrintLoggerLevel(enum ur_logger_level_t value, char *buffer, + const size_t buff_size, size_t *out_size) { + std::stringstream ss; + ss << value; + return str_copy(&ss, buffer, buff_size, out_size); +} + ur_result_t urPrintPlatformInfo(enum ur_platform_info_t value, char *buffer, const size_t buff_size, size_t *out_size) { std::stringstream ss; @@ -1198,6 +1205,22 @@ urPrintAdapterGetInfoParams(const struct ur_adapter_get_info_params_t *params, return str_copy(&ss, buffer, buff_size, out_size); } +ur_result_t urPrintAdapterSetLoggerCallbackParams( + const struct ur_adapter_set_logger_callback_params_t *params, char *buffer, + const size_t buff_size, size_t *out_size) { + std::stringstream ss; + ss << params; + return str_copy(&ss, buffer, buff_size, out_size); +} + +ur_result_t urPrintAdapterSetLoggerCallbackLevelParams( + const struct ur_adapter_set_logger_callback_level_params_t *params, + char *buffer, const size_t buff_size, size_t *out_size) { + std::stringstream ss; + ss << params; + return str_copy(&ss, buffer, buff_size, out_size); +} + ur_result_t urPrintBindlessImagesUnsampledImageHandleDestroyExpParams( const struct ur_bindless_images_unsampled_image_handle_destroy_exp_params_t *params, diff --git a/unified-runtime/source/ur_api.cpp b/unified-runtime/source/ur_api.cpp index a71d65ae64630..5c43596dae3f1 100644 --- a/unified-runtime/source/ur_api.cpp +++ b/unified-runtime/source/ur_api.cpp @@ -441,6 +441,57 @@ ur_result_t UR_APICALL urAdapterGetInfo( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Set a callback function for use by the logger to retrieve logging +/// output. +/// It is a requirement that the callback function is thread safe and the +/// creator of the function will be responsible for this. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hAdapter` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pfnLoggerCallback` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_LOGGER_LEVEL_QUIET < level` +ur_result_t UR_APICALL urAdapterSetLoggerCallback( + /// [in] handle of the adapter + ur_adapter_handle_t hAdapter, + /// [in] Function pointer to callback from the logger. + ur_logger_callback_t pfnLoggerCallback, + /// [in][out][optional] pointer to data to be passed to callback + void *pUserData, + /// [in] logging level + ur_logger_level_t level) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Set the minimum logging level for the logger Callback function. +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hAdapter` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_LOGGER_LEVEL_QUIET < level` +ur_result_t UR_APICALL urAdapterSetLoggerCallbackLevel( + /// [in] handle of the adapter + ur_adapter_handle_t hAdapter, + /// [in] logging level + ur_logger_level_t level) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Retrieves all available platforms for the given adapters /// diff --git a/unified-runtime/test/layers/sanitizer/sanitizer_options.cpp b/unified-runtime/test/layers/sanitizer/sanitizer_options.cpp index f08dd56f5001f..50b25ec641909 100644 --- a/unified-runtime/test/layers/sanitizer/sanitizer_options.cpp +++ b/unified-runtime/test/layers/sanitizer/sanitizer_options.cpp @@ -30,7 +30,7 @@ struct OptionParserTest : public ::testing::Test { OptionParserTest() : Logger(logger::create_logger("OptionParser", false, false, - logger::Level::DEBUG)), + UR_LOGGER_LEVEL_DEBUG)), Parser(EnvMap, Logger) {} }; @@ -122,7 +122,7 @@ struct SanitizerOptionsTest : public ::testing::Test { SanitizerOptionsTest() : Logger(logger::create_logger("SanitizerOptions", false, false, - logger::Level::DEBUG)) {} + UR_LOGGER_LEVEL_DEBUG)) {} void SetEnvAndInit(const std::string &Value) { setenv(EnvName.c_str(), Value.c_str(), 1); diff --git a/unified-runtime/test/logger/fixtures.hpp b/unified-runtime/test/logger/fixtures.hpp index 0cff38284fa56..af1a3dad43568 100644 --- a/unified-runtime/test/logger/fixtures.hpp +++ b/unified-runtime/test/logger/fixtures.hpp @@ -92,9 +92,20 @@ class DefaultLoggerWithFileSink : public UniquePtrLoggerWithFilesink { protected: void SetUp() override { logger = std::make_unique( - logger::Level::WARN, + UR_LOGGER_LEVEL_WARN, std::make_unique(logger_name, file_path)); } }; +class LoggerWithCallbackSink : public ::testing::Test { +protected: + std::unique_ptr logger; + + void SetUp() override { + logger = std::make_unique( + UR_LOGGER_LEVEL_QUIET, nullptr, UR_LOGGER_LEVEL_WARN, + std::make_unique("UR_LOG_CALLBACK")); + } +}; + #endif // UR_UNIT_LOGGER_TEST_FIXTURES_HPP diff --git a/unified-runtime/test/unit/logger.cpp b/unified-runtime/test/unit/logger.cpp index bbeacaa845af7..9e6176f40ae9e 100644 --- a/unified-runtime/test/unit/logger.cpp +++ b/unified-runtime/test/unit/logger.cpp @@ -10,6 +10,7 @@ #include "../fixtures.hpp" #include "logger/ur_logger_details.hpp" +#include "ur_api.h" ////////////////////////////////////////////////////////////////////////////// TEST_F(DefaultLoggerWithFileSink, DefaultLevelNoOutput) { @@ -52,7 +53,7 @@ TEST_F(DefaultLoggerWithFileSink, NoBraces) { } TEST_F(DefaultLoggerWithFileSink, SetLevelDebug) { - auto level = logger::Level::DEBUG; + auto level = UR_LOGGER_LEVEL_DEBUG; logger->setLevel(level); logger->setFlushLevel(level); logger->debug("Test message: {}", "success"); @@ -61,7 +62,7 @@ TEST_F(DefaultLoggerWithFileSink, SetLevelDebug) { } TEST_F(DefaultLoggerWithFileSink, SetLevelInfo) { - auto level = logger::Level::INFO; + auto level = UR_LOGGER_LEVEL_INFO; logger->setLevel(level); logger->setFlushLevel(level); logger->info("Test message: {}", "success"); @@ -71,7 +72,7 @@ TEST_F(DefaultLoggerWithFileSink, SetLevelInfo) { } TEST_F(DefaultLoggerWithFileSink, SetLevelWarning) { - auto level = logger::Level::WARN; + auto level = UR_LOGGER_LEVEL_WARN; logger->setLevel(level); logger->warning("Test message: {}", "success"); logger->info("This should not be printed: {}", 42); @@ -80,7 +81,7 @@ TEST_F(DefaultLoggerWithFileSink, SetLevelWarning) { } TEST_F(DefaultLoggerWithFileSink, SetLevelError) { - logger->setLevel(logger::Level::ERR); + logger->setLevel(UR_LOGGER_LEVEL_ERROR); logger->error("Test message: {}", "success"); logger->warning("This should not be printed: {}", 42); @@ -89,7 +90,7 @@ TEST_F(DefaultLoggerWithFileSink, SetLevelError) { ////////////////////////////////////////////////////////////////////////////// TEST_F(UniquePtrLoggerWithFilesink, SetLogLevelAndFlushLevelDebugWithCtor) { - auto level = logger::Level::DEBUG; + auto level = UR_LOGGER_LEVEL_DEBUG; logger = std::make_unique( level, std::make_unique(logger_name, file_path, level)); @@ -106,15 +107,15 @@ TEST_F(UniquePtrLoggerWithFilesink, NestedFilePath) { filesystem::create_directories(file_path); file_path /= file_name; logger = std::make_unique( - logger::Level::WARN, std::make_unique( - logger_name, file_path, logger::Level::WARN)); + UR_LOGGER_LEVEL_WARN, std::make_unique( + logger_name, file_path, UR_LOGGER_LEVEL_WARN)); logger->warning("Test message: {}", "success"); test_msg << test_msg_prefix << "[WARNING]: Test message: success\n"; } TEST_F(UniquePtrLoggerWithFilesinkFail, NullSink) { - logger = std::make_unique(logger::Level::INFO, nullptr); + logger = std::make_unique(UR_LOGGER_LEVEL_INFO, nullptr); logger->info("This should not be printed: {}", 42); test_msg.clear(); } @@ -128,7 +129,7 @@ INSTANTIATE_TEST_SUITE_P( TEST_P(FileSinkLoggerMultipleThreads, Multithreaded) { std::vector threads; auto local_logger = logger::Logger( - logger::Level::WARN, + UR_LOGGER_LEVEL_WARN, std::make_unique(logger_name, file_path, true)); constexpr int message_count = 50; @@ -174,7 +175,7 @@ INSTANTIATE_TEST_SUITE_P( TEST_P(CommonLoggerWithMultipleThreads, StdoutMultithreaded) { std::vector threads; auto local_logger = logger::Logger( - logger::Level::WARN, std::make_unique("test", true)); + UR_LOGGER_LEVEL_WARN, std::make_unique("test", true)); constexpr int message_count = 50; // Messages below the flush level @@ -204,3 +205,65 @@ TEST_P(CommonLoggerWithMultipleThreads, StdoutMultithreaded) { thread.join(); } } + +////////////////////////////////////////////////////////////////////////////// +void receiveLoggerMessages([[maybe_unused]] ur_logger_level_t level, + const char *msg, void *userData) { + std::string *str = static_cast(userData); + *str = msg; +} + +TEST_F(LoggerWithCallbackSink, CallbackSinkTest) { + // Pass a callback function to the logger which will be used as an additional + // destination sink and any logged messages will be sent to the callback + // function + std::string callback_message; + logger->setCallbackSink(receiveLoggerMessages, &callback_message, + UR_LOGGER_LEVEL_ERROR); + + logger->error("Test message: {}", "success"); + + ASSERT_STREQ(callback_message.c_str(), + "[ERROR]: Test message: success\n"); +} + +TEST_F(LoggerWithCallbackSink, CallbackSinkSetLevel) { + // Set log level to DEBUG and confirm a DEBUG message is received + std::string callback_message; + logger->setCallbackSink(receiveLoggerMessages, &callback_message, + UR_LOGGER_LEVEL_DEBUG); + + logger->debug("Test message: {}", "success"); + ASSERT_STREQ(callback_message.c_str(), + "[DEBUG]: Test message: success\n"); + + // Set level to WARN and confirm a DEBUG message is not received + logger->setCallbackLevel(UR_LOGGER_LEVEL_WARN); + callback_message.clear(); + logger->debug("Test message: {}", "success"); + ASSERT_STREQ(callback_message.c_str(), ""); + + // While level is DEBUG confirm a ERR message is received + callback_message.clear(); + logger->error("Test message: {}", "success"); + ASSERT_STREQ(callback_message.c_str(), + "[ERROR]: Test message: success\n"); + + // Set level to QUIET and confirm no log levels are received + logger->setCallbackLevel(UR_LOGGER_LEVEL_QUIET); + callback_message.clear(); + logger->debug("Test message: {}", "success"); + ASSERT_STREQ(callback_message.c_str(), ""); + + callback_message.clear(); + logger->info("Test message: {}", "success"); + ASSERT_STREQ(callback_message.c_str(), ""); + + callback_message.clear(); + logger->warn("Test message: {}", "success"); + ASSERT_STREQ(callback_message.c_str(), ""); + + callback_message.clear(); + logger->error("Test message: {}", "success"); + ASSERT_STREQ(callback_message.c_str(), ""); +}