From db498898467edb123a2f12229165b9a319b52527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20=C5=9Alusarczyk?= Date: Wed, 29 Jan 2025 12:26:05 +0100 Subject: [PATCH] added filename and line number to logs --- source/CMakeLists.txt | 2 + source/adapters/cuda/command_buffer.hpp | 4 +- source/adapters/cuda/common.cpp | 6 +- source/adapters/cuda/device.cpp | 2 +- source/adapters/cuda/image.cpp | 4 +- source/adapters/hip/common.cpp | 8 +- source/adapters/hip/device.cpp | 2 +- source/adapters/level_zero/adapter.cpp | 41 +++--- source/adapters/level_zero/command_buffer.cpp | 24 ++-- source/adapters/level_zero/common.cpp | 8 +- source/adapters/level_zero/common.hpp | 8 +- source/adapters/level_zero/context.cpp | 40 +++--- source/adapters/level_zero/device.cpp | 26 ++-- source/adapters/level_zero/event.cpp | 13 +- .../level_zero/helpers/kernel_helpers.cpp | 26 ++-- source/adapters/level_zero/image.cpp | 120 +++++++++--------- source/adapters/level_zero/kernel.cpp | 59 ++++----- source/adapters/level_zero/memory.cpp | 48 +++---- source/adapters/level_zero/platform.cpp | 2 +- source/adapters/level_zero/program.cpp | 8 +- source/adapters/level_zero/queue.cpp | 76 ++++++----- source/adapters/level_zero/sampler.cpp | 9 +- source/adapters/level_zero/usm.cpp | 8 +- .../adapters/level_zero/v2/command_buffer.cpp | 6 +- .../level_zero/v2/command_list_cache.cpp | 16 +-- source/adapters/level_zero/v2/event.cpp | 7 +- .../level_zero/v2/event_provider_normal.cpp | 2 +- source/adapters/level_zero/v2/kernel.cpp | 12 +- source/adapters/level_zero/v2/memory.cpp | 6 +- .../v2/queue_immediate_in_order.cpp | 7 +- source/adapters/level_zero/v2/usm.cpp | 6 +- source/adapters/level_zero/virtual_mem.cpp | 8 +- source/adapters/native_cpu/common.cpp | 2 +- source/adapters/native_cpu/common.hpp | 12 +- source/adapters/native_cpu/device.cpp | 2 +- source/adapters/native_cpu/platform.cpp | 2 +- source/adapters/opencl/common.cpp | 2 +- source/common/latency_tracker.hpp | 6 +- source/common/linux/ur_lib_loader.cpp | 24 ++-- source/common/logger/ur_logger.hpp | 16 +++ source/common/umf_helpers.hpp | 2 +- source/common/ur_pool_manager.hpp | 5 +- source/common/ur_util.cpp | 6 +- source/common/windows/ur_lib_loader.cpp | 13 +- source/loader/ur_adapter_registry.hpp | 83 ++++++------ source/loader/ur_lib.cpp | 86 ++++++------- test/unit/logger/env_var.cpp | 8 +- 47 files changed, 462 insertions(+), 421 deletions(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index f0dd315313..cbcbe36adc 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -5,6 +5,8 @@ add_definitions(-DUR_VERSION="${PROJECT_VERSION_MAJOR}") add_definitions(-DUR_VALIDATION_LAYER_SUPPORTED_VERSION="${PROJECT_VERSION_MAJOR}") +string(LENGTH "${CMAKE_SOURCE_DIR}/" SRC_PATH_SIZE) +add_definitions("-DSRC_PATH_SIZE=${SRC_PATH_SIZE}") # for nicer log messages add_subdirectory(common) add_subdirectory(loader) diff --git a/source/adapters/cuda/command_buffer.hpp b/source/adapters/cuda/command_buffer.hpp index 97d809e5a3..6ce85f9aa9 100644 --- a/source/adapters/cuda/command_buffer.hpp +++ b/source/adapters/cuda/command_buffer.hpp @@ -29,10 +29,10 @@ #define UR_CALL(Call, Result) \ { \ if (PrintTrace) \ - logger::always("UR ---> {}", #Call); \ + URLOG_ALWAYS("UR ---> {}", #Call); \ Result = (Call); \ if (PrintTrace) \ - logger::always("UR <--- {}({})", #Call, Result); \ + URLOG_ALWAYS("UR <--- {}({})", #Call, Result); \ } enum class CommandType { diff --git a/source/adapters/cuda/common.cpp b/source/adapters/cuda/common.cpp index 89500d1a1c..9d5ded1a63 100644 --- a/source/adapters/cuda/common.cpp +++ b/source/adapters/cuda/common.cpp @@ -53,7 +53,7 @@ void checkErrorUR(CUresult Result, const char *Function, int Line, << "\n\tDescription: " << ErrorString << "\n\tFunction: " << Function << "\n\tSource Location: " << File << ":" << Line << "\n"; - logger::error("{}", SS.str()); + URLOG(ERR, "{}", SS.str()); if (std::getenv("PI_CUDA_ABORT") != nullptr || std::getenv("UR_CUDA_ABORT") != nullptr) { @@ -73,7 +73,7 @@ void checkErrorUR(ur_result_t Result, const char *Function, int Line, SS << "\nUR ERROR:" << "\n\tValue: " << Result << "\n\tFunction: " << Function << "\n\tSource Location: " << File << ":" << Line << "\n"; - logger::error("{}", SS.str()); + URLOG(ERR, "{}", SS.str()); if (std::getenv("PI_CUDA_ABORT") != nullptr) { std::abort(); @@ -93,7 +93,7 @@ std::string getCudaVersionString() { } void detail::ur::die(const char *Message) { - logger::always("ur_die:{}", Message); + URLOG_ALWAYS("ur_die:{}", Message); std::terminate(); } diff --git a/source/adapters/cuda/device.cpp b/source/adapters/cuda/device.cpp index 3e0ce05c27..14b9388ae9 100644 --- a/source/adapters/cuda/device.cpp +++ b/source/adapters/cuda/device.cpp @@ -290,7 +290,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, std::getenv("UR_CUDA_ENABLE_IMAGE_SUPPORT") != nullptr) { Enabled = true; } else { - logger::always( + URLOG_ALWAYS( "Images are not fully supported by the CUDA BE, their support is " "disabled by default. Their partial support can be activated by " "setting UR_CUDA_ENABLE_IMAGE_SUPPORT environment variable at " diff --git a/source/adapters/cuda/image.cpp b/source/adapters/cuda/image.cpp index 87570e3b45..036a969935 100644 --- a/source/adapters/cuda/image.cpp +++ b/source/adapters/cuda/image.cpp @@ -801,8 +801,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp( // we don't support copying between different image types. if (pSrcImageDesc->type != pDstImageDesc->type) { - logger::error( - "Unsupported copy operation between different type of images"); + URLOG(ERR, + "Unsupported copy operation between different type of images"); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } diff --git a/source/adapters/hip/common.cpp b/source/adapters/hip/common.cpp index 23ef1d3301..f8f23241fc 100644 --- a/source/adapters/hip/common.cpp +++ b/source/adapters/hip/common.cpp @@ -82,7 +82,7 @@ void checkErrorUR(amd_comgr_status_t Result, const char *Function, int Line, << "\n\tDescription: " << ErrorString << "\n\tFunction: " << Function << "\n\tSource Location: " << File << ":" << Line << "\n"; - logger::error("{}", SS.str()); + URLOG(ERR, "{}", SS.str()); if (std::getenv("PI_HIP_ABORT") != nullptr || std::getenv("UR_HIP_ABORT") != nullptr) { @@ -109,7 +109,7 @@ void checkErrorUR(hipError_t Result, const char *Function, int Line, << "\n\tDescription: " << ErrorString << "\n\tFunction: " << Function << "\n\tSource Location: " << File << ":" << Line << "\n"; - logger::error("{}", SS.str()); + URLOG(ERR, "{}", SS.str()); if (std::getenv("PI_HIP_ABORT") != nullptr || std::getenv("UR_HIP_ABORT") != nullptr) { @@ -129,7 +129,7 @@ void checkErrorUR(ur_result_t Result, const char *Function, int Line, SS << "\nUR HIP ERROR:" << "\n\tValue: " << Result << "\n\tFunction: " << Function << "\n\tSource Location: " << File << ":" << Line << "\n"; - logger::error("{}", SS.str()); + URLOG(ERR, "{}", SS.str()); if (std::getenv("PI_HIP_ABORT") != nullptr || std::getenv("UR_HIP_ABORT") != nullptr) { @@ -153,7 +153,7 @@ hipError_t getHipVersionString(std::string &Version) { } void detail::ur::die(const char *pMessage) { - logger::always("ur_die: {}", pMessage); + URLOG_ALWAYS("ur_die: {}", pMessage); std::terminate(); } diff --git a/source/adapters/hip/device.cpp b/source/adapters/hip/device.cpp index a472648793..9233a70577 100644 --- a/source/adapters/hip/device.cpp +++ b/source/adapters/hip/device.cpp @@ -230,7 +230,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, if (std::getenv("UR_HIP_ENABLE_IMAGE_SUPPORT") != nullptr) { Enabled = true; } else { - logger::always( + URLOG_ALWAYS( "Images are not fully supported by the HIP BE, their support is " "disabled by default. Their partial support can be activated by " "setting UR_HIP_ENABLE_IMAGE_SUPPORT environment variable at " diff --git a/source/adapters/level_zero/adapter.cpp b/source/adapters/level_zero/adapter.cpp index 88b9458242..9dee29f797 100644 --- a/source/adapters/level_zero/adapter.cpp +++ b/source/adapters/level_zero/adapter.cpp @@ -163,7 +163,7 @@ ur_result_t initPlatforms(PlatformVec &platforms, ZE2UR_CALL(zeDriverGet, (&ZeDriverGetCount, ZeDriverGetHandles.data())); } if (ZeDriverGetCount == 0 && GlobalAdapter->ZeInitDriversCount == 0) { - logger::error("\nNo Valid L0 Drivers found.\n"); + URLOG(ERR, "\nNo Valid L0 Drivers found.\n"); return UR_RESULT_SUCCESS; } @@ -188,9 +188,10 @@ ur_result_t initPlatforms(PlatformVec &platforms, // newer drivers. if (ZeDriverGetProperties.driverVersion != ZeInitDriverProperties.driverVersion) { - logger::debug("\nzeDriverHandle {} added to the zeInitDrivers list " - "of possible handles.\n", - ZeDriverGetHandles[Y]); + URLOG(DEBUG, + "\nzeDriverHandle {} added to the zeInitDrivers list " + "of possible handles.\n", + ZeDriverGetHandles[Y]); ZeDrivers.push_back(ZeDriverGetHandles[Y]); } } @@ -201,7 +202,7 @@ ur_result_t initPlatforms(PlatformVec &platforms, ZeDrivers.assign(ZeDriverGetHandles.begin(), ZeDriverGetHandles.end()); } ZeDriverCount = ZeDrivers.size(); - logger::debug("\n{} L0 Drivers found.\n", ZeDriverCount); + URLOG(DEBUG, "\n{} L0 Drivers found.\n", ZeDriverCount); for (uint32_t I = 0; I < ZeDriverCount; ++I) { // Keep track of the first platform init for this Driver bool DriverPlatformInit = false; @@ -351,8 +352,8 @@ ur_adapter_handle_t_::ur_adapter_handle_t_() } if (getenv("SYCL_ENABLE_PCI") != nullptr) { - logger::warning( - "WARNING: SYCL_ENABLE_PCI is deprecated and no longer needed.\n"); + URLOG(WARN, + "WARNING: SYCL_ENABLE_PCI is deprecated and no longer needed.\n"); } // TODO: We can still safely recover if something goes wrong during the @@ -373,13 +374,13 @@ ur_adapter_handle_t_::ur_adapter_handle_t_() if (UrL0InitAllDrivers) { L0InitFlags |= ZE_INIT_FLAG_VPU_ONLY; } - logger::debug("\nzeInit with flags value of {}\n", - static_cast(L0InitFlags)); + URLOG(DEBUG, "\nzeInit with flags value of {}\n", + static_cast(L0InitFlags)); GlobalAdapter->ZeInitResult = ZE_CALL_NOCHECK(zeInit, (L0InitFlags)); if (GlobalAdapter->ZeInitResult != ZE_RESULT_SUCCESS) { const char *ErrorString = "Unknown"; zeParseError(GlobalAdapter->ZeInitResult, ErrorString); - logger::error("\nzeInit failed with {}\n", ErrorString); + URLOG(ERR, "\nzeInit failed with {}\n", ErrorString); } bool useInitDrivers = false; @@ -395,9 +396,9 @@ ur_adapter_handle_t_::ur_adapter_handle_t_() if (strncmp(versions[i].component_name, "loader", strlen("loader")) == 0) { loader_version = versions[i].component_lib_version; - logger::debug("\nLevel Zero Loader Version: {}.{}.{}\n", - loader_version.major, loader_version.minor, - loader_version.patch); + URLOG(DEBUG, "\nLevel Zero Loader Version: {}.{}.{}\n", + loader_version.major, loader_version.minor, + loader_version.patch); break; } } @@ -416,8 +417,8 @@ ur_adapter_handle_t_::ur_adapter_handle_t_() (ze_pfnInitDrivers_t)ur_loader::LibLoader::getFunctionPtr( processHandle, "zeInitDrivers"); if (GlobalAdapter->initDriversFunctionPtr) { - logger::debug("\nzeInitDrivers with flags value of {}\n", - static_cast(GlobalAdapter->InitDriversDesc.flags)); + URLOG(DEBUG, "\nzeInitDrivers with flags value of {}\n", + static_cast(GlobalAdapter->InitDriversDesc.flags)); GlobalAdapter->ZeInitDriversResult = ZE_CALL_NOCHECK(GlobalAdapter->initDriversFunctionPtr, (&GlobalAdapter->ZeInitDriversCount, nullptr, @@ -427,7 +428,7 @@ ur_adapter_handle_t_::ur_adapter_handle_t_() } else { const char *ErrorString = "Unknown"; zeParseError(GlobalAdapter->ZeInitDriversResult, ErrorString); - logger::error("\nzeInitDrivers failed with {}\n", ErrorString); + URLOG(ERR, "\nzeInitDrivers failed with {}\n", ErrorString); } } } @@ -445,12 +446,12 @@ ur_adapter_handle_t_::ur_adapter_handle_t_() // Absorb the ZE_RESULT_ERROR_UNINITIALIZED and just return 0 Platforms. if (*GlobalAdapter->ZeResult == ZE_RESULT_ERROR_UNINITIALIZED) { - logger::error("Level Zero Uninitialized\n"); + URLOG(ERR, "Level Zero Uninitialized\n"); result = std::move(platforms); return; } if (*GlobalAdapter->ZeResult != ZE_RESULT_SUCCESS) { - logger::error("Level Zero initialization failure\n"); + URLOG(ERR, "Level Zero initialization failure\n"); result = ze2urResult(*GlobalAdapter->ZeResult); return; @@ -499,8 +500,8 @@ ur_adapter_handle_t_::ur_adapter_handle_t_() GlobalAdapter->getSysManDriversFunctionPtr && GlobalAdapter->sysManInitFunctionPtr) { ze_init_flags_t L0ZesInitFlags = 0; - logger::debug("\nzesInit with flags value of {}\n", - static_cast(L0ZesInitFlags)); + URLOG(DEBUG, "\nzesInit with flags value of {}\n", + static_cast(L0ZesInitFlags)); GlobalAdapter->ZesResult = ZE_CALL_NOCHECK( GlobalAdapter->sysManInitFunctionPtr, (L0ZesInitFlags)); } else { diff --git a/source/adapters/level_zero/command_buffer.cpp b/source/adapters/level_zero/command_buffer.cpp index 879ee0f1cc..2a91469bb3 100644 --- a/source/adapters/level_zero/command_buffer.cpp +++ b/source/adapters/level_zero/command_buffer.cpp @@ -18,7 +18,7 @@ */ // Print the name of a variable and its value in the L0 debug log -#define DEBUG_LOG(VAR) logger::debug(#VAR " {}", VAR); +#define DEBUG_LOG(VAR) URLOG(DEBUG, #VAR " {}", VAR); namespace { @@ -44,17 +44,19 @@ bool checkImmediateAppendSupport(ur_context_handle_t Context, const bool EnableAppendPath = std::atoi(UrRet) == 1; if (EnableAppendPath && !Device->ImmCommandListUsed) { - logger::error("{} is set but immediate command-lists are currently " - "disabled. Immediate command-lists are " - "required to use the immediate append path.", - AppendEnvVarName); + URLOG(ERR, + "{} is set but immediate command-lists are currently " + "disabled. Immediate command-lists are " + "required to use the immediate append path.", + AppendEnvVarName); std::abort(); } if (EnableAppendPath && !DriverSupportsImmediateAppend) { - logger::error("{} is set but " - "the current driver does not support the " - "zeCommandListImmediateAppendCommandListsExp entrypoint.", - AppendEnvVarName); + URLOG(ERR, + "{} is set but " + "the current driver does not support the " + "zeCommandListImmediateAppendCommandListsExp entrypoint.", + AppendEnvVarName); std::abort(); } @@ -1775,7 +1777,7 @@ ur_result_t validateCommandDesc( auto SupportedFeatures = Command->CommandBuffer->Device->ZeDeviceMutableCmdListsProperties ->mutableCommandFlags; - logger::debug("Mutable features supported by device {}", SupportedFeatures); + URLOG(DEBUG, "Mutable features supported by device {}", SupportedFeatures); UR_ASSERT( !CommandDesc->hNewKernel || @@ -1801,7 +1803,7 @@ ur_result_t validateCommandDesc( if (NewGlobalWorkOffset) { if (!CommandBuffer->Context->getPlatform() ->ZeDriverGlobalOffsetExtensionFound) { - logger::error("No global offset extension found on this driver"); + URLOG(ERR, "No global offset extension found on this driver"); return UR_RESULT_ERROR_INVALID_VALUE; } } diff --git a/source/adapters/level_zero/common.cpp b/source/adapters/level_zero/common.cpp index e13afc179f..500ac04956 100644 --- a/source/adapters/level_zero/common.cpp +++ b/source/adapters/level_zero/common.cpp @@ -77,8 +77,8 @@ bool setEnvVar(const char *name, const char *value) { int Res = setenv(name, value, 1); #endif if (Res != 0) { - logger::debug( - "UR L0 Adapter was unable to set the environment variable: {}", name); + URLOG(DEBUG, "UR L0 Adapter was unable to set the environment variable: {}", + name); return false; } return true; @@ -139,7 +139,7 @@ void zeParseError(ze_result_t ZeError, const char *&ErrorString) { ze_result_t ZeCall::doCall(ze_result_t ZeResult, const char *ZeName, const char *ZeArgs, bool TraceError) { - logger::debug("ZE ---> {}{}", ZeName, ZeArgs); + URLOG(DEBUG, "ZE ---> {}{}", ZeName, ZeArgs); if (ZeResult == ZE_RESULT_SUCCESS) { if (UrL0LeaksDebug) { @@ -151,7 +151,7 @@ ze_result_t ZeCall::doCall(ze_result_t ZeResult, const char *ZeName, if (TraceError) { const char *ErrorString = "Unknown"; zeParseError(ZeResult, ErrorString); - logger::error("Error ({}) in {}", ErrorString, ZeName); + URLOG(ERR, "Error ({}) in {}", ErrorString, ZeName); } return ZeResult; } diff --git a/source/adapters/level_zero/common.hpp b/source/adapters/level_zero/common.hpp index 590a9badea..0b4f51e446 100644 --- a/source/adapters/level_zero/common.hpp +++ b/source/adapters/level_zero/common.hpp @@ -174,10 +174,10 @@ static auto getUrResultString = [](ur_result_t Result) { #define UR_CALL(Call) \ { \ if (PrintTrace) \ - logger::always("UR ---> {}", #Call); \ + URLOG_ALWAYS("UR ---> {}", #Call); \ ur_result_t Result = (Call); \ if (PrintTrace) \ - logger::always("UR <--- {}({})", #Call, getUrResultString(Result)); \ + URLOG_ALWAYS("UR <--- {}({})", #Call, getUrResultString(Result)); \ if (Result != UR_RESULT_SUCCESS) \ return Result; \ } @@ -186,10 +186,10 @@ static auto getUrResultString = [](ur_result_t Result) { #define UR_CALL_THROWS(Call) \ { \ if (PrintTrace) \ - logger::always("UR ---> {}", #Call); \ + URLOG_ALWAYS("UR ---> {}", #Call); \ ur_result_t Result = (Call); \ if (PrintTrace) \ - logger::always("UR <--- {}({})", #Call, getUrResultString(Result)); \ + URLOG_ALWAYS("UR <--- {}({})", #Call, getUrResultString(Result)); \ if (Result != UR_RESULT_SUCCESS) \ throw Result; \ } diff --git a/source/adapters/level_zero/context.cpp b/source/adapters/level_zero/context.cpp index 67dcd513e5..6e7239de89 100644 --- a/source/adapters/level_zero/context.cpp +++ b/source/adapters/level_zero/context.cpp @@ -331,7 +331,8 @@ ur_result_t ur_context_handle_t_::initialize() { ZeCommandQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS; if (Device->useDriverInOrderLists() && Device->useDriverCounterBasedEvents()) { - logger::debug( + URLOG( + DEBUG, "L0 Synchronous Immediate Command List needed with In Order property."); ZeCommandQueueDesc.flags |= ZE_COMMAND_LIST_FLAG_IN_ORDER; } @@ -550,8 +551,8 @@ ur_result_t ur_context_handle_t_::getFreeSlotInExistingOrNewPool( ZeEventPoolDesc.flags |= ZE_EVENT_POOL_FLAG_HOST_VISIBLE; if (ProfilingEnabled) ZeEventPoolDesc.flags |= ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP; - logger::debug("ze_event_pool_desc_t flags set to: {}", - ZeEventPoolDesc.flags); + URLOG(DEBUG, "ze_event_pool_desc_t flags set to: {}", + ZeEventPoolDesc.flags); if (CounterBasedEventEnabled) { if (UsingImmCmdList) { counterBasedExt.flags = ZE_EVENT_POOL_COUNTER_BASED_EXP_FLAG_IMMEDIATE; @@ -559,8 +560,8 @@ ur_result_t ur_context_handle_t_::getFreeSlotInExistingOrNewPool( counterBasedExt.flags = ZE_EVENT_POOL_COUNTER_BASED_EXP_FLAG_NON_IMMEDIATE; } - logger::debug("ze_event_pool_desc_t counter based flags set to: {}", - counterBasedExt.flags); + URLOG(DEBUG, "ze_event_pool_desc_t counter based flags set to: {}", + counterBasedExt.flags); if (InterruptBasedEventEnabled) { counterBasedExt.pNext = &eventSyncMode; } @@ -600,10 +601,11 @@ ur_event_handle_t ur_context_handle_t_::getEventFromContextCache( getEventCache(HostVisible, WithProfiling, Device, CounterBasedEventEnabled, InterruptBasedEventEnabled); if (Cache->empty()) { - logger::info("Cache empty (Host Visible: {}, Profiling: {}, Counter: {}, " - "Interrupt: {}, Device: {})", - HostVisible, WithProfiling, CounterBasedEventEnabled, - InterruptBasedEventEnabled, Device); + URLOG(INFO, + "Cache empty (Host Visible: {}, Profiling: {}, Counter: {}, " + "Interrupt: {}, Device: {})", + HostVisible, WithProfiling, CounterBasedEventEnabled, + InterruptBasedEventEnabled, Device); return nullptr; } @@ -614,11 +616,12 @@ ur_event_handle_t ur_context_handle_t_::getEventFromContextCache( // We have to reset event before using it. Event->reset(); - logger::info("Using {} event (Host Visible: {}, Profiling: {}, Counter: {}, " - "Interrupt: {}, Device: {}) from cache {}", - Event, Event->HostVisibleEvent, Event->isProfilingEnabled(), - Event->CounterBasedEventsEnabled, - Event->InterruptBasedEventsEnabled, Device, Cache); + URLOG(INFO, + "Using {} event (Host Visible: {}, Profiling: {}, Counter: {}, " + "Interrupt: {}, Device: {}) from cache {}", + Event, Event->HostVisibleEvent, Event->isProfilingEnabled(), + Event->CounterBasedEventsEnabled, Event->InterruptBasedEventsEnabled, + Device, Cache); return Event; } @@ -634,10 +637,11 @@ void ur_context_handle_t_::addEventToContextCache(ur_event_handle_t Event) { auto Cache = getEventCache( Event->isHostVisible(), Event->isProfilingEnabled(), Device, Event->CounterBasedEventsEnabled, Event->InterruptBasedEventsEnabled); - logger::info("Inserting {} event (Host Visible: {}, Profiling: {}, Counter: " - "{}, Device: {}) into cache {}", - Event, Event->HostVisibleEvent, Event->isProfilingEnabled(), - Event->CounterBasedEventsEnabled, Device, Cache); + URLOG(INFO, + "Inserting {} event (Host Visible: {}, Profiling: {}, Counter: " + "{}, Device: {}) into cache {}", + Event, Event->HostVisibleEvent, Event->isProfilingEnabled(), + Event->CounterBasedEventsEnabled, Device, Cache); Cache->emplace_back(Event); } diff --git a/source/adapters/level_zero/device.cpp b/source/adapters/level_zero/device.cpp index e6a73a378e..500faf5643 100644 --- a/source/adapters/level_zero/device.cpp +++ b/source/adapters/level_zero/device.cpp @@ -52,8 +52,8 @@ getRangeOfAllowedCopyEngines(const ur_device_handle_t &Device) { int UpperCopyEngineIndex = std::stoi(CopyEngineRange.substr(pos + 1)); if ((LowerCopyEngineIndex > UpperCopyEngineIndex) || (LowerCopyEngineIndex < -1) || (UpperCopyEngineIndex < -1)) { - logger::error("UR_L0_LEVEL_ZERO_USE_COPY_ENGINE: invalid value provided, " - "default set."); + URLOG(ERR, "UR_L0_LEVEL_ZERO_USE_COPY_ENGINE: invalid value provided, " + "default set."); LowerCopyEngineIndex = 0; UpperCopyEngineIndex = INT_MAX; } @@ -141,7 +141,7 @@ ur_result_t urDeviceGet( break; default: Matched = false; - logger::warning("Unknown device type"); + URLOG(WARN, "Unknown device type"); break; } @@ -217,7 +217,7 @@ ur_result_t urDeviceGetInfo( case ZE_DEVICE_TYPE_FPGA: return ReturnValue(UR_DEVICE_TYPE_FPGA); default: - logger::error("This device type is not supported"); + URLOG(ERR, "This device type is not supported"); return UR_RESULT_ERROR_INVALID_VALUE; } } @@ -765,8 +765,8 @@ ur_result_t urDeviceGetInfo( case UR_DEVICE_INFO_GLOBAL_MEM_FREE: { bool SysManEnv = getenv_tobool("ZES_ENABLE_SYSMAN", false); if ((Device->Platform->ZedeviceToZesDeviceMap.size() == 0) && !SysManEnv) { - logger::error("SysMan support is unavailable on this system. Please " - "check your level zero driver installation."); + URLOG(ERR, "SysMan support is unavailable on this system. Please " + "check your level zero driver installation."); return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; } // Calculate the global memory size as the max limit that can be reported as @@ -1091,8 +1091,8 @@ ur_result_t urDeviceGetInfo( case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP: case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP: case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_PITCH_EXP: - logger::error("Unsupported ParamName in urGetDeviceInfo"); - logger::error("ParamName=%{}(0x{})", ParamName, logger::toHex(ParamName)); + URLOG(ERR, "Unsupported ParamName in urGetDeviceInfo"); + URLOG(ERR, "ParamName=%{}(0x{})", ParamName, logger::toHex(ParamName)); return UR_RESULT_ERROR_INVALID_VALUE; case UR_DEVICE_INFO_MIPMAP_SUPPORT_EXP: { // L0 does not support mipmaps. @@ -1103,8 +1103,8 @@ ur_result_t urDeviceGetInfo( return ReturnValue(false); } case UR_DEVICE_INFO_MIPMAP_MAX_ANISOTROPY_EXP: - logger::error("Unsupported ParamName in urGetDeviceInfo"); - logger::error("ParamName=%{}(0x{})", ParamName, logger::toHex(ParamName)); + URLOG(ERR, "Unsupported ParamName in urGetDeviceInfo"); + URLOG(ERR, "ParamName=%{}(0x{})", ParamName, logger::toHex(ParamName)); return UR_RESULT_ERROR_INVALID_VALUE; case UR_DEVICE_INFO_MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP: { // L0 does not support creation of images from individual mipmap levels. @@ -1199,9 +1199,9 @@ ur_result_t urDeviceGetInfo( case UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED: return ReturnValue(false); default: - logger::error("Unsupported ParamName in urGetDeviceInfo"); - logger::error("ParamNameParamName={}(0x{})", ParamName, - logger::toHex(ParamName)); + URLOG(ERR, "Unsupported ParamName in urGetDeviceInfo"); + URLOG(ERR, "ParamNameParamName={}(0x{})", ParamName, + logger::toHex(ParamName)); return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; } diff --git a/source/adapters/level_zero/event.cpp b/source/adapters/level_zero/event.cpp index 85f06bdfd7..e09f4a658b 100644 --- a/source/adapters/level_zero/event.cpp +++ b/source/adapters/level_zero/event.cpp @@ -29,7 +29,7 @@ void printZeEventList(const _ur_ze_event_list_t &UrZeEventList) { for (uint32_t I = 0; I < UrZeEventList.Length; I++) { ss << " " << ur_cast(UrZeEventList.ZeEventList[I]); } - logger::debug(ss.str().c_str()); + URLOG(DEBUG, "{}", ss.str().c_str()); } } @@ -523,7 +523,8 @@ ur_result_t urEventGetInfo( return ReturnValue(Event->RefCount.load()); } default: - logger::error( + URLOG( + ERR, "Unsupported ParamName in urEventGetInfo: ParamName=ParamName={}(0x{})", PropName, logger::toHex(PropName)); return UR_RESULT_ERROR_INVALID_VALUE; @@ -610,7 +611,7 @@ ur_result_t urEventGetProfilingInfo( return ReturnValue(ContextEndTime); } default: - logger::error("urEventGetProfilingInfo: not supported ParamName"); + URLOG(ERR, "urEventGetProfilingInfo: not supported ParamName"); return UR_RESULT_ERROR_INVALID_VALUE; } } @@ -673,7 +674,7 @@ ur_result_t urEventGetProfilingInfo( return ReturnValue(ContextEndTime); } default: - logger::error("urEventGetProfilingInfo: not supported ParamName"); + URLOG(ERR, "urEventGetProfilingInfo: not supported ParamName"); return UR_RESULT_ERROR_INVALID_VALUE; } } else { @@ -716,7 +717,7 @@ ur_result_t urEventGetProfilingInfo( // return ReturnValue(uint64_t{0}); default: - logger::error("urEventGetProfilingInfo: not supported ParamName"); + URLOG(ERR, "urEventGetProfilingInfo: not supported ParamName"); return UR_RESULT_ERROR_INVALID_VALUE; } @@ -831,7 +832,7 @@ urEventWait(uint32_t NumEvents, die("The host-visible proxy event missing"); ze_event_handle_t ZeEvent = HostVisibleEvent->ZeEvent; - logger::debug("ZeEvent = {}", ur_cast(ZeEvent)); + URLOG(DEBUG, "ZeEvent = {}", ur_cast(ZeEvent)); // If this event was an inner batched event, then sync with // the Queue instead of waiting on the event. if (HostVisibleEvent->IsInnerBatchedEvent && Event->ZeBatchedQueue) { diff --git a/source/adapters/level_zero/helpers/kernel_helpers.cpp b/source/adapters/level_zero/helpers/kernel_helpers.cpp index 895dbbe7d9..af04d49214 100644 --- a/source/adapters/level_zero/helpers/kernel_helpers.cpp +++ b/source/adapters/level_zero/helpers/kernel_helpers.cpp @@ -52,15 +52,15 @@ ur_result_t getSuggestedLocalWorkSize(ur_device_handle_t hDevice, --GroupSize[I]; } if (GlobalWorkSize3D[I] / GroupSize[I] > UINT32_MAX) { - logger::error("getSuggestedLocalWorkSize: can't find a WG size " - "suitable for global work size > UINT32_MAX"); + URLOG(ERR, "getSuggestedLocalWorkSize: can't find a WG size " + "suitable for global work size > UINT32_MAX"); return UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE; } WG[I] = GroupSize[I]; } - logger::debug( - "getSuggestedLocalWorkSize: using computed WG size = {{{}, {}, {}}}", - WG[0], WG[1], WG[2]); + URLOG(DEBUG, + "getSuggestedLocalWorkSize: using computed WG size = {{{}, {}, {}}}", + WG[0], WG[1], WG[2]); } return UR_RESULT_SUCCESS; @@ -70,7 +70,7 @@ ur_result_t setKernelGlobalOffset(ur_context_handle_t Context, ze_kernel_handle_t Kernel, uint32_t WorkDim, const size_t *GlobalWorkOffset) { if (!Context->getPlatform()->ZeDriverGlobalOffsetExtensionFound) { - logger::debug("No global offset extension found on this driver"); + URLOG(DEBUG, "No global offset extension found on this driver"); return UR_RESULT_ERROR_INVALID_VALUE; } @@ -130,27 +130,27 @@ ur_result_t calculateKernelWorkDimensions( break; default: - logger::error("calculateKernelWorkDimensions: unsupported work_dim"); + URLOG(ERR, "calculateKernelWorkDimensions: unsupported work_dim"); return UR_RESULT_ERROR_INVALID_VALUE; } // Error handling for non-uniform group size case if (GlobalWorkSize3D[0] != size_t(ZeThreadGroupDimensions.groupCountX) * WG[0]) { - logger::error("calculateKernelWorkDimensions: invalid work_dim. The range " - "is not a multiple of the group size in the 1st dimension"); + URLOG(ERR, "calculateKernelWorkDimensions: invalid work_dim. The range " + "is not a multiple of the group size in the 1st dimension"); return UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE; } if (GlobalWorkSize3D[1] != size_t(ZeThreadGroupDimensions.groupCountY) * WG[1]) { - logger::error("calculateKernelWorkDimensions: invalid work_dim. The range " - "is not a multiple of the group size in the 2nd dimension"); + URLOG(ERR, "calculateKernelWorkDimensions: invalid work_dim. The range " + "is not a multiple of the group size in the 2nd dimension"); return UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE; } if (GlobalWorkSize3D[2] != size_t(ZeThreadGroupDimensions.groupCountZ) * WG[2]) { - logger::error("calculateKernelWorkDimensions: invalid work_dim. The range " - "is not a multiple of the group size in the 3rd dimension"); + URLOG(ERR, "calculateKernelWorkDimensions: invalid work_dim. The range " + "is not a multiple of the group size in the 3rd dimension"); return UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE; } diff --git a/source/adapters/level_zero/image.cpp b/source/adapters/level_zero/image.cpp index 217a185f5b..9e9f369571 100644 --- a/source/adapters/level_zero/image.cpp +++ b/source/adapters/level_zero/image.cpp @@ -56,9 +56,8 @@ ur_result_t ze2urImageFormat(const ze_image_desc_t *ZeImageDesc, ZeImageFormatTypeSize = 32; break; default: - logger::error( - "ze2urImageFormat: unsupported image format layout: layout = {}", - ZeImageFormat.layout); + URLOG(ERR, "ze2urImageFormat: unsupported image format layout: layout = {}", + ZeImageFormat.layout); return UR_RESULT_ERROR_INVALID_VALUE; } @@ -75,9 +74,8 @@ ur_result_t ze2urImageFormat(const ze_image_desc_t *ZeImageDesc, ChannelOrder = UR_IMAGE_CHANNEL_ORDER_A; break; default: - logger::error( - "ze2urImageFormat: unexpected image format channel x: x = {}", - ZeImageFormat.x); + URLOG(ERR, "ze2urImageFormat: unexpected image format channel x: x = {}", + ZeImageFormat.x); return UR_RESULT_ERROR_INVALID_VALUE; } break; @@ -85,9 +83,8 @@ ur_result_t ze2urImageFormat(const ze_image_desc_t *ZeImageDesc, case ZE_IMAGE_FORMAT_LAYOUT_16_16: case ZE_IMAGE_FORMAT_LAYOUT_32_32: if (ZeImageFormat.x != ZE_IMAGE_FORMAT_SWIZZLE_R) { - logger::error( - "ze2urImageFormat: unexpected image format channel x: x = {}", - ZeImageFormat.x); + URLOG(ERR, "ze2urImageFormat: unexpected image format channel x: x = {}", + ZeImageFormat.x); return UR_RESULT_ERROR_INVALID_VALUE; } switch (ZeImageFormat.y) { @@ -101,9 +98,9 @@ ur_result_t ze2urImageFormat(const ze_image_desc_t *ZeImageDesc, ChannelOrder = UR_IMAGE_CHANNEL_ORDER_RX; break; default: - logger::error( - "ze2urImageFormat: unexpected image format channel y: y = {}\n", - ZeImageFormat.y); + URLOG(ERR, + "ze2urImageFormat: unexpected image format channel y: y = {}\n", + ZeImageFormat.y); return UR_RESULT_ERROR_INVALID_VALUE; } break; @@ -120,13 +117,13 @@ ur_result_t ze2urImageFormat(const ze_image_desc_t *ZeImageDesc, ChannelOrder = UR_IMAGE_CHANNEL_ORDER_RGX; break; default: - logger::error( - "ze2urImageFormat: unexpected image format channel z: z = {}\n", - ZeImageFormat.z); + URLOG(ERR, + "ze2urImageFormat: unexpected image format channel z: z = {}\n", + ZeImageFormat.z); return UR_RESULT_ERROR_INVALID_VALUE; } } else { - logger::error("ze2urImageFormat: unexpected image format channel"); + URLOG(ERR, "ze2urImageFormat: unexpected image format channel"); return UR_RESULT_ERROR_INVALID_VALUE; } break; @@ -144,9 +141,10 @@ ur_result_t ze2urImageFormat(const ze_image_desc_t *ZeImageDesc, ChannelOrder = UR_IMAGE_CHANNEL_ORDER_RGBA; break; default: - logger::error("ze2urImageFormat: unexpected image format channel w: w " - "= {}", - ZeImageFormat.x); + URLOG(ERR, + "ze2urImageFormat: unexpected image format channel w: w " + "= {}", + ZeImageFormat.x); return UR_RESULT_ERROR_INVALID_VALUE; } } else if (ZeImageFormat.x == ZE_IMAGE_FORMAT_SWIZZLE_A && @@ -160,14 +158,13 @@ ur_result_t ze2urImageFormat(const ze_image_desc_t *ZeImageDesc, ZeImageFormat.w == ZE_IMAGE_FORMAT_SWIZZLE_A) { ChannelOrder = UR_IMAGE_CHANNEL_ORDER_BGRA; } else { - logger::error("ze2urImageFormat: unexpected image format channel"); + URLOG(ERR, "ze2urImageFormat: unexpected image format channel"); return UR_RESULT_ERROR_INVALID_VALUE; } break; default: - logger::error( - "ze2urImageFormat: unsupported image format layout: layout = {}", - ZeImageFormat.layout); + URLOG(ERR, "ze2urImageFormat: unsupported image format layout: layout = {}", + ZeImageFormat.layout); return UR_RESULT_ERROR_INVALID_VALUE; } @@ -185,9 +182,10 @@ ur_result_t ze2urImageFormat(const ze_image_desc_t *ZeImageDesc, ChannelType = UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT32; break; default: - logger::error("ze2urImageFormat: unexpected image format type size: size " - "= {}", - ZeImageFormatTypeSize); + URLOG(ERR, + "ze2urImageFormat: unexpected image format type size: size " + "= {}", + ZeImageFormatTypeSize); return UR_RESULT_ERROR_INVALID_VALUE; } break; @@ -203,9 +201,10 @@ ur_result_t ze2urImageFormat(const ze_image_desc_t *ZeImageDesc, ChannelType = UR_IMAGE_CHANNEL_TYPE_SIGNED_INT32; break; default: - logger::error("ze2urImageFormat: unexpected image format type size: size " - "= {}", - ZeImageFormatTypeSize); + URLOG(ERR, + "ze2urImageFormat: unexpected image format type size: size " + "= {}", + ZeImageFormatTypeSize); return UR_RESULT_ERROR_INVALID_VALUE; } break; @@ -218,9 +217,10 @@ ur_result_t ze2urImageFormat(const ze_image_desc_t *ZeImageDesc, ChannelType = UR_IMAGE_CHANNEL_TYPE_UNORM_INT16; break; default: - logger::error("ze2urImageFormat: unexpected image format type size: size " - "= {}", - ZeImageFormatTypeSize); + URLOG(ERR, + "ze2urImageFormat: unexpected image format type size: size " + "= {}", + ZeImageFormatTypeSize); return UR_RESULT_ERROR_INVALID_VALUE; } break; @@ -233,9 +233,10 @@ ur_result_t ze2urImageFormat(const ze_image_desc_t *ZeImageDesc, ChannelType = UR_IMAGE_CHANNEL_TYPE_SNORM_INT16; break; default: - logger::error("ze2urImageFormat: unexpected image format type size: size " - "= {}", - ZeImageFormatTypeSize); + URLOG(ERR, + "ze2urImageFormat: unexpected image format type size: size " + "= {}", + ZeImageFormatTypeSize); return UR_RESULT_ERROR_INVALID_VALUE; } break; @@ -248,15 +249,16 @@ ur_result_t ze2urImageFormat(const ze_image_desc_t *ZeImageDesc, ChannelType = UR_IMAGE_CHANNEL_TYPE_FLOAT; break; default: - logger::error("ze2urImageFormat: unexpected image format type size: size " - "= {}", - ZeImageFormatTypeSize); + URLOG(ERR, + "ze2urImageFormat: unexpected image format type size: size " + "= {}", + ZeImageFormatTypeSize); return UR_RESULT_ERROR_INVALID_VALUE; } break; default: - logger::error("ze2urImageFormat: unsupported image format type: type = {}", - ZeImageFormat.type); + URLOG(ERR, "ze2urImageFormat: unsupported image format type: type = {}", + ZeImageFormat.type); return UR_RESULT_ERROR_INVALID_VALUE; } @@ -300,7 +302,7 @@ ur_result_t ur2zeImageDesc(const ur_image_format_t *ImageFormat, ZeImageFormatLayout = ZE_IMAGE_FORMAT_LAYOUT_32; break; default: - logger::error("ur2zeImageDesc: unexpected data type size"); + URLOG(ERR, "ur2zeImageDesc: unexpected data type size"); return UR_RESULT_ERROR_INVALID_VALUE; } break; @@ -319,7 +321,7 @@ ur_result_t ur2zeImageDesc(const ur_image_format_t *ImageFormat, ZeImageFormatLayout = ZE_IMAGE_FORMAT_LAYOUT_32_32; break; default: - logger::error("ur2zeImageDesc: unexpected data type size"); + URLOG(ERR, "ur2zeImageDesc: unexpected data type size"); return UR_RESULT_ERROR_INVALID_VALUE; } break; @@ -339,7 +341,7 @@ ur_result_t ur2zeImageDesc(const ur_image_format_t *ImageFormat, ZeImageFormatLayout = ZE_IMAGE_FORMAT_LAYOUT_32_32_32_32; break; default: - logger::error("ur2zeImageDesc: unexpected data type size"); + URLOG(ERR, "ur2zeImageDesc: unexpected data type size"); return UR_RESULT_ERROR_INVALID_VALUE; } break; @@ -357,13 +359,13 @@ ur_result_t ur2zeImageDesc(const ur_image_format_t *ImageFormat, ZeImageFormatLayout = ZE_IMAGE_FORMAT_LAYOUT_32_32_32; break; default: - logger::error("ur2zeImageDesc: unexpected data type size"); + URLOG(ERR, "ur2zeImageDesc: unexpected data type size"); return UR_RESULT_ERROR_INVALID_VALUE; } break; } default: - logger::error("format channel order = {}", ImageFormat->channelOrder); + URLOG(ERR, "format channel order = {}", ImageFormat->channelOrder); die("ur2zeImageDesc: unsupported image channel order\n"); break; } @@ -392,7 +394,7 @@ ur_result_t ur2zeImageDesc(const ur_image_format_t *ImageFormat, ZeImageType = ZE_IMAGE_TYPE_2DARRAY; break; default: - logger::error("ur2zeImageDesc: unsupported image type"); + URLOG(ERR, "ur2zeImageDesc: unsupported image type"); return UR_RESULT_ERROR_INVALID_VALUE; } @@ -542,9 +544,10 @@ ur_result_t bindlessImagesCreateImpl(ur_context_handle_t hContext, DriverHandle, "zeImageGetDeviceOffsetExp", (void **)&zeImageGetDeviceOffsetExpFunctionPtr); if (Result != ZE_RESULT_SUCCESS) - logger::error("zeDriverGetExtensionFunctionAddress " - "zeImageGetDeviceOffsetExpv failed, err = {}", - Result); + URLOG(ERR, + "zeDriverGetExtensionFunctionAddress " + "zeImageGetDeviceOffsetExpv failed, err = {}", + Result); }); if (!zeImageGetDeviceOffsetExpFunctionPtr) return UR_RESULT_ERROR_INVALID_OPERATION; @@ -684,9 +687,8 @@ getImageFormatTypeAndSize(const ur_image_format_t *ImageFormat) { break; } default: - logger::error( - "urMemImageCreate: unsupported image data type: data type = {}", - ImageFormat->channelType); + URLOG(ERR, "urMemImageCreate: unsupported image data type: data type = {}", + ImageFormat->channelType); ZeImageFormatType = ZE_IMAGE_FORMAT_TYPE_FORCE_UINT32; ZeImageFormatTypeSize = 0; } @@ -714,10 +716,10 @@ ur_result_t urUSMPitchedAllocExp(ur_context_handle_t hContext, DriverHandle, "zeMemGetPitchFor2dImage", (void **)&zeMemGetPitchFor2dImageFunctionPtr); if (Result != ZE_RESULT_SUCCESS) - logger::error( - "zeDriverGetExtensionFunctionAddress zeMemGetPitchFor2dImage " - "failed, err = {}", - Result); + URLOG(ERR, + "zeDriverGetExtensionFunctionAddress zeMemGetPitchFor2dImage " + "failed, err = {}", + Result); }); if (!zeMemGetPitchFor2dImageFunctionPtr) return UR_RESULT_ERROR_INVALID_OPERATION; @@ -985,7 +987,7 @@ ur_result_t urBindlessImagesImageCopyExp( &DstRegion, &SrcRegion, ZeEvent, WaitList.Length, WaitList.ZeEventList)); } else { - logger::error("urBindlessImagesImageCopyExp: unexpected imageCopyFlags"); + URLOG(ERR, "urBindlessImagesImageCopyExp: unexpected imageCopyFlags"); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -1169,8 +1171,8 @@ ur_result_t urBindlessImagesMapExternalLinearMemoryExp( std::ignore = offset; std::ignore = hExternalMem; std::ignore = phRetMem; - logger::error("[UR][L0] {} function not implemented!", - "{} function not implemented!", __FUNCTION__); + URLOG(ERR, "[UR][L0] {} function not implemented!", + "{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } diff --git a/source/adapters/level_zero/kernel.cpp b/source/adapters/level_zero/kernel.cpp index 4a0bfc3da5..b51ea2211f 100644 --- a/source/adapters/level_zero/kernel.cpp +++ b/source/adapters/level_zero/kernel.cpp @@ -189,9 +189,10 @@ ur_result_t urEnqueueKernelLaunch( (*Event)->WaitList.Length, (*Event)->WaitList.ZeEventList)); } - logger::debug("calling zeCommandListAppendLaunchKernel() with" - " ZeEvent {}", - ur_cast(ZeEvent)); + URLOG(DEBUG, + "calling zeCommandListAppendLaunchKernel() with" + " ZeEvent {}", + ur_cast(ZeEvent)); printZeEventList((*Event)->WaitList); // Execute command list asynchronously, as the event will be used @@ -317,16 +318,17 @@ ur_result_t urEnqueueCooperativeKernelLaunchExp( } if (GlobalWorkSize3D[I] / GroupSize[I] > UINT32_MAX) { - logger::error( - "urEnqueueCooperativeKernelLaunchExp: can't find a WG size " - "suitable for global work size > UINT32_MAX"); + URLOG(ERR, + "urEnqueueCooperativeKernelLaunchExp: can't find a WG size " + "suitable for global work size > UINT32_MAX"); return UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE; } WG[I] = GroupSize[I]; } - logger::debug("urEnqueueCooperativeKernelLaunchExp: using computed WG " - "size = {{{}, {}, {}}}", - WG[0], WG[1], WG[2]); + URLOG(DEBUG, + "urEnqueueCooperativeKernelLaunchExp: using computed WG " + "size = {{{}, {}, {}}}", + WG[0], WG[1], WG[2]); } } @@ -355,30 +357,30 @@ ur_result_t urEnqueueCooperativeKernelLaunchExp( break; default: - logger::error("urEnqueueCooperativeKernelLaunchExp: unsupported work_dim"); + URLOG(ERR, "urEnqueueCooperativeKernelLaunchExp: unsupported work_dim"); return UR_RESULT_ERROR_INVALID_VALUE; } // Error handling for non-uniform group size case if (GlobalWorkSize3D[0] != size_t(ZeThreadGroupDimensions.groupCountX) * WG[0]) { - logger::error("urEnqueueCooperativeKernelLaunchExp: invalid work_dim. The " - "range is not a " - "multiple of the group size in the 1st dimension"); + URLOG(ERR, "urEnqueueCooperativeKernelLaunchExp: invalid work_dim. The " + "range is not a " + "multiple of the group size in the 1st dimension"); return UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE; } if (GlobalWorkSize3D[1] != size_t(ZeThreadGroupDimensions.groupCountY) * WG[1]) { - logger::error("urEnqueueCooperativeKernelLaunchExp: invalid work_dim. The " - "range is not a " - "multiple of the group size in the 2nd dimension"); + URLOG(ERR, "urEnqueueCooperativeKernelLaunchExp: invalid work_dim. The " + "range is not a " + "multiple of the group size in the 2nd dimension"); return UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE; } if (GlobalWorkSize3D[2] != size_t(ZeThreadGroupDimensions.groupCountZ) * WG[2]) { - logger::debug("urEnqueueCooperativeKernelLaunchExp: invalid work_dim. The " - "range is not a " - "multiple of the group size in the 3rd dimension"); + URLOG(DEBUG, "urEnqueueCooperativeKernelLaunchExp: invalid work_dim. The " + "range is not a " + "multiple of the group size in the 3rd dimension"); return UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE; } @@ -449,9 +451,10 @@ ur_result_t urEnqueueCooperativeKernelLaunchExp( (*Event)->WaitList.Length, (*Event)->WaitList.ZeEventList)); } - logger::debug("calling zeCommandListAppendLaunchCooperativeKernel() with" - " ZeEvent {}", - ur_cast(ZeEvent)); + URLOG(DEBUG, + "calling zeCommandListAppendLaunchCooperativeKernel() with" + " ZeEvent {}", + ur_cast(ZeEvent)); printZeEventList((*Event)->WaitList); // Execute command list asynchronously, as the event will be used @@ -770,9 +773,8 @@ ur_result_t urKernelGetInfo( return UR_RESULT_ERROR_UNKNOWN; } default: - logger::error( - "Unsupported ParamName in urKernelGetInfo: ParamName={}(0x{})", - ParamName, logger::toHex(ParamName)); + URLOG(ERR, "Unsupported ParamName in urKernelGetInfo: ParamName={}(0x{})", + ParamName, logger::toHex(ParamName)); return UR_RESULT_ERROR_INVALID_VALUE; } @@ -859,9 +861,8 @@ ur_result_t urKernelGetGroupInfo( // No corresponding enumeration in Level Zero return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; default: { - logger::error( - "Unknown ParamName in urKernelGetGroupInfo: ParamName={}(0x{})", - ParamName, logger::toHex(ParamName)); + URLOG(ERR, "Unknown ParamName in urKernelGetGroupInfo: ParamName={}(0x{})", + ParamName, logger::toHex(ParamName)); return UR_RESULT_ERROR_INVALID_VALUE; } } @@ -999,7 +1000,7 @@ ur_result_t urKernelSetExecInfo( return UR_RESULT_ERROR_INVALID_VALUE; ZE2UR_CALL(zeKernelSetCacheConfig, (ZeKernel, ZeCacheConfig);); } else { - logger::error("urKernelSetExecInfo: unsupported ParamName"); + URLOG(ERR, "urKernelSetExecInfo: unsupported ParamName"); return UR_RESULT_ERROR_INVALID_VALUE; } } diff --git a/source/adapters/level_zero/memory.cpp b/source/adapters/level_zero/memory.cpp index e21470eee2..a27ee16851 100644 --- a/source/adapters/level_zero/memory.cpp +++ b/source/adapters/level_zero/memory.cpp @@ -117,9 +117,10 @@ ur_result_t enqueueMemCopyHelper(ur_command_t CommandType, const auto &ZeCommandList = CommandList->first; const auto &WaitList = (*Event)->WaitList; - logger::debug("calling zeCommandListAppendMemoryCopy() with" - " ZeEvent {}", - ur_cast(ZeEvent)); + URLOG(DEBUG, + "calling zeCommandListAppendMemoryCopy() with" + " ZeEvent {}", + ur_cast(ZeEvent)); printZeEventList(WaitList); ZE2UR_CALL(zeCommandListAppendMemoryCopy, @@ -170,9 +171,10 @@ ur_result_t enqueueMemCopyRectHelper( const auto &ZeCommandList = CommandList->first; const auto &WaitList = (*Event)->WaitList; - logger::debug("calling zeCommandListAppendMemoryCopy() with" - " ZeEvent {}", - ur_cast(ZeEvent)); + URLOG(DEBUG, + "calling zeCommandListAppendMemoryCopy() with" + " ZeEvent {}", + ur_cast(ZeEvent)); printZeEventList(WaitList); auto ZeParams = ur2zeRegionParams(SrcOrigin, DstOrigin, Region, SrcRowPitch, @@ -184,7 +186,7 @@ ur_result_t enqueueMemCopyRectHelper( ZeParams.srcPitch, ZeParams.srcSlicePitch, ZeEvent, WaitList.Length, WaitList.ZeEventList)); - logger::debug("calling zeCommandListAppendMemoryCopyRegion()"); + URLOG(DEBUG, "calling zeCommandListAppendMemoryCopyRegion()"); UR_CALL(Queue->executeCommandList(CommandList, Blocking, OkToBatch)); @@ -259,9 +261,10 @@ static ur_result_t enqueueMemFillHelper(ur_command_t CommandType, (ZeCommandList, Ptr, Pattern, PatternSize, Size, ZeEvent, WaitList.Length, WaitList.ZeEventList)); - logger::debug("calling zeCommandListAppendMemoryFill() with" - " ZeEvent {}", - ur_cast(ZeEvent)); + URLOG(DEBUG, + "calling zeCommandListAppendMemoryFill() with" + " ZeEvent {}", + ur_cast(ZeEvent)); printZeEventList(WaitList); // Execute command list asynchronously, as the event will be used @@ -281,9 +284,10 @@ static ur_result_t enqueueMemFillHelper(ur_command_t CommandType, WaitList.Length, WaitList.ZeEventList)); } - logger::debug("calling zeCommandListAppendMemoryCopy() with" - " ZeEvent {}", - ur_cast(ZeEvent)); + URLOG(DEBUG, + "calling zeCommandListAppendMemoryCopy() with" + " ZeEvent {}", + ur_cast(ZeEvent)); printZeEventList(WaitList); // Execute command list synchronously. @@ -466,7 +470,7 @@ static ur_result_t enqueueMemImageCommandHelper( ur_cast(ZeHandleSrc), &ZeDstRegion, &ZeSrcRegion, ZeEvent, 0, nullptr)); } else { - logger::error("enqueueMemImageUpdate: unsupported image command type"); + URLOG(ERR, "enqueueMemImageUpdate: unsupported image command type"); return UR_RESULT_ERROR_INVALID_OPERATION; } @@ -1043,7 +1047,7 @@ ur_result_t urEnqueueMemBufferMap( // False as the second value in pair means that mapping was not inserted // because mapping already exists. if (!Res.second) { - logger::error("urEnqueueMemBufferMap: duplicate mapping detected"); + URLOG(ERR, "urEnqueueMemBufferMap: duplicate mapping detected"); return UR_RESULT_ERROR_INVALID_VALUE; } @@ -1104,7 +1108,7 @@ ur_result_t urEnqueueMemBufferMap( // False as the second value in pair means that mapping was not inserted // because mapping already exists. if (!Res.second) { - logger::error("urEnqueueMemBufferMap: duplicate mapping detected"); + URLOG(ERR, "urEnqueueMemBufferMap: duplicate mapping detected"); return UR_RESULT_ERROR_INVALID_VALUE; } return UR_RESULT_SUCCESS; @@ -1158,7 +1162,7 @@ ur_result_t urEnqueueMemUnmap( std::scoped_lock Guard(Buffer->Mutex); auto It = Buffer->Mappings.find(MappedPtr); if (It == Buffer->Mappings.end()) { - logger::error("urEnqueueMemUnmap: unknown memory mapping"); + URLOG(ERR, "urEnqueueMemUnmap: unknown memory mapping"); return UR_RESULT_ERROR_INVALID_VALUE; } MapInfo = It->second; @@ -1513,13 +1517,13 @@ static ur_result_t ur2zeImageDesc(const ur_image_format_t *ImageFormat, ZeImageFormatLayout = ZE_IMAGE_FORMAT_LAYOUT_32_32_32_32; break; default: - logger::error("urMemImageCreate: unexpected data type Size\n"); + URLOG(ERR, "urMemImageCreate: unexpected data type Size\n"); return UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT; } break; } default: - logger::error("format layout = {}", ImageFormat->channelOrder); + URLOG(ERR, "format layout = {}", ImageFormat->channelOrder); return UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT; break; } @@ -1548,7 +1552,7 @@ static ur_result_t ur2zeImageDesc(const ur_image_format_t *ImageFormat, ZeImageType = ZE_IMAGE_TYPE_2DARRAY; break; default: - logger::error("urMemImageCreate: unsupported image type"); + URLOG(ERR, "urMemImageCreate: unsupported image type"); return UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR; } @@ -2337,8 +2341,8 @@ ur_result_t _ur_buffer::getZeHandle(char *&ZeHandle, access_mode_t AccessMode, } } - logger::debug("getZeHandle(pi_device{{{}}}) = {}", (void *)Device, - (void *)Allocation.ZeHandle); + URLOG(DEBUG, "getZeHandle(pi_device{{{}}}) = {}", (void *)Device, + (void *)Allocation.ZeHandle); return UR_RESULT_SUCCESS; } diff --git a/source/adapters/level_zero/platform.cpp b/source/adapters/level_zero/platform.cpp index 09be698532..acf124acb9 100644 --- a/source/adapters/level_zero/platform.cpp +++ b/source/adapters/level_zero/platform.cpp @@ -98,7 +98,7 @@ ur_result_t urPlatformGetInfo( case UR_PLATFORM_INFO_ADAPTER: return ReturnValue(GlobalAdapter); default: - logger::debug("urPlatformGetInfo: unrecognized ParamName"); + URLOG(DEBUG, "urPlatformGetInfo: unrecognized ParamName"); return UR_RESULT_ERROR_INVALID_VALUE; } diff --git a/source/adapters/level_zero/program.cpp b/source/adapters/level_zero/program.cpp index 3f0790bddd..bf5335b424 100644 --- a/source/adapters/level_zero/program.cpp +++ b/source/adapters/level_zero/program.cpp @@ -440,9 +440,9 @@ ur_result_t urProgramLinkExp( ZeModuleDesc.pInputModule = ZeExtModuleDesc.pInputModules[0]; ZeModuleDesc.pConstants = ZeExtModuleDesc.pConstants[0]; } else { - logger::error( - "urProgramLink: level_zero driver does not have static linking " - "support."); + URLOG(ERR, + "urProgramLink: level_zero driver does not have static linking " + "support."); return UR_RESULT_ERROR_INVALID_VALUE; } } @@ -894,7 +894,7 @@ ur_result_t urProgramGetBuildInfo( // program. return ReturnValue(""); } else { - logger::error("urProgramGetBuildInfo: unsupported ParamName"); + URLOG(ERR, "urProgramGetBuildInfo: unsupported ParamName"); return UR_RESULT_ERROR_INVALID_VALUE; } return UR_RESULT_SUCCESS; diff --git a/source/adapters/level_zero/queue.cpp b/source/adapters/level_zero/queue.cpp index aed521b605..32540d4a55 100644 --- a/source/adapters/level_zero/queue.cpp +++ b/source/adapters/level_zero/queue.cpp @@ -455,7 +455,8 @@ ur_result_t urQueueGetInfo( return ReturnValue(true); } default: - logger::error( + URLOG( + ERR, "Unsupported ParamName in urQueueGetInfo: ParamName=ParamName={}(0x{})", ParamName, logger::toHex(ParamName)); return UR_RESULT_ERROR_INVALID_ENUMERATION; @@ -924,8 +925,8 @@ ur_result_t urEnqueueKernelLaunchCustomExp( std::ignore = phEventWaitList; std::ignore = phEvent; - logger::error("[UR][L0] {} function not implemented!", - "{} function not implemented!", __FUNCTION__); + URLOG(ERR, "[UR][L0] {} function not implemented!", + "{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -1005,9 +1006,9 @@ static const zeCommandListBatchConfig ZeCommandListBatchConfig(bool IsCopy) { Val = std::stoi(BatchConfig.substr(Pos)); } catch (...) { if (IsCopy) - logger::error("UR_L0_COPY_BATCH_SIZE: failed to parse value"); + URLOG(ERR, "UR_L0_COPY_BATCH_SIZE: failed to parse value") else - logger::error("UR_L0_BATCH_SIZE: failed to parse value"); + URLOG(ERR, "UR_L0_BATCH_SIZE: failed to parse value") break; } switch (Ord) { @@ -1030,20 +1031,21 @@ static const zeCommandListBatchConfig ZeCommandListBatchConfig(bool IsCopy) { die("Unexpected batch config"); } if (IsCopy) - logger::error("UR_L0_COPY_BATCH_SIZE: dynamic batch param " - "#{}: {}", - (int)Ord, (int)Val); + URLOG(ERR, + "UR_L0_COPY_BATCH_SIZE: dynamic batch param " + "#{}: {}", + (int)Ord, (int)Val) else - logger::error("UR_L0_BATCH_SIZE: dynamic batch param #{}: {}", - (int)Ord, (int)Val); + URLOG(ERR, "UR_L0_BATCH_SIZE: dynamic batch param #{}: {}", (int)Ord, + (int)Val) }; } else { // Negative batch sizes are silently ignored. if (IsCopy) - logger::warning("UR_L0_COPY_BATCH_SIZE: ignored negative value"); + URLOG(WARN, "UR_L0_COPY_BATCH_SIZE: ignored negative value") else - logger::warning("UR_L0_BATCH_SIZE: ignored negative value"); + URLOG(WARN, "UR_L0_BATCH_SIZE: ignored negative value") } } return Config; @@ -1219,7 +1221,7 @@ void ur_queue_handle_t_::adjustBatchSizeForFullBatch(bool IsCopy) { ZeCommandListBatchConfig.NumTimesClosedFullThreshold) { if (QueueBatchSize < ZeCommandListBatchConfig.DynamicSizeMax) { QueueBatchSize += ZeCommandListBatchConfig.DynamicSizeStep; - logger::debug("Raising QueueBatchSize to {}", QueueBatchSize); + URLOG(DEBUG, "Raising QueueBatchSize to {}", QueueBatchSize); } CommandBatch.NumTimesClosedEarly = 0; CommandBatch.NumTimesClosedFull = 0; @@ -1246,7 +1248,7 @@ void ur_queue_handle_t_::adjustBatchSizeForPartialBatch(bool IsCopy) { QueueBatchSize = CommandBatch.OpenCommandList->second.size() - 1; if (QueueBatchSize < 1) QueueBatchSize = 1; - logger::debug("Lowering QueueBatchSize to {}", QueueBatchSize); + URLOG(DEBUG, "Lowering QueueBatchSize to {}", QueueBatchSize); CommandBatch.NumTimesClosedEarly = 0; CommandBatch.NumTimesClosedFull = 0; } @@ -1608,14 +1610,15 @@ ur_result_t urQueueReleaseInternal(ur_queue_handle_t Queue) { Queue->clearEndTimeRecordings(); - logger::debug("urQueueRelease(compute) NumTimesClosedFull {}, " - "NumTimesClosedEarly {}", - Queue->ComputeCommandBatch.NumTimesClosedFull, - Queue->ComputeCommandBatch.NumTimesClosedEarly); - logger::debug( - "urQueueRelease(copy) NumTimesClosedFull {}, NumTimesClosedEarly {}", - Queue->CopyCommandBatch.NumTimesClosedFull, - Queue->CopyCommandBatch.NumTimesClosedEarly); + URLOG(DEBUG, + "urQueueRelease(compute) NumTimesClosedFull {}, " + "NumTimesClosedEarly {}", + Queue->ComputeCommandBatch.NumTimesClosedFull, + Queue->ComputeCommandBatch.NumTimesClosedEarly); + URLOG(DEBUG, + "urQueueRelease(copy) NumTimesClosedFull {}, NumTimesClosedEarly {}", + Queue->CopyCommandBatch.NumTimesClosedFull, + Queue->CopyCommandBatch.NumTimesClosedEarly); delete Queue; @@ -2232,10 +2235,11 @@ ur_queue_handle_t_::ur_queue_group_t::getZeQueue(uint32_t *QueueGroupOrdinal) { ZeCommandQueueDesc.flags = ZE_COMMAND_QUEUE_FLAG_EXPLICIT_ONLY; } - logger::debug("[getZeQueue]: create queue ordinal = {}, index = {} " - "(round robin in [{}, {}]) priority = {}", - ZeCommandQueueDesc.ordinal, ZeCommandQueueDesc.index, - LowerIndex, UpperIndex, Priority); + URLOG(DEBUG, + "[getZeQueue]: create queue ordinal = {}, index = {} " + "(round robin in [{}, {}]) priority = {}", + ZeCommandQueueDesc.ordinal, ZeCommandQueueDesc.index, LowerIndex, + UpperIndex, Priority); auto ZeResult = ZE_CALL_NOCHECK( zeCommandQueueCreate, (Queue->Context->ZeContext, Queue->Device->ZeDevice, @@ -2293,7 +2297,8 @@ ur_result_t ur_queue_handle_t_::createCommandList( IsInOrderList = true; } - logger::debug( + URLOG( + DEBUG, "create command list ordinal: {}, type: regular, device: {}, inOrder: {}", QueueGroupOrdinal, Device->ZeDevice, IsInOrderList); @@ -2459,14 +2464,15 @@ ur_command_list_ptr_t &ur_queue_handle_t_::ur_queue_group_t::getImmCmdList() { // If cache didn't contain a command list, create one. if (!ZeCommandList) { - logger::debug("[getZeQueue]: create queue ordinal = {}, index = {} " - "(round robin in [{}, {}]) priority = {}", - ZeCommandQueueDesc.ordinal, ZeCommandQueueDesc.index, - LowerIndex, UpperIndex, Priority); - logger::debug("create command list ordinal: {}, type: immediate, device: " - "{}, inOrder: {}", - ZeCommandQueueDesc.ordinal, Queue->Device->ZeDevice, - isInOrderList); + URLOG(DEBUG, + "[getZeQueue]: create queue ordinal = {}, index = {} " + "(round robin in [{}, {}]) priority = {}", + ZeCommandQueueDesc.ordinal, ZeCommandQueueDesc.index, LowerIndex, + UpperIndex, Priority); + URLOG(DEBUG, + "create command list ordinal: {}, type: immediate, device: " + "{}, inOrder: {}", + ZeCommandQueueDesc.ordinal, Queue->Device->ZeDevice, isInOrderList); ZE_CALL_NOCHECK(zeCommandListCreateImmediate, (Queue->Context->ZeContext, Queue->Device->ZeDevice, diff --git a/source/adapters/level_zero/sampler.cpp b/source/adapters/level_zero/sampler.cpp index 8fdc23390e..3acbab97b7 100644 --- a/source/adapters/level_zero/sampler.cpp +++ b/source/adapters/level_zero/sampler.cpp @@ -78,9 +78,9 @@ ur_result_t urSamplerCreate( ZeSamplerDesc.addressMode = ZE_SAMPLER_ADDRESS_MODE_MIRROR; break; default: - logger::error("urSamplerCreate: unsupported " - "UR_SAMPLER_PROPERTIES_ADDRESSING_MODEE " - "value"); + URLOG(ERR, "urSamplerCreate: unsupported " + "UR_SAMPLER_PROPERTIES_ADDRESSING_MODEE " + "value"); return UR_RESULT_ERROR_INVALID_VALUE; } @@ -89,8 +89,7 @@ ur_result_t urSamplerCreate( else if (Props->filterMode == UR_SAMPLER_FILTER_MODE_LINEAR) ZeSamplerDesc.filterMode = ZE_SAMPLER_FILTER_MODE_LINEAR; else { - logger::error( - "urSamplerCreate: unsupported UR_SAMPLER_FILTER_MODE value"); + URLOG(ERR, "urSamplerCreate: unsupported UR_SAMPLER_FILTER_MODE value"); return UR_RESULT_ERROR_INVALID_VALUE; } } diff --git a/source/adapters/level_zero/usm.cpp b/source/adapters/level_zero/usm.cpp index 19480e83c5..5db2286f92 100644 --- a/source/adapters/level_zero/usm.cpp +++ b/source/adapters/level_zero/usm.cpp @@ -636,7 +636,7 @@ ur_result_t urUSMGetMemAllocInfo( MemAllocaType = UR_USM_TYPE_SHARED; break; default: - logger::error("urUSMGetMemAllocInfo: unexpected usm memory type"); + URLOG(ERR, "urUSMGetMemAllocInfo: unexpected usm memory type"); return UR_RESULT_ERROR_INVALID_VALUE; } return ReturnValue(MemAllocaType); @@ -694,7 +694,7 @@ ur_result_t urUSMGetMemAllocInfo( return UR_RESULT_ERROR_INVALID_VALUE; } default: - logger::error("urUSMGetMemAllocInfo: unsupported ParamName"); + URLOG(ERR, "urUSMGetMemAllocInfo: unsupported ParamName"); return UR_RESULT_ERROR_INVALID_VALUE; } return UR_RESULT_SUCCESS; @@ -975,7 +975,7 @@ umf_result_t L0MemoryProvider::open_ipc_handle(void *IpcData, void **Ptr) { memcpy(&fdRemote, &zeIpcData->zeHandle, sizeof(fdRemote)); fdLocal = ur_duplicate_fd(zeIpcData->pid, fdRemote); if (fdLocal == -1) { - logger::error("duplicating file descriptor from IPC handle failed"); + URLOG(ERR, "duplicating file descriptor from IPC handle failed"); return UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC; } @@ -1056,7 +1056,7 @@ ur_usm_pool_handle_t_::ur_usm_pool_handle_t_(ur_context_handle_t Context, break; } default: { - logger::error("urUSMPoolCreate: unexpected chained stype"); + URLOG(ERR, "urUSMPoolCreate: unexpected chained stype"); throw UsmAllocationException(UR_RESULT_ERROR_INVALID_ARGUMENT); } } diff --git a/source/adapters/level_zero/v2/command_buffer.cpp b/source/adapters/level_zero/v2/command_buffer.cpp index eace40918b..893b6fb6ca 100644 --- a/source/adapters/level_zero/v2/command_buffer.cpp +++ b/source/adapters/level_zero/v2/command_buffer.cpp @@ -19,9 +19,9 @@ namespace { // given context. void checkImmediateAppendSupport(ur_context_handle_t context) { if (!context->getPlatform()->ZeCommandListImmediateAppendExt.Supported) { - logger::error("Adapter v2 is used but " - "the current driver does not support the " - "zeCommandListImmediateAppendCommandListsExp entrypoint."); + URLOG(ERR, "Adapter v2 is used but " + "the current driver does not support the " + "zeCommandListImmediateAppendCommandListsExp entrypoint."); throw UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } } diff --git a/source/adapters/level_zero/v2/command_list_cache.cpp b/source/adapters/level_zero/v2/command_list_cache.cpp index 2a5f7e20e2..5a32c41edf 100644 --- a/source/adapters/level_zero/v2/command_list_cache.cpp +++ b/source/adapters/level_zero/v2/command_list_cache.cpp @@ -70,10 +70,10 @@ command_list_cache_t::createCommandList(const command_list_descriptor_t &desc) { } QueueDesc.pNext = &offloadDesc; - logger::debug("create command list ordinal: {}, type: immediate, device: " - "{}, inOrder: {}", - ImmCmdDesc->Ordinal, ImmCmdDesc->ZeDevice, - ImmCmdDesc->IsInOrder); + URLOG(DEBUG, + "create command list ordinal: {}, type: immediate, device: " + "{}, inOrder: {}", + ImmCmdDesc->Ordinal, ImmCmdDesc->ZeDevice, ImmCmdDesc->IsInOrder); ZE2UR_CALL_THROWS( zeCommandListCreateImmediate, @@ -87,10 +87,10 @@ command_list_cache_t::createCommandList(const command_list_descriptor_t &desc) { CmdListDesc.commandQueueGroupOrdinal = RegCmdDesc.Ordinal; CmdListDesc.pNext = &offloadDesc; - logger::debug("create command list ordinal: {}, type: immediate, device: " - "{}, inOrder: {}", - RegCmdDesc.Ordinal, RegCmdDesc.ZeDevice, - RegCmdDesc.IsInOrder); + URLOG(DEBUG, + "create command list ordinal: {}, type: immediate, device: " + "{}, inOrder: {}", + RegCmdDesc.Ordinal, RegCmdDesc.ZeDevice, RegCmdDesc.IsInOrder); ze_command_list_handle_t ZeCommandList; ZE2UR_CALL_THROWS(zeCommandListCreate, (ZeContext, RegCmdDesc.ZeDevice, diff --git a/source/adapters/level_zero/v2/event.cpp b/source/adapters/level_zero/v2/event.cpp index edccd7f429..73f40f2a88 100644 --- a/source/adapters/level_zero/v2/event.cpp +++ b/source/adapters/level_zero/v2/event.cpp @@ -263,7 +263,8 @@ ur_result_t urEventGetInfo(ur_event_handle_t hEvent, ur_event_info_t propName, return returnValue(hEvent->getCommandType()); } default: - logger::error( + URLOG( + ERR, "Unsupported ParamName in urEventGetInfo: ParamName=ParamName={}(0x{})", propName, logger::toHex(propName)); return UR_RESULT_ERROR_INVALID_VALUE; @@ -310,7 +311,7 @@ ur_result_t urEventGetProfilingInfo( return returnValue(hEvent->getEventEndTimestamp()); } default: - logger::error("urEventGetProfilingInfo: not supported ParamName"); + URLOG(ERR, "urEventGetProfilingInfo: not supported ParamName"); return UR_RESULT_ERROR_INVALID_VALUE; } } @@ -360,7 +361,7 @@ ur_result_t urEventGetProfilingInfo( // return returnValue(uint64_t{0}); default: - logger::error("urEventGetProfilingInfo: not supported ParamName"); + URLOG(ERR, "urEventGetProfilingInfo: not supported ParamName"); return UR_RESULT_ERROR_INVALID_VALUE; } diff --git a/source/adapters/level_zero/v2/event_provider_normal.cpp b/source/adapters/level_zero/v2/event_provider_normal.cpp index 3f7116adf3..842584b1c5 100644 --- a/source/adapters/level_zero/v2/event_provider_normal.cpp +++ b/source/adapters/level_zero/v2/event_provider_normal.cpp @@ -50,7 +50,7 @@ provider_pool::provider_pool(ur_context_handle_t context, queue_type queue, devices.push_back(d->ZeDevice); } - logger::debug("ze_event_pool_desc_t flags set to: {}", desc.flags); + URLOG(DEBUG, "ze_event_pool_desc_t flags set to: {}", desc.flags); ZE2UR_CALL_THROWS(zeEventPoolCreate, (context->getZeHandle(), &desc, devices.size(), diff --git a/source/adapters/level_zero/v2/kernel.cpp b/source/adapters/level_zero/v2/kernel.cpp index db10ff03ff..a8266c2f1c 100644 --- a/source/adapters/level_zero/v2/kernel.cpp +++ b/source/adapters/level_zero/v2/kernel.cpp @@ -262,7 +262,7 @@ ur_result_t ur_kernel_handle_t_::setExecInfo(ur_kernel_exec_info_t propName, ZE2UR_CALL(zeKernelSetCacheConfig, (kernel->hKernel.get(), zeCacheConfig);); } else { - logger::error("urKernelSetExecInfo: unsupported ParamName"); + URLOG(ERR, "urKernelSetExecInfo: unsupported ParamName"); return UR_RESULT_ERROR_INVALID_VALUE; } } @@ -556,9 +556,8 @@ ur_result_t urKernelGetGroupInfo( // No corresponding enumeration in Level Zero return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; default: { - logger::error( - "Unknown ParamName in urKernelGetGroupInfo: ParamName={}(0x{})", - paramName, logger::toHex(paramName)); + URLOG(ERR, "Unknown ParamName in urKernelGetGroupInfo: ParamName={}(0x{})", + paramName, logger::toHex(paramName)); return UR_RESULT_ERROR_INVALID_VALUE; } } @@ -631,9 +630,8 @@ ur_result_t urKernelGetInfo(ur_kernel_handle_t hKernel, return ReturnValue(static_cast(attributes.data())); } default: - logger::error( - "Unsupported ParamName in urKernelGetInfo: ParamName={}(0x{})", - paramName, logger::toHex(paramName)); + URLOG(ERR, "Unsupported ParamName in urKernelGetInfo: ParamName={}(0x{})", + paramName, logger::toHex(paramName)); return UR_RESULT_ERROR_INVALID_VALUE; } diff --git a/source/adapters/level_zero/v2/memory.cpp b/source/adapters/level_zero/v2/memory.cpp index 3ec16e8352..0cd558dd9e 100644 --- a/source/adapters/level_zero/v2/memory.cpp +++ b/source/adapters/level_zero/v2/memory.cpp @@ -97,7 +97,7 @@ ur_integrated_mem_handle_t::ur_integrated_mem_handle_t( this->ptr = usm_unique_ptr_t(rawPtr, [hContext](void *ptr) { auto ret = hContext->getDefaultUSMPool()->free(ptr); if (ret != UR_RESULT_SUCCESS) { - logger::error("Failed to free host memory: {}", ret); + URLOG(ERR, "Failed to free host memory: {}", ret); } }); @@ -178,7 +178,7 @@ void *ur_discrete_mem_handle_t::allocateOnDevice(ur_device_handle_t hDevice, usm_unique_ptr_t(ptr, [hContext = this->hContext](void *ptr) { auto ret = hContext->getDefaultUSMPool()->free(ptr); if (ret != UR_RESULT_SUCCESS) { - logger::error("Failed to free device memory: {}", ret); + URLOG(ERR, "Failed to free device memory: {}", ret); } }); @@ -306,7 +306,7 @@ void *ur_discrete_mem_handle_t::mapHostPtr( if (ownsAlloc) { auto ret = hContext->getDefaultUSMPool()->free(p); if (ret != UR_RESULT_SUCCESS) { - logger::error("Failed to mapped memory: {}", ret); + URLOG(ERR, "Failed to mapped memory: {}", ret); } } }); diff --git a/source/adapters/level_zero/v2/queue_immediate_in_order.cpp b/source/adapters/level_zero/v2/queue_immediate_in_order.cpp index 8da52fe6b6..178136bf4e 100644 --- a/source/adapters/level_zero/v2/queue_immediate_in_order.cpp +++ b/source/adapters/level_zero/v2/queue_immediate_in_order.cpp @@ -124,9 +124,10 @@ ur_queue_immediate_in_order_t::queueGetInfo(ur_queue_info_t propName, } } default: - logger::error("Unsupported ParamName in urQueueGetInfo: " - "ParamName=ParamName={}(0x{})", - propName, logger::toHex(propName)); + URLOG(ERR, + "Unsupported ParamName in urQueueGetInfo: " + "ParamName=ParamName={}(0x{})", + propName, logger::toHex(propName)); return UR_RESULT_ERROR_INVALID_VALUE; } diff --git a/source/adapters/level_zero/v2/usm.cpp b/source/adapters/level_zero/v2/usm.cpp index 4f22221562..a4dbc38a5d 100644 --- a/source/adapters/level_zero/v2/usm.cpp +++ b/source/adapters/level_zero/v2/usm.cpp @@ -235,7 +235,7 @@ ur_result_t ur_usm_pool_handle_t_::free(void *ptr) { if (umfPool) { return umf::umf2urResult(umfPoolFree(umfPool, ptr)); } else { - logger::error("Failed to find pool for pointer: {}", ptr); + URLOG(ERR, "Failed to find pool for pointer: {}", ptr); return UR_RESULT_ERROR_INVALID_VALUE; } } @@ -439,7 +439,7 @@ ur_result_t urUSMGetMemAllocInfo( memAllocType = UR_USM_TYPE_SHARED; break; default: - logger::error("urUSMGetMemAllocInfo: unexpected usm memory type"); + URLOG(ERR, "urUSMGetMemAllocInfo: unexpected usm memory type"); return UR_RESULT_ERROR_INVALID_VALUE; } return ReturnValue(memAllocType); @@ -468,7 +468,7 @@ ur_result_t urUSMGetMemAllocInfo( // TODO return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; default: - logger::error("urUSMGetMemAllocInfo: unsupported ParamName"); + URLOG(ERR, "urUSMGetMemAllocInfo: unsupported ParamName"); return UR_RESULT_ERROR_INVALID_VALUE; } } diff --git a/source/adapters/level_zero/virtual_mem.cpp b/source/adapters/level_zero/virtual_mem.cpp index 092edc8ed1..e04b09d580 100644 --- a/source/adapters/level_zero/virtual_mem.cpp +++ b/source/adapters/level_zero/virtual_mem.cpp @@ -38,8 +38,8 @@ ur_result_t urVirtualMemGranularityGetInfo( return ReturnValue(PageSize); } default: - logger::error("Unsupported propName in urQueueGetInfo: propName={}({})", - propName, propName); + URLOG(ERR, "Unsupported propName in urQueueGetInfo: propName={}({})", + propName, propName); return UR_RESULT_ERROR_INVALID_VALUE; } return UR_RESULT_SUCCESS; @@ -120,8 +120,8 @@ ur_result_t urVirtualMemGetInfo(ur_context_handle_t hContext, return ReturnValue(RetFlags); } default: - logger::error("Unsupported propName in urQueueGetInfo: propName={}({})", - propName, propName); + URLOG(ERR, "Unsupported propName in urQueueGetInfo: propName={}({})", + propName, propName); return UR_RESULT_ERROR_INVALID_VALUE; } diff --git a/source/adapters/native_cpu/common.cpp b/source/adapters/native_cpu/common.cpp index ab7c7a07ea..fb67851a22 100644 --- a/source/adapters/native_cpu/common.cpp +++ b/source/adapters/native_cpu/common.cpp @@ -31,6 +31,6 @@ ur_result_t urGetLastResult(ur_platform_handle_t, const char **ppMessage) { } void detail::ur::die(const char *pMessage) { - logger::always("ur_die: {}", pMessage); + URLOG_ALWAYS("ur_die: {}", pMessage); std::terminate(); } diff --git a/source/adapters/native_cpu/common.hpp b/source/adapters/native_cpu/common.hpp index af0d11c5af..fb65d05051 100644 --- a/source/adapters/native_cpu/common.hpp +++ b/source/adapters/native_cpu/common.hpp @@ -21,23 +21,23 @@ extern thread_local char ErrorMessage[MaxMessageSize]; #define DIE_NO_IMPLEMENTATION \ do { \ - logger::error("Not Implemented : {} - File : {} / Line : {}", \ - __FUNCTION__, __FILE__, __LINE__); \ + URLOG(ERR, "Not Implemented : {} - File : {} / Line : {}", __FUNCTION__, \ + __FILE__, __LINE__); \ \ return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; \ } while (false); #define CONTINUE_NO_IMPLEMENTATION \ do { \ - logger::warning("Not Implemented : {} - File : {} / Line : {}", \ - __FUNCTION__, __FILE__, __LINE__); \ + URLOG(WARN, "Not Implemented : {} - File : {} / Line : {}", __FUNCTION__, \ + __FILE__, __LINE__); \ return UR_RESULT_SUCCESS; \ } while (false); #define CASE_UR_UNSUPPORTED(not_supported) \ case not_supported: \ - logger::error("Unsupported UR case : {} in {}:{}({})", #not_supported, \ - __FUNCTION__, __LINE__, __FILE__); \ + URLOG(ERR, "Unsupported UR case : {} in {}:{}({})", #not_supported, \ + __FUNCTION__, __LINE__, __FILE__); \ return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; /// ------ Error handling, matching OpenCL plugin semantics. diff --git a/source/adapters/native_cpu/device.cpp b/source/adapters/native_cpu/device.cpp index 6deca1ac37..4c7c0fd6b9 100644 --- a/source/adapters/native_cpu/device.cpp +++ b/source/adapters/native_cpu/device.cpp @@ -99,7 +99,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGet(ur_platform_handle_t hPlatform, if (NumEntries == 0) { /// Runtime queries number of devices if (phDevices != nullptr) { - logger::error("Invalid Arguments for urDevicesGet"); + URLOG(ERR, "Invalid Arguments for urDevicesGet"); return UR_RESULT_ERROR_INVALID_VALUE; } return UR_RESULT_SUCCESS; diff --git a/source/adapters/native_cpu/platform.cpp b/source/adapters/native_cpu/platform.cpp index 8e55037079..53fd793b47 100644 --- a/source/adapters/native_cpu/platform.cpp +++ b/source/adapters/native_cpu/platform.cpp @@ -29,7 +29,7 @@ urPlatformGet(ur_adapter_handle_t *, uint32_t, uint32_t NumEntries, if (NumEntries == 0) { if (phPlatforms != nullptr) { - logger::error("Invalid argument combination for urPlatformsGet"); + URLOG(ERR, "Invalid argument combination for urPlatformsGet"); return UR_RESULT_ERROR_INVALID_VALUE; } return UR_RESULT_SUCCESS; diff --git a/source/adapters/opencl/common.cpp b/source/adapters/opencl/common.cpp index 33da43a182..e13712453c 100644 --- a/source/adapters/opencl/common.cpp +++ b/source/adapters/opencl/common.cpp @@ -106,7 +106,7 @@ ur_result_t mapCLErrorToUR(cl_int Result) { } void cl_adapter::die(const char *Message) { - logger::always("ur_die: {}", Message); + URLOG_ALWAYS("ur_die: {}", Message); std::terminate(); } diff --git a/source/common/latency_tracker.hpp b/source/common/latency_tracker.hpp index b8af6c6de5..fd36a553d3 100644 --- a/source/common/latency_tracker.hpp +++ b/source/common/latency_tracker.hpp @@ -64,7 +64,7 @@ static inline latencyValues getValues(const struct hdr_histogram *histogram) { auto ret = hdr_value_at_percentiles(histogram, percentiles, values.percentileValues, numPercentiles); if (ret != 0) { - logger::error("Failed to get percentiles from latency histogram"); + URLOG(ERR, "Failed to get percentiles from latency histogram"); } return values; @@ -137,7 +137,7 @@ class latency_histogram { auto ret = hdr_init(lowestDiscernibleValue, highestTrackableValue, significantFigures, &cHistogram); if (ret != 0) { - logger::error("Failed to initialize latency histogram"); + URLOG(ERR, "Failed to initialize latency histogram"); } histogram = std::unique_ptr( cHistogram, &hdr_close); @@ -153,7 +153,7 @@ class latency_histogram { } if (hdr_min(histogram.get()) == std::numeric_limits::max()) { - logger::info("[{}] latency: no data", name); + URLOG(INFO, "[{}] latency: no data", name); return; } diff --git a/source/common/linux/ur_lib_loader.cpp b/source/common/linux/ur_lib_loader.cpp index 8028154448..8954e3437f 100644 --- a/source/common/linux/ur_lib_loader.cpp +++ b/source/common/linux/ur_lib_loader.cpp @@ -25,10 +25,10 @@ void LibLoader::freeAdapterLibrary(HMODULE handle) { if (handle) { int res = dlclose(handle); if (res) { - logger::error( - "Failed to unload the library with the handle at address {}", handle); + URLOG(ERR, "Failed to unload the library with the handle at address {}", + handle); } else { - logger::info("unloaded adapter 0x{}", handle); + URLOG(INFO, "unloaded adapter 0x{}", handle); } } } @@ -40,10 +40,10 @@ LibLoader::loadAdapterLibrary(const char *name) { bool deepbind = getenv_tobool(DEEP_BIND_ENV); if (deepbind) { #if defined(SANITIZER_ANY) - logger::warning( - "Enabling RTLD_DEEPBIND while running under a sanitizer is likely " - "to cause issues. Consider disabling {} environment variable.", - DEEP_BIND_ENV); + URLOG(WARN, + "Enabling RTLD_DEEPBIND while running under a sanitizer is likely " + "to cause issues. Consider disabling {} environment variable.", + DEEP_BIND_ENV); #endif mode |= RTLD_DEEPBIND; } @@ -51,17 +51,17 @@ LibLoader::loadAdapterLibrary(const char *name) { HMODULE handle = dlopen(name, mode); if (!handle) { char *err = dlerror(); - logger::info("failed to load adapter '{}' with error: {}", name, - err ? err : "unknown error"); + URLOG(INFO, "failed to load adapter '{}' with error: {}", name, + err ? err : "unknown error"); } else { #if defined(ADD_FULL_PATH_LOG) struct link_map *dlinfo_map; if (dlinfo(handle, RTLD_DI_LINKMAP, &dlinfo_map) == 0) { - logger::info("loaded adapter 0x{} ({}) from {}", handle, name, - dlinfo_map->l_name); + URLOG(INFO, "loaded adapter 0x{} ({}) from {}", handle, name, + dlinfo_map->l_name); } else #endif - logger::info("loaded adapter 0x{} ({})", handle, name); + URLOG(INFO, "loaded adapter 0x{} ({})", handle, name); } return std::unique_ptr(handle); } diff --git a/source/common/logger/ur_logger.hpp b/source/common/logger/ur_logger.hpp index 9d640be0e2..a8c7357edc 100644 --- a/source/common/logger/ur_logger.hpp +++ b/source/common/logger/ur_logger.hpp @@ -53,6 +53,22 @@ template inline void always(const char *format, Args &&...args) { get_logger().always(format, std::forward(args)...); } +#ifdef SRC_PATH_SIZE +#define SHORT_FILE ((__FILE__) + (SRC_PATH_SIZE)) +#else +#define SHORT_FILE __FILE__ +#endif + +#define URLOG_IMPL(level, format, ...) \ + { \ + ::logger::get_logger().log(logger::Level::level, format " <{}:{}>", \ + __VA_ARGS__); \ + } +#define URLOG(...) URLOG_IMPL(__VA_ARGS__, SHORT_FILE, __LINE__) + +#define URLOG_ALWAYS_IMPL(format, ...) \ + { ::logger::get_logger().always(format " <{}:{}>", __VA_ARGS__); } +#define URLOG_ALWAYS(...) URLOG_ALWAYS_IMPL(__VA_ARGS__, SHORT_FILE, __LINE__) template inline void debug(const logger::LegacyMessage &p, const char *format, diff --git a/source/common/umf_helpers.hpp b/source/common/umf_helpers.hpp index af8659dd56..fdc53c1492 100644 --- a/source/common/umf_helpers.hpp +++ b/source/common/umf_helpers.hpp @@ -263,7 +263,7 @@ inline ur_result_t umf2urResult(umf_result_t umfResult) { umfMemoryProviderGetLastNativeError(hProvider, &Msg, &Err); if (Msg) { - logger::error("UMF failed with: {}", Msg); + URLOG(ERR, "UMF failed with: {}", Msg); } return getProviderNativeError(umfMemoryProviderGetName(hProvider), Err); diff --git a/source/common/ur_pool_manager.hpp b/source/common/ur_pool_manager.hpp index 2913c8e3af..61f67e4e76 100644 --- a/source/common/ur_pool_manager.hpp +++ b/source/common/ur_pool_manager.hpp @@ -271,7 +271,7 @@ template struct pool_manager { ur_result_t addPool(const D &desc, umf::pool_unique_handle_t &&hPool) noexcept { if (!descToPoolMap.try_emplace(desc, std::move(hPool)).second) { - logger::error("Pool for pool descriptor: {}, already exists", desc); + URLOG(ERR, "Pool for pool descriptor: {}, already exists", desc); return UR_RESULT_ERROR_INVALID_ARGUMENT; } @@ -281,8 +281,7 @@ template struct pool_manager { std::optional getPool(const D &desc) noexcept { auto it = descToPoolMap.find(desc); if (it == descToPoolMap.end()) { - logger::error("Pool descriptor doesn't match any existing pool: {}", - desc); + URLOG(ERR, "Pool descriptor doesn't match any existing pool: {}", desc); return std::nullopt; } diff --git a/source/common/ur_util.cpp b/source/common/ur_util.cpp index c1e224d0f0..483ab74d3a 100644 --- a/source/common/ur_util.cpp +++ b/source/common/ur_util.cpp @@ -45,14 +45,14 @@ int ur_duplicate_fd(int pid, int fd_in) { errno = 0; int pid_fd = syscall(__NR_pidfd_open, pid, 0); if (pid_fd == -1) { - logger::error("__NR_pidfd_open"); + URLOG(ERR, "__NR_pidfd_open"); return -1; } int fd_dup = syscall(__NR_pidfd_getfd, pid_fd, fd_in, 0); close(pid_fd); if (fd_dup == -1) { - logger::error("__NR_pidfd_getfd"); + URLOG(ERR, "__NR_pidfd_getfd"); return -1; } @@ -63,7 +63,7 @@ int ur_duplicate_fd(int pid, int fd_in) { (void)pid; // unused (void)fd_in; // unused errno = ENOTSUP; // unsupported - logger::error("__NR_pidfd_open or __NR_pidfd_getfd not available"); + URLOG(ERR, "__NR_pidfd_open or __NR_pidfd_getfd not available"); return -1; #endif /* defined(__NR_pidfd_open) && defined(__NR_pidfd_getfd) */ } diff --git a/source/common/windows/ur_lib_loader.cpp b/source/common/windows/ur_lib_loader.cpp index a3a86c2e7c..f6906b39a4 100644 --- a/source/common/windows/ur_lib_loader.cpp +++ b/source/common/windows/ur_lib_loader.cpp @@ -17,11 +17,10 @@ void LibLoader::freeAdapterLibrary(HMODULE handle) { if (handle) { BOOL res = FreeLibrary(handle); if (!res) { - logger::error( - "Failed to unload the library with the handle at address 0x{}", - handle); + URLOG(ERR, "Failed to unload the library with the handle at address 0x{}", + handle); } else { - logger::info("unloaded adapter 0x{}", handle); + URLOG(INFO, "unloaded adapter 0x{}", handle); } } } @@ -29,11 +28,11 @@ void LibLoader::freeAdapterLibrary(HMODULE handle) { std::unique_ptr LibLoader::loadAdapterLibrary(const char *name) { if (HMODULE handle = LoadLibraryExA(name, nullptr, 0)) { - logger::info("loaded adapter 0x{}: {}", handle, name); + URLOG(INFO, "loaded adapter 0x{}: {}", handle, name); return std::unique_ptr{handle}; } else { - logger::debug("loading adapter failed with error {}: {}", GetLastError(), - name); + URLOG(DEBUG, "loading adapter failed with error {}: {}", GetLastError(), + name); } return nullptr; } diff --git a/source/loader/ur_adapter_registry.hpp b/source/loader/ur_adapter_registry.hpp index e59c71fb23..eaac2a316c 100644 --- a/source/loader/ur_adapter_registry.hpp +++ b/source/loader/ur_adapter_registry.hpp @@ -28,16 +28,17 @@ class AdapterRegistry { try { forceLoadedAdaptersOpt = getenv_to_vec("UR_ADAPTERS_FORCE_LOAD"); } catch (const std::invalid_argument &e) { - logger::error(e.what()); + URLOG(ERR, "{}", e.what()); } if (forceLoadedAdaptersOpt.has_value()) { for (const auto &s : forceLoadedAdaptersOpt.value()) { auto path = fs::path(s); if (path.filename().extension() == STATIC_LIBRARY_EXTENSION) { - logger::warning("UR_ADAPTERS_FORCE_LOAD contains a path to a static" - "library {}, it will be skipped", - s); + URLOG(WARN, + "UR_ADAPTERS_FORCE_LOAD contains a path to a static" + "library {}, it will be skipped", + s); continue; } @@ -45,16 +46,17 @@ class AdapterRegistry { try { exists = fs::exists(path); } catch (std::exception &e) { - logger::error(e.what()); + URLOG(ERR, "{}", e.what()); } if (exists) { forceLoaded = true; adaptersLoadPaths.emplace_back(std::vector{std::move(path)}); } else { - logger::warning("Detected nonexistent path {} in environment " - "variable UR_ADAPTERS_FORCE_LOAD", - s); + URLOG(WARN, + "Detected nonexistent path {} in environment " + "variable UR_ADAPTERS_FORCE_LOAD", + s); } } } else { @@ -137,7 +139,7 @@ class AdapterRegistry { try { pathStringsOpt = getenv_to_vec("UR_ADAPTERS_SEARCH_PATH"); } catch (const std::invalid_argument &e) { - logger::error(e.what()); + URLOG(ERR, "{}", e.what()); return std::nullopt; } @@ -148,9 +150,10 @@ class AdapterRegistry { if (fs::exists(path)) { paths.emplace_back(path); } else { - logger::warning("Detected nonexistent path {} in environmental " - "variable UR_ADAPTERS_SEARCH_PATH", - s); + URLOG(WARN, + "Detected nonexistent path {} in environmental " + "variable UR_ADAPTERS_SEARCH_PATH", + s); } } } @@ -169,12 +172,12 @@ class AdapterRegistry { } catch (...) { // If the selector is malformed, then we ignore selector and return // success. - logger::error("ERROR: missing backend, format of filter = " - "'[!]backend:filterStrings'"); + URLOG(ERR, "ERROR: missing backend, format of filter = " + "'[!]backend:filterStrings'"); return UR_RESULT_SUCCESS; } - logger::debug("getenv_to_map parsed env var and {} a map", - (odsEnvMap.has_value() ? "produced" : "failed to produce")); + URLOG(DEBUG, "getenv_to_map parsed env var and {} a map", + (odsEnvMap.has_value() ? "produced" : "failed to produce")); // if the ODS env var is not set at all, then pretend it was set to the // default @@ -188,24 +191,24 @@ class AdapterRegistry { if (backend.empty()) { // FIXME: never true because getenv_to_map rejects this case // malformed term: missing backend -- output ERROR, then continue - logger::error("ERROR: missing backend, format of filter = " - "'[!]backend:filterStrings'"); + URLOG(ERR, "ERROR: missing backend, format of filter = " + "'[!]backend:filterStrings'"); continue; } - logger::debug("ONEAPI_DEVICE_SELECTOR Pre-Filter with backend '{}' " - "and platform library name '{}'", - backend, platformBackendName); + URLOG(DEBUG, + "ONEAPI_DEVICE_SELECTOR Pre-Filter with backend '{}' " + "and platform library name '{}'", + backend, platformBackendName); enum FilterType { AcceptFilter, DiscardFilter, } termType = (backend.front() != '!') ? AcceptFilter : DiscardFilter; - logger::debug( - "termType is {}", - (termType != AcceptFilter ? "DiscardFilter" : "AcceptFilter")); + URLOG(DEBUG, "termType is {}", + (termType != AcceptFilter ? "DiscardFilter" : "AcceptFilter")); if (termType != AcceptFilter) { - logger::debug("DEBUG: backend was '{}'", backend); + URLOG(DEBUG, "DEBUG: backend was '{}'", backend); backend.erase(backend.cbegin()); - logger::debug("DEBUG: backend now '{}'", backend); + URLOG(DEBUG, "DEBUG: backend now '{}'", backend); } // Verify that the backend string is valid, otherwise ignore the backend. @@ -214,9 +217,10 @@ class AdapterRegistry { (strcmp(backend.c_str(), "opencl") != 0) && (strcmp(backend.c_str(), "cuda") != 0) && (strcmp(backend.c_str(), "hip") != 0)) { - logger::debug("ONEAPI_DEVICE_SELECTOR Pre-Filter with illegal " - "backend '{}' ", - backend); + URLOG(DEBUG, + "ONEAPI_DEVICE_SELECTOR Pre-Filter with illegal " + "backend '{}' ", + backend); continue; } @@ -231,9 +235,10 @@ class AdapterRegistry { bool backendFound = nameFound != std::string::npos; if (termType == AcceptFilter) { if (backend.front() != '*' && !backendFound) { - logger::debug("The ONEAPI_DEVICE_SELECTOR backend name '{}' was not " - "found in the platform library name '{}'", - backend, platformBackendName); + URLOG(DEBUG, + "The ONEAPI_DEVICE_SELECTOR backend name '{}' was not " + "found in the platform library name '{}'", + backend, platformBackendName); acceptLibrary = false; continue; } else if (backend.front() == '*' || backendFound) { @@ -242,9 +247,10 @@ class AdapterRegistry { } else { if (backendFound || backend.front() == '*') { acceptLibrary = false; - logger::debug("The ONEAPI_DEVICE_SELECTOR backend name for discard " - "'{}' was found in the platform library name '{}'", - backend, platformBackendName); + URLOG(DEBUG, + "The ONEAPI_DEVICE_SELECTOR backend name for discard " + "'{}' was found in the platform library name '{}'", + backend, platformBackendName); continue; } } @@ -267,9 +273,10 @@ class AdapterRegistry { if (loaderPreFilter) { if (readPreFilterODS(adapterName) != UR_RESULT_SUCCESS) { - logger::debug("The adapter '{}' was removed based on the " - "pre-filter from ONEAPI_DEVICE_SELECTOR.", - adapterName); + URLOG(DEBUG, + "The adapter '{}' was removed based on the " + "pre-filter from ONEAPI_DEVICE_SELECTOR.", + adapterName); continue; } } diff --git a/source/loader/ur_lib.cpp b/source/loader/ur_lib.cpp index ef46895861..b85dba31ee 100644 --- a/source/loader/ur_lib.cpp +++ b/source/loader/ur_lib.cpp @@ -76,7 +76,7 @@ __urdlllocal ur_result_t context_t::Init( ur_result_t result; const char *logger_name = "loader"; logger::init(logger_name); - logger::debug("Logger {} initialized successfully!", logger_name); + URLOG(DEBUG, "Logger {} initialized successfully!", logger_name); result = ur_loader::getContext()->init(); @@ -215,7 +215,7 @@ ur_result_t urLoaderTearDown() { ur_result_t result = ret == 0 ? UR_RESULT_SUCCESS : UR_RESULT_ERROR_UNINITIALIZED; - logger::info("---> urLoaderTearDown() -> {}", result); + URLOG(INFO, "---> urLoaderTearDown() -> {}", result); return result; } @@ -324,9 +324,8 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform, // `std::map` with `std::queue>` or // something similar.) auto maybeEnvVarMap = getenv_to_map("ONEAPI_DEVICE_SELECTOR", false); - logger::debug( - "getenv_to_map parsed env var and {} a map", - (maybeEnvVarMap.has_value() ? "produced" : "failed to produce")); + URLOG(DEBUG, "getenv_to_map parsed env var and {} a map", + (maybeEnvVarMap.has_value() ? "produced" : "failed to produce")); // if the ODS env var is not set at all, then pretend it was set to the // default @@ -461,23 +460,22 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform, if (backend.empty()) { // FIXME: never true because getenv_to_map rejects this case // malformed term: missing backend -- output ERROR, then continue - logger::error("ERROR: missing backend, format of filter = " - "'[!]backend:filterStrings'"); + URLOG(ERR, "ERROR: missing backend, format of filter = " + "'[!]backend:filterStrings'"); continue; } enum FilterType { AcceptFilter, DiscardFilter, } termType = (backend.front() != '!') ? AcceptFilter : DiscardFilter; - logger::debug( - "termType is {}", - (termType != AcceptFilter ? "DiscardFilter" : "AcceptFilter")); + URLOG(DEBUG, "termType is {}", + (termType != AcceptFilter ? "DiscardFilter" : "AcceptFilter")); auto &deviceList = (termType != AcceptFilter) ? discardDeviceList : acceptDeviceList; if (termType != AcceptFilter) { - logger::debug("DEBUG: backend was '{}'", backend); + URLOG(DEBUG, "DEBUG: backend was '{}'", backend); backend.erase(backend.cbegin()); - logger::debug("DEBUG: backend now '{}'", backend); + URLOG(DEBUG, "DEBUG: backend now '{}'", backend); } // Note the hPlatform -> platformBackend -> platformBackendName conversion // above guarantees minimal sanity for the comparison with backend from the @@ -492,13 +490,13 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform, })) { // irrelevant term for current request: different backend -- silently // ignore - logger::error("unrecognised backend '{}'", backend); + URLOG(ERR, "unrecognised backend '{}'", backend); return UR_RESULT_ERROR_INVALID_VALUE; } if (termPair.second.size() == 0) { // malformed term: missing filterStrings -- output ERROR - logger::error("missing filterStrings, format of filter = " - "'[!]backend:filterStrings'"); + URLOG(ERR, "missing filterStrings, format of filter = " + "'[!]backend:filterStrings'"); return UR_RESULT_ERROR_INVALID_VALUE; } if (std::find_if(termPair.second.cbegin(), termPair.second.cend(), @@ -506,8 +504,8 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform, termPair.second.cend()) { // FIXME: never true because getenv_to_map rejects this case // malformed term: missing filterString -- output warning, then continue - logger::warning("WARNING: empty filterString, format of filterStrings " - "= 'filterString[,filterString[,...]]'"); + URLOG(WARN, "WARNING: empty filterString, format of filterStrings " + "= 'filterString[,filterString[,...]]'"); continue; } if (std::find_if(termPair.second.cbegin(), termPair.second.cend(), @@ -515,8 +513,8 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform, return std::count(s.cbegin(), s.cend(), '.') > 2; }) != termPair.second.cend()) { // malformed term: too many dots in filterString - logger::error("too many dots in filterString, format of " - "filterString = 'root[.sub[.subsub]]'"); + URLOG(ERR, "too many dots in filterString, format of " + "filterString = 'root[.sub[.subsub]]'"); return UR_RESULT_ERROR_INVALID_VALUE; } if (std::find_if(termPair.second.cbegin(), termPair.second.cend(), @@ -537,7 +535,7 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform, return false; // no BAD things, so must be okay }) != termPair.second.cend()) { // malformed term: star dot no-star in filterString - logger::error("invalid wildcard in filterString, '*.' => '*.*'"); + URLOG(ERR, "invalid wildcard in filterString, '*.' => '*.*'"); return UR_RESULT_ERROR_INVALID_VALUE; } @@ -596,10 +594,9 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform, 0, 0, nullptr}); } - logger::debug("DEBUG: size of acceptDeviceList = {}", - acceptDeviceList.size()); - logger::debug("DEBUG: size of discardDeviceList = {}", - discardDeviceList.size()); + URLOG(DEBUG, "DEBUG: size of acceptDeviceList = {}", acceptDeviceList.size()); + URLOG(DEBUG, "DEBUG: size of discardDeviceList = {}", + discardDeviceList.size()); std::vector rootDevices; std::vector subDevices; @@ -725,50 +722,50 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform, // is a subsubdevice filter, then it must be '*.*.*' matches = (filter.hwType == device.hwType) || (filter.hwType == DeviceHardwareType::UR_DEVICE_TYPE_ALL); - logger::debug("DEBUG: In ApplyFilter, if block case 1, matches = {}", - matches); + URLOG(DEBUG, "DEBUG: In ApplyFilter, if block case 1, matches = {}", + matches); } else if (filter.rootId != device.rootId) { // root part in filter is a number but does not match the number in the // root part of device matches = false; - logger::debug("DEBUG: In ApplyFilter, if block case 2, matches = ", - matches); + URLOG(DEBUG, + "DEBUG: In ApplyFilter, if block case 2, matches = ", matches); } else if (filter.level == DevicePartLevel::ROOT) { // this is a root device filter with a number that matches matches = true; - logger::debug("DEBUG: In ApplyFilter, if block case 3, matches = ", - matches); + URLOG(DEBUG, + "DEBUG: In ApplyFilter, if block case 3, matches = ", matches); } else if (filter.subId == DeviceIdTypeALL) { // sub type of star always matches (when root part matches, which we // already know here) if this is a subdevice filter, then it must be // 'matches.*' if this is a subsubdevice filter, then it must be // 'matches.*.*' matches = true; - logger::debug("DEBUG: In ApplyFilter, if block case 4, matches = ", - matches); + URLOG(DEBUG, + "DEBUG: In ApplyFilter, if block case 4, matches = ", matches); } else if (filter.subId != device.subId) { // sub part in filter is a number but does not match the number in the sub // part of device matches = false; - logger::debug("DEBUG: In ApplyFilter, if block case 5, matches = ", - matches); + URLOG(DEBUG, + "DEBUG: In ApplyFilter, if block case 5, matches = ", matches); } else if (filter.level == DevicePartLevel::SUB) { // this is a sub device number filter, numbers match in both parts matches = true; - logger::debug("DEBUG: In ApplyFilter, if block case 6, matches = ", - matches); + URLOG(DEBUG, + "DEBUG: In ApplyFilter, if block case 6, matches = ", matches); } else if (filter.subsubId == DeviceIdTypeALL) { // subsub type of star always matches (when other parts match, which we // already know here) this is a subsub device filter, it must be // 'matches.matches.*' matches = true; - logger::debug("DEBUG: In ApplyFilter, if block case 7, matches = ", - matches); + URLOG(DEBUG, + "DEBUG: In ApplyFilter, if block case 7, matches = ", matches); } else { // this is a subsub device filter, numbers in all three parts match matches = (filter.subsubId == device.subsubId); - logger::debug("DEBUG: In ApplyFilter, if block case 8, matches = ", - matches); + URLOG(DEBUG, + "DEBUG: In ApplyFilter, if block case 8, matches = ", matches); } return matches; }; @@ -832,10 +829,11 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform, subSubDevices.end()); } if (numAlreadySelected == selectedDevices.size()) { - logger::warning("WARNING: an accept term was ignored because it " - "does not select any additional devices" - "selectedDevices.size() = {}", - selectedDevices.size()); + URLOG(WARN, + "WARNING: an accept term was ignored because it " + "does not select any additional devices" + "selectedDevices.size() = {}", + selectedDevices.size()); } } diff --git a/test/unit/logger/env_var.cpp b/test/unit/logger/env_var.cpp index faf7a15d88..2171afe70f 100644 --- a/test/unit/logger/env_var.cpp +++ b/test/unit/logger/env_var.cpp @@ -8,17 +8,17 @@ ////////////////////////////////////////////////////////////////////////////// TEST_F(LoggerFromEnvVar, DebugMessage) { - logger::debug("Test message: {}", "success"); + URLOG(DEBUG, "Test message: {}", "success"); } TEST_F(LoggerFromEnvVar, InfoMessage) { - logger::info("Test message: {}", "success"); + URLOG(INFO, "Test message: {}", "success"); } TEST_F(LoggerFromEnvVar, WarningMessage) { - logger::warning("Test message: {}", "success"); + URLOG(WARN, "Test message: {}", "success"); } TEST_F(LoggerFromEnvVar, ErrorMessage) { - logger::error("Test message: {}", "success"); + URLOG(ERR, "Test message: {}", "success"); }