From 953c95c7559829c2be3e55e9c8c434b9d9284448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Plewa?= Date: Wed, 8 Nov 2023 16:49:22 +0100 Subject: [PATCH] change urprint to the new logger framework MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ɓukasz Plewa --- source/adapters/level_zero/adapter.hpp | 2 + source/adapters/level_zero/command_buffer.cpp | 57 +++++++++--------- source/adapters/level_zero/common.cpp | 18 ++---- source/adapters/level_zero/common.hpp | 6 -- source/adapters/level_zero/context.cpp | 6 +- source/adapters/level_zero/device.cpp | 23 ++++---- source/adapters/level_zero/event.cpp | 23 ++++---- source/adapters/level_zero/image.cpp | 37 ++++++------ source/adapters/level_zero/kernel.cpp | 44 +++++++------- source/adapters/level_zero/memory.cpp | 56 +++++++++--------- source/adapters/level_zero/platform.cpp | 6 +- source/adapters/level_zero/program.cpp | 10 ++-- source/adapters/level_zero/queue.cpp | 58 +++++++++---------- source/adapters/level_zero/sampler.cpp | 16 ++--- source/adapters/level_zero/usm.cpp | 9 +-- source/adapters/level_zero/usm_p2p.cpp | 5 +- 16 files changed, 191 insertions(+), 185 deletions(-) diff --git a/source/adapters/level_zero/adapter.hpp b/source/adapters/level_zero/adapter.hpp index 22bb032d75..93280580d8 100644 --- a/source/adapters/level_zero/adapter.hpp +++ b/source/adapters/level_zero/adapter.hpp @@ -8,12 +8,14 @@ // //===----------------------------------------------------------------------===// +#include "logger/ur_logger.hpp" #include #include struct ur_adapter_handle_t_ { std::atomic RefCount = 0; std::mutex Mutex; + logger::Logger &logger = logger::get_logger("level_zero"); }; extern ur_adapter_handle_t_ Adapter; diff --git a/source/adapters/level_zero/command_buffer.cpp b/source/adapters/level_zero/command_buffer.cpp index 7ba3cfae4d..672846994e 100644 --- a/source/adapters/level_zero/command_buffer.cpp +++ b/source/adapters/level_zero/command_buffer.cpp @@ -8,6 +8,7 @@ // //===----------------------------------------------------------------------===// #include "command_buffer.hpp" +#include "logger/ur_logger.hpp" #include "ur_level_zero.hpp" /* Command-buffer Extension @@ -182,16 +183,17 @@ ur_result_t calculateKernelWorkDimensions( --GroupSize[I]; } if (GlobalWorkSize[I] / GroupSize[I] > UINT32_MAX) { - urPrint("urCommandBufferAppendKernelLaunchExp: can't find a WG size " - "suitable for global work size > UINT32_MAX\n"); + logger::debug( + "urCommandBufferAppendKernelLaunchExp: 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]; } - urPrint( - "urCommandBufferAppendKernelLaunchExp: using computed WG size = {%d, " - "%d, %d}\n", - WG[0], WG[1], WG[2]); + logger::debug("urCommandBufferAppendKernelLaunchExp: using computed WG " + "size = {{{}, " + "{}, {}}}", + WG[0], WG[1], WG[2]); } } @@ -219,30 +221,33 @@ ur_result_t calculateKernelWorkDimensions( break; default: - urPrint("urCommandBufferAppendKernelLaunchExp: unsupported work_dim\n"); + logger::error("urCommandBufferAppendKernelLaunchExp: unsupported work_dim"); return UR_RESULT_ERROR_INVALID_VALUE; } // Error handling for non-uniform group size case if (GlobalWorkSize[0] != size_t(ZeThreadGroupDimensions.groupCountX) * WG[0]) { - urPrint("urCommandBufferAppendKernelLaunchExp: invalid work_dim. The range " - "is not a " - "multiple of the group size in the 1st dimension\n"); + logger::error( + "urCommandBufferAppendKernelLaunchExp: 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 (GlobalWorkSize[1] != size_t(ZeThreadGroupDimensions.groupCountY) * WG[1]) { - urPrint("urCommandBufferAppendKernelLaunchExp: invalid work_dim. The range " - "is not a " - "multiple of the group size in the 2nd dimension\n"); + logger::error( + "urCommandBufferAppendKernelLaunchExp: 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 (GlobalWorkSize[2] != size_t(ZeThreadGroupDimensions.groupCountZ) * WG[2]) { - urPrint("urCommandBufferAppendKernelLaunchExp: invalid work_dim. The range " - "is not a " - "multiple of the group size in the 3rd dimension\n"); + logger::error( + "urCommandBufferAppendKernelLaunchExp: 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; } @@ -306,9 +311,9 @@ static ur_result_t enqueueCommandBufferMemCopyHelper( (CommandBuffer->ZeCommandList, Dst, Src, Size, LaunchEvent->ZeEvent, ZeEventList.size(), ZeEventList.data())); - urPrint("calling zeCommandListAppendMemoryCopy() with" - " ZeEvent %#" PRIxPTR "\n", - ur_cast(LaunchEvent->ZeEvent)); + logger::debug("calling zeCommandListAppendMemoryCopy() with" + " ZeEvent {}", + ur_cast(LaunchEvent->ZeEvent)); return UR_RESULT_SUCCESS; } @@ -372,9 +377,9 @@ static ur_result_t enqueueCommandBufferMemCopyRectHelper( DstSlicePitch, Src, &ZeSrcRegion, SrcPitch, SrcSlicePitch, LaunchEvent->ZeEvent, ZeEventList.size(), ZeEventList.data())); - urPrint("calling zeCommandListAppendMemoryCopyRegion() with" - " ZeEvent %#" PRIxPTR "\n", - ur_cast(LaunchEvent->ZeEvent)); + logger::debug("calling zeCommandListAppendMemoryCopyRegion() with" + " ZeEvent {}", + ur_cast(LaunchEvent->ZeEvent)); return UR_RESULT_SUCCESS; } @@ -483,7 +488,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp( if (GlobalWorkOffset != NULL) { if (!CommandBuffer->Context->getPlatform() ->ZeDriverGlobalOffsetExtensionFound) { - urPrint("No global offset extension found on this driver\n"); + logger::debug("No global offset extension found on this driver"); return UR_RESULT_ERROR_INVALID_VALUE; } @@ -538,9 +543,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp( &ZeThreadGroupDimensions, LaunchEvent->ZeEvent, ZeEventList.size(), ZeEventList.data())); - urPrint("calling zeCommandListAppendLaunchKernel() with" - " ZeEvent %#" PRIxPTR "\n", - ur_cast(LaunchEvent->ZeEvent)); + logger::debug("calling zeCommandListAppendLaunchKernel() with" + " ZeEvent {}", + ur_cast(LaunchEvent->ZeEvent)); return UR_RESULT_SUCCESS; } diff --git a/source/adapters/level_zero/common.cpp b/source/adapters/level_zero/common.cpp index eb0f34307c..09a765a510 100644 --- a/source/adapters/level_zero/common.cpp +++ b/source/adapters/level_zero/common.cpp @@ -9,6 +9,7 @@ //===----------------------------------------------------------------------===// #include "common.hpp" +#include "logger/ur_logger.hpp" #include "usm.hpp" ur_result_t ze2urResult(ze_result_t ZeResult) { @@ -63,15 +64,6 @@ ur_result_t ze2urResult(ze_result_t ZeResult) { } } -void urPrint(const char *Format, ...) { - if (UrL0Debug & UR_L0_DEBUG_BASIC) { - va_list Args; - va_start(Args, Format); - vfprintf(stderr, Format, Args); - va_end(Args); - } -} - usm::DisjointPoolAllConfigs DisjointPoolConfigInstance = InitializeDisjointPoolConfig(); @@ -84,8 +76,8 @@ bool setEnvVar(const char *name, const char *value) { int Res = setenv(name, value, 1); #endif if (Res != 0) { - urPrint("UR L0 Adapter was unable to set the environment variable: %s\n", - name); + logger::debug( + "UR L0 Adapter was unable to set the environment variable: {}", name); return false; } return true; @@ -147,7 +139,7 @@ inline 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) { - urPrint("ZE ---> %s%s\n", ZeName, ZeArgs); + logger::debug("ZE ---> {}{}", ZeName, ZeArgs); if (UrL0Debug & UR_L0_DEBUG_CALL_COUNT) { ++(*ZeCallCount)[ZeName]; @@ -156,7 +148,7 @@ ze_result_t ZeCall::doCall(ze_result_t ZeResult, const char *ZeName, if (ZeResult && TraceError) { const char *ErrorString = "Unknown"; zeParseError(ZeResult, ErrorString); - urPrint("Error (%s) in %s\n", ErrorString, ZeName); + logger::error("Error ({}) in {}", ErrorString, ZeName); } return ZeResult; } diff --git a/source/adapters/level_zero/common.hpp b/source/adapters/level_zero/common.hpp index 7c2ac7f8be..305690e7c9 100644 --- a/source/adapters/level_zero/common.hpp +++ b/source/adapters/level_zero/common.hpp @@ -252,9 +252,6 @@ class ZeCall { // setting environment variables. bool setEnvVar(const char *name, const char *value); -// Prints to stderr if UR_L0_DEBUG allows it -void urPrint(const char *Format, ...); - // Helper for one-liner validation #define UR_ASSERT(condition, error) \ if (!(condition)) \ @@ -297,9 +294,6 @@ template struct ZesStruct : public T { // setting environment variables. bool setEnvVar(const char *name, const char *value); -// Prints to stderr if UR_L0_DEBUG allows it -void urPrint(const char *Format, ...); - // Helper for one-liner validation #define UR_ASSERT(condition, error) \ if (!(condition)) \ diff --git a/source/adapters/level_zero/context.cpp b/source/adapters/level_zero/context.cpp index 2bd893b043..c693e52be2 100644 --- a/source/adapters/level_zero/context.cpp +++ b/source/adapters/level_zero/context.cpp @@ -14,6 +14,7 @@ #include #include "context.hpp" +#include "logger/ur_logger.hpp" #include "ur_level_zero.hpp" UR_APIEXPORT ur_result_t UR_APICALL urContextCreate( @@ -174,7 +175,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urContextSetExtendedDeleter( std::ignore = Context; std::ignore = Deleter; std::ignore = UserData; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -508,7 +509,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; - urPrint("ze_event_pool_desc_t flags set to: %d\n", ZeEventPoolDesc.flags); + logger::debug("ze_event_pool_desc_t flags set to: {}", + ZeEventPoolDesc.flags); std::vector ZeDevices; std::for_each( diff --git a/source/adapters/level_zero/device.cpp b/source/adapters/level_zero/device.cpp index 35e48931b2..67fe797dcc 100644 --- a/source/adapters/level_zero/device.cpp +++ b/source/adapters/level_zero/device.cpp @@ -9,6 +9,7 @@ //===----------------------------------------------------------------------===// #include "device.hpp" +#include "logger/ur_logger.hpp" #include "ur_level_zero.hpp" #include #include @@ -65,7 +66,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGet( break; default: Matched = false; - urPrint("Unknown device type"); + logger::warning("Unknown device type"); break; } if (Matched) @@ -114,7 +115,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( case ZE_DEVICE_TYPE_FPGA: return ReturnValue(UR_DEVICE_TYPE_FPGA); default: - urPrint("This device type is not supported\n"); + logger::error("This device type is not supported"); return UR_RESULT_ERROR_INVALID_VALUE; } } @@ -799,8 +800,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( } default: - urPrint("Unsupported ParamName in urGetDeviceInfo\n"); - urPrint("ParamName=%d(0x%x)\n", ParamName, ParamName); + logger::error("Unsupported ParamName in urGetDeviceInfo"); + logger::error("ParamName={}", ParamName); return UR_RESULT_ERROR_INVALID_VALUE; } @@ -842,8 +843,8 @@ getRangeOfAllowedCopyEngines(const ur_device_handle_t &Device) { int UpperCopyEngineIndex = std::stoi(CopyEngineRange.substr(pos + 1)); if ((LowerCopyEngineIndex > UpperCopyEngineIndex) || (LowerCopyEngineIndex < -1) || (UpperCopyEngineIndex < -1)) { - urPrint("UR_L0_LEVEL_ZERO_USE_COPY_ENGINE: invalid value provided, " - "default set.\n"); + logger::error("UR_L0_LEVEL_ZERO_USE_COPY_ENGINE: invalid value provided, " + "default set."); LowerCopyEngineIndex = 0; UpperCopyEngineIndex = INT_MAX; } @@ -981,7 +982,7 @@ ur_result_t ur_device_handle_t_::initialize(int SubSubDeviceOrdinal, if (numQueueGroups == 0) { return UR_RESULT_ERROR_UNKNOWN; } - urPrint("NOTE: Number of queue groups = %d\n", numQueueGroups); + logger::info("Number of queue groups = {}", numQueueGroups); std::vector> QueueGroupProperties(numQueueGroups); ZE2UR_CALL(zeDeviceGetCommandQueueGroupProperties, @@ -1034,14 +1035,14 @@ ur_result_t ur_device_handle_t_::initialize(int SubSubDeviceOrdinal, } } if (QueueGroup[queue_group_info_t::MainCopy].ZeOrdinal < 0) - urPrint("NOTE: main blitter/copy engine is not available\n"); + logger::info("main blitter/copy engine is not available"); else - urPrint("NOTE: main blitter/copy engine is available\n"); + logger::info("main blitter/copy engine is available"); if (QueueGroup[queue_group_info_t::LinkCopy].ZeOrdinal < 0) - urPrint("NOTE: link blitter/copy engines are not available\n"); + logger::info("link blitter/copy engines are not available"); else - urPrint("NOTE: link blitter/copy engines are available\n"); + logger::info("link blitter/copy engines are available"); } } diff --git a/source/adapters/level_zero/event.cpp b/source/adapters/level_zero/event.cpp index b979c8ab15..b64fc9e331 100644 --- a/source/adapters/level_zero/event.cpp +++ b/source/adapters/level_zero/event.cpp @@ -15,18 +15,17 @@ #include "common.hpp" #include "event.hpp" +#include "logger/ur_logger.hpp" #include "ur_level_zero.hpp" void printZeEventList(const _ur_ze_event_list_t &UrZeEventList) { - if (UrL0Debug & UR_L0_DEBUG_BASIC) { - urPrint(" NumEventsInWaitList %d:", UrZeEventList.Length); + std::stringstream ss; + ss << " NumEventsInWaitList" << UrZeEventList.Length << ":"; - for (uint32_t I = 0; I < UrZeEventList.Length; I++) { - urPrint(" %#llx", ur_cast(UrZeEventList.ZeEventList[I])); - } - - urPrint("\n"); + for (uint32_t I = 0; I < UrZeEventList.Length; I++) { + ss << " " << ur_cast(UrZeEventList.ZeEventList[I]); } + logger::debug(ss.str().c_str()); } // This is an experimental option that allows the use of multiple command lists @@ -428,8 +427,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventGetInfo( return ReturnValue(Event->RefCount.load()); } default: - urPrint("Unsupported ParamName in urEventGetInfo: ParamName=%d(%x)\n", - PropName, PropName); + logger::error("Unsupported ParamName in urEventGetInfo: ParamName={}", + PropName); return UR_RESULT_ERROR_INVALID_VALUE; } @@ -498,7 +497,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventGetProfilingInfo( // return ReturnValue(uint64_t{0}); default: - urPrint("urEventGetProfilingInfo: not supported ParamName\n"); + logger::error("urEventGetProfilingInfo: not supported ParamName"); return UR_RESULT_ERROR_INVALID_VALUE; } @@ -594,7 +593,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventWait( die("The host-visible proxy event missing"); ze_event_handle_t ZeEvent = HostVisibleEvent->ZeEvent; - urPrint("ZeEvent = %#llx\n", ur_cast(ZeEvent)); + logger::debug("ZeEvent = {}", ur_cast(ZeEvent)); ZE2UR_CALL(zeHostSynchronize, (ZeEvent)); Event->Completed = true; } @@ -742,7 +741,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventSetCallback( std::ignore = ExecStatus; std::ignore = Notify; std::ignore = UserData; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("[UR][L0] {} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } diff --git a/source/adapters/level_zero/image.cpp b/source/adapters/level_zero/image.cpp index 3e2b78488f..29316108c7 100644 --- a/source/adapters/level_zero/image.cpp +++ b/source/adapters/level_zero/image.cpp @@ -10,6 +10,7 @@ #include "image.hpp" #include "common.hpp" +#include "logger/ur_logger.hpp" UR_APIEXPORT ur_result_t UR_APICALL urUSMPitchedAllocExp( ur_context_handle_t hContext, ur_device_handle_t hDevice, @@ -25,7 +26,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMPitchedAllocExp( std::ignore = elementSizeBytes; std::ignore = ppMem; std::ignore = pResultPitch; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -36,7 +37,7 @@ urBindlessImagesUnsampledImageHandleDestroyExp(ur_context_handle_t hContext, std::ignore = hContext; std::ignore = hDevice; std::ignore = hImage; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -47,7 +48,7 @@ urBindlessImagesSampledImageHandleDestroyExp(ur_context_handle_t hContext, std::ignore = hContext; std::ignore = hDevice; std::ignore = hImage; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -60,7 +61,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( std::ignore = pImageFormat; std::ignore = pImageDesc; std::ignore = phImageMem; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -70,7 +71,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageFreeExp( std::ignore = hContext; std::ignore = hDevice; std::ignore = hImageMem; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -86,7 +87,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp( std::ignore = pImageDesc; std::ignore = phMem; std::ignore = phImage; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -103,7 +104,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp( std::ignore = hSampler; std::ignore = phMem; std::ignore = phImage; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -127,7 +128,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp( std::ignore = numEventsInWaitList; std::ignore = phEventWaitList; std::ignore = phEvent; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -138,7 +139,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp( std::ignore = propName; std::ignore = pPropValue; std::ignore = pPropSizeRet; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -151,7 +152,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp( std::ignore = hImageMem; std::ignore = mipmapLevel; std::ignore = phImageMem; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -161,7 +162,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( std::ignore = hContext; std::ignore = hDevice; std::ignore = hMem; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -174,7 +175,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp( std::ignore = size; std::ignore = pInteropMemDesc; std::ignore = phInteropMem; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -189,7 +190,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp( std::ignore = pImageDesc; std::ignore = hInteropMem; std::ignore = phImageMem; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -199,7 +200,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( std::ignore = hContext; std::ignore = hDevice; std::ignore = hInteropMem; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -212,7 +213,7 @@ urBindlessImagesImportExternalSemaphoreOpaqueFDExp( std::ignore = hDevice; std::ignore = pInteropSemaphoreDesc; std::ignore = phInteropSemaphoreHandle; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -222,7 +223,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( std::ignore = hContext; std::ignore = hDevice; std::ignore = hInteropSemaphore; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -235,7 +236,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesWaitExternalSemaphoreExp( std::ignore = numEventsInWaitList; std::ignore = phEventWaitList; std::ignore = phEvent; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -248,6 +249,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesSignalExternalSemaphoreExp( std::ignore = numEventsInWaitList; std::ignore = phEventWaitList; std::ignore = phEvent; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} 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 dfa8915197..bffd89660e 100644 --- a/source/adapters/level_zero/kernel.cpp +++ b/source/adapters/level_zero/kernel.cpp @@ -9,6 +9,7 @@ //===----------------------------------------------------------------------===// #include "kernel.hpp" +#include "logger/ur_logger.hpp" #include "ur_level_zero.hpp" UR_APIEXPORT ur_result_t UR_APICALL urEnqueueKernelLaunch( @@ -46,7 +47,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueKernelLaunch( Queue->Mutex, Kernel->Mutex, Kernel->Program->Mutex); if (GlobalWorkOffset != NULL) { if (!Queue->Device->Platform->ZeDriverGlobalOffsetExtensionFound) { - urPrint("No global offset extension found on this driver\n"); + logger::error("No global offset extension found on this driver"); return UR_RESULT_ERROR_INVALID_VALUE; } @@ -115,14 +116,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueKernelLaunch( --GroupSize[I]; } if (GlobalWorkSize[I] / GroupSize[I] > UINT32_MAX) { - urPrint("urEnqueueKernelLaunch: can't find a WG size " - "suitable for global work size > UINT32_MAX\n"); + logger::error("urEnqueueKernelLaunch: 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]; } - urPrint("urEnqueueKernelLaunch: using computed WG size = {%d, %d, %d}\n", - WG[0], WG[1], WG[2]); + logger::debug( + "urEnqueueKernelLaunch: using computed WG size = {{{}, {}, {}}}", + WG[0], WG[1], WG[2]); } } @@ -151,27 +153,27 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueKernelLaunch( break; default: - urPrint("urEnqueueKernelLaunch: unsupported work_dim\n"); + logger::error("urEnqueueKernelLaunch: unsupported work_dim"); return UR_RESULT_ERROR_INVALID_VALUE; } // Error handling for non-uniform group size case if (GlobalWorkSize[0] != size_t(ZeThreadGroupDimensions.groupCountX) * WG[0]) { - urPrint("urEnqueueKernelLaunch: invalid work_dim. The range is not a " - "multiple of the group size in the 1st dimension\n"); + logger::error("urEnqueueKernelLaunch: 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 (GlobalWorkSize[1] != size_t(ZeThreadGroupDimensions.groupCountY) * WG[1]) { - urPrint("urEnqueueKernelLaunch: invalid work_dim. The range is not a " - "multiple of the group size in the 2nd dimension\n"); + logger::error("urEnqueueKernelLaunch: 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 (GlobalWorkSize[2] != size_t(ZeThreadGroupDimensions.groupCountZ) * WG[2]) { - urPrint("urEnqueueKernelLaunch: invalid work_dim. The range is not a " - "multiple of the group size in the 3rd dimension\n"); + logger::debug("urEnqueueKernelLaunch: 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; } @@ -241,9 +243,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueKernelLaunch( (*Event)->WaitList.ZeEventList)); } - urPrint("calling zeCommandListAppendLaunchKernel() with" - " ZeEvent %#" PRIxPTR "\n", - ur_cast(ZeEvent)); + logger::debug("calling zeCommandListAppendLaunchKernel() with" + " ZeEvent {}", + ur_cast(ZeEvent)); printZeEventList((*Event)->WaitList); // Execute command list asynchronously, as the event will be used @@ -482,8 +484,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelGetInfo( return UR_RESULT_ERROR_UNKNOWN; } default: - urPrint("Unsupported ParamName in urKernelGetInfo: ParamName=%d(0x%x)\n", - ParamName, ParamName); + logger::error("Unsupported ParamName in urKernelGetInfo: ParamName={}", + ParamName); return UR_RESULT_ERROR_INVALID_VALUE; } @@ -541,8 +543,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelGetGroupInfo( return ReturnValue(uint32_t{Kernel->ZeKernelProperties->privateMemSize}); } default: { - urPrint("Unknown ParamName in urKernelGetGroupInfo: ParamName=%d(0x%x)\n", - ParamName, ParamName); + logger::error("Unknown ParamName in urKernelGetGroupInfo: ParamName=%d", + ParamName); return UR_RESULT_ERROR_INVALID_VALUE; } } @@ -665,7 +667,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelSetExecInfo( return UR_RESULT_ERROR_INVALID_VALUE; ZE2UR_CALL(zeKernelSetCacheConfig, (Kernel->ZeKernel, ZeCacheConfig);); } else { - urPrint("urKernelSetExecInfo: unsupported ParamName\n"); + logger::error("urKernelSetExecInfo: unsupported ParamName"); return UR_RESULT_ERROR_INVALID_VALUE; } @@ -799,6 +801,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelSetSpecializationConstants( std::ignore = Kernel; std::ignore = Count; std::ignore = SpecConstants; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } diff --git a/source/adapters/level_zero/memory.cpp b/source/adapters/level_zero/memory.cpp index aefa661dac..50da18d215 100644 --- a/source/adapters/level_zero/memory.cpp +++ b/source/adapters/level_zero/memory.cpp @@ -14,6 +14,7 @@ #include "context.hpp" #include "event.hpp" +#include "logger/ur_logger.hpp" #include "ur_level_zero.hpp" // Default to using compute engine for fill operation, but allow to @@ -74,9 +75,9 @@ ur_result_t enqueueMemCopyHelper(ur_command_t CommandType, const auto &ZeCommandList = CommandList->first; const auto &WaitList = (*Event)->WaitList; - urPrint("calling zeCommandListAppendMemoryCopy() with\n" - " ZeEvent %#" PRIxPTR "\n", - ur_cast(ZeEvent)); + logger::debug("calling zeCommandListAppendMemoryCopy() with" + " ZeEvent {}", + ur_cast(ZeEvent)); printZeEventList(WaitList); ZE2UR_CALL(zeCommandListAppendMemoryCopy, @@ -125,9 +126,9 @@ ur_result_t enqueueMemCopyRectHelper( const auto &ZeCommandList = CommandList->first; const auto &WaitList = (*Event)->WaitList; - urPrint("calling zeCommandListAppendMemoryCopy() with\n" - " ZeEvent %#" PRIxPTR "\n", - ur_cast(ZeEvent)); + logger::debug("calling zeCommandListAppendMemoryCopy() with" + " ZeEvent {}", + ur_cast(ZeEvent)); printZeEventList(WaitList); uint32_t SrcOriginX = ur_cast(SrcOrigin.x); @@ -166,7 +167,7 @@ ur_result_t enqueueMemCopyRectHelper( SrcBuffer, &ZeSrcRegion, SrcPitch, SrcSlicePitch, ZeEvent, WaitList.Length, WaitList.ZeEventList)); - urPrint("calling zeCommandListAppendMemoryCopyRegion()\n"); + logger::debug("calling zeCommandListAppendMemoryCopyRegion()"); UR_CALL(Queue->executeCommandList(CommandList, Blocking, OkToBatch)); @@ -239,9 +240,9 @@ static ur_result_t enqueueMemFillHelper(ur_command_t CommandType, (ZeCommandList, Ptr, Pattern, PatternSize, Size, ZeEvent, WaitList.Length, WaitList.ZeEventList)); - urPrint("calling zeCommandListAppendMemoryFill() with\n" - " ZeEvent %#" PRIxPTR "\n", - ur_cast(ZeEvent)); + logger::debug("calling zeCommandListAppendMemoryFill() with" + " ZeEvent {}", + ur_cast(ZeEvent)); printZeEventList(WaitList); // Execute command list asynchronously, as the event will be used @@ -455,7 +456,7 @@ static ur_result_t enqueueMemImageCommandHelper( ur_cast(ZeHandleSrc), &ZeDstRegion, &ZeSrcRegion, ZeEvent, 0, nullptr)); } else { - urPrint("enqueueMemImageUpdate: unsupported image command type\n"); + logger::error("enqueueMemImageUpdate: unsupported image command type"); return UR_RESULT_ERROR_INVALID_OPERATION; } @@ -976,7 +977,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferMap( // False as the second value in pair means that mapping was not inserted // because mapping already exists. if (!Res.second) { - urPrint("urEnqueueMemBufferMap: duplicate mapping detected\n"); + logger::error("urEnqueueMemBufferMap: duplicate mapping detected"); return UR_RESULT_ERROR_INVALID_VALUE; } @@ -1029,7 +1030,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferMap( // False as the second value in pair means that mapping was not inserted // because mapping already exists. if (!Res.second) { - urPrint("urEnqueueMemBufferMap: duplicate mapping detected\n"); + logger::error("urEnqueueMemBufferMap: duplicate mapping detected"); return UR_RESULT_ERROR_INVALID_VALUE; } return UR_RESULT_SUCCESS; @@ -1082,7 +1083,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemUnmap( std::scoped_lock Guard(Buffer->Mutex); auto It = Buffer->Mappings.find(MappedPtr); if (It == Buffer->Mappings.end()) { - urPrint("urEnqueueMemUnmap: unknown memory mapping\n"); + logger::error("urEnqueueMemUnmap: unknown memory mapping"); return UR_RESULT_ERROR_INVALID_VALUE; } MapInfo = It->second; @@ -1179,7 +1180,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMMemset( std::ignore = NumEventsInWaitList; std::ignore = EventWaitList; std::ignore = Event; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -1372,7 +1373,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMFill2D( std::ignore = NumEventsInWaitList; std::ignore = EventWaitList; std::ignore = OutEvent; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -1404,7 +1405,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMMemset2D( std::ignore = NumEventsInWaitList; std::ignore = EventWaitList; std::ignore = OutEvent; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -1520,8 +1521,9 @@ static ur_result_t ur2zeImageDesc(const ur_image_format_t *ImageFormat, break; } default: - urPrint("urMemImageCreate: unsupported image data type: data type = %d\n", - ImageFormat->channelType); + logger::error( + "urMemImageCreate: unsupported image data type: data type = {}", + ImageFormat->channelType); return UR_RESULT_ERROR_INVALID_VALUE; } @@ -1540,13 +1542,13 @@ static ur_result_t ur2zeImageDesc(const ur_image_format_t *ImageFormat, ZeImageFormatLayout = ZE_IMAGE_FORMAT_LAYOUT_32_32_32_32; break; default: - urPrint("urMemImageCreate: unexpected data type Size\n"); + logger::error("urMemImageCreate: unexpected data type Size"); return UR_RESULT_ERROR_INVALID_VALUE; } break; } default: - urPrint("format layout = %d\n", ImageFormat->channelOrder); + logger::error("format layout = {}", ImageFormat->channelOrder); die("urMemImageCreate: unsupported image format layout\n"); break; } @@ -1575,7 +1577,7 @@ static ur_result_t ur2zeImageDesc(const ur_image_format_t *ImageFormat, ZeImageType = ZE_IMAGE_TYPE_2DARRAY; break; default: - urPrint("urMemImageCreate: unsupported image type\n"); + logger::error("urMemImageCreate: unsupported image type"); return UR_RESULT_ERROR_INVALID_VALUE; } @@ -2020,7 +2022,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemImageGetInfo( std::ignore = PropSize; std::ignore = ImgInfo; std::ignore = PropSizeRet; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -2269,8 +2271,8 @@ ur_result_t _ur_buffer::getZeHandle(char *&ZeHandle, access_mode_t AccessMode, } } - urPrint("getZeHandle(pi_device{%p}) = %p\n", (void *)Device, - (void *)Allocation.ZeHandle); + logger::debug("getZeHandle(pi_device{{{}}}) = {}", (void *)Device, + (void *)Allocation.ZeHandle); return UR_RESULT_SUCCESS; } @@ -2441,7 +2443,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueReadHostPipe( std::ignore = numEventsInWaitList; std::ignore = phEventWaitList; std::ignore = phEvent; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -2459,6 +2461,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueWriteHostPipe( std::ignore = numEventsInWaitList; std::ignore = phEventWaitList; std::ignore = phEvent; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } diff --git a/source/adapters/level_zero/platform.cpp b/source/adapters/level_zero/platform.cpp index 308b6909eb..94b8935dba 100644 --- a/source/adapters/level_zero/platform.cpp +++ b/source/adapters/level_zero/platform.cpp @@ -48,7 +48,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urPlatformGet( } if (getenv("SYCL_ENABLE_PCI") != nullptr) { - urPrint("WARNING: SYCL_ENABLE_PCI is deprecated and no longer needed.\n"); + logger::warning("SYCL_ENABLE_PCI is deprecated and no longer needed."); } // TODO: We can still safely recover if something goes wrong during the init. @@ -69,7 +69,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urPlatformGet( } if (ZeResult != ZE_RESULT_SUCCESS) { - urPrint("zeInit: Level Zero initialization failure\n"); + logger::error("zeInit: Level Zero initialization failure"); return ze2urResult(ZeResult); } @@ -174,7 +174,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urPlatformGetInfo( case UR_PLATFORM_INFO_BACKEND: return ReturnValue(UR_PLATFORM_BACKEND_LEVEL_ZERO); default: - urPrint("urPlatformGetInfo: unrecognized ParamName\n"); + logger::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 5bf517d55b..2f275789c6 100644 --- a/source/adapters/level_zero/program.cpp +++ b/source/adapters/level_zero/program.cpp @@ -9,6 +9,7 @@ //===----------------------------------------------------------------------===// #include "program.hpp" +#include "logger/ur_logger.hpp" #include "ur_level_zero.hpp" extern "C" { @@ -329,8 +330,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramLink( ZeModuleDesc.pBuildFlags = ZeExtModuleDesc.pBuildFlags[0]; ZeModuleDesc.pConstants = ZeExtModuleDesc.pConstants[0]; } else { - urPrint("urProgramLink: level_zero driver does not have static linking " - "support."); + logger::error( + "urProgramLink: level_zero driver does not have static linking " + "support."); return UR_RESULT_ERROR_INVALID_VALUE; } } @@ -674,7 +676,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramGetBuildInfo( // program. return ReturnValue(""); } else { - urPrint("urProgramGetBuildInfo: unsupported ParamName\n"); + logger::error("urProgramGetBuildInfo: unsupported ParamName"); return UR_RESULT_ERROR_INVALID_VALUE; } return UR_RESULT_SUCCESS; @@ -690,7 +692,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramSetSpecializationConstant( std::ignore = SpecId; std::ignore = SpecSize; std::ignore = SpecValue; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!"); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } diff --git a/source/adapters/level_zero/queue.cpp b/source/adapters/level_zero/queue.cpp index 994f595a5d..cb2ab2211c 100755 --- a/source/adapters/level_zero/queue.cpp +++ b/source/adapters/level_zero/queue.cpp @@ -250,8 +250,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueGetInfo( return ReturnValue(true); } default: - urPrint("Unsupported ParamName in urQueueGetInfo: ParamName=%d(0x%x)\n", - ParamName, ParamName); + logger::error("Unsupported ParamName in urQueueGetInfo: ParamName={}", + ParamName); return UR_RESULT_ERROR_INVALID_VALUE; } @@ -797,9 +797,9 @@ static const zeCommandListBatchConfig ZeCommandListBatchConfig(bool IsCopy) { Val = std::stoi(BatchConfig.substr(Pos)); } catch (...) { if (IsCopy) - urPrint("UR_L0_COPY_BATCH_SIZE: failed to parse value\n"); + logger::error("UR_L0_COPY_BATCH_SIZE: failed to parse value"); else - urPrint("UR_L0_BATCH_SIZE: failed to parse value\n"); + logger::error("UR_L0_BATCH_SIZE: failed to parse value"); break; } switch (Ord) { @@ -822,20 +822,20 @@ static const zeCommandListBatchConfig ZeCommandListBatchConfig(bool IsCopy) { die("Unexpected batch config"); } if (IsCopy) - urPrint("UR_L0_COPY_BATCH_SIZE: dynamic batch param " - "#%d: %d\n", - (int)Ord, (int)Val); + logger::error("UR_L0_COPY_BATCH_SIZE: dynamic batch param " + "#{}: {}", + (int)Ord, (int)Val); else - urPrint("UR_L0_BATCH_SIZE: dynamic batch param #%d: %d\n", (int)Ord, - (int)Val); + logger::error("UR_L0_BATCH_SIZE: dynamic batch param #{}: {}", + (int)Ord, (int)Val); }; } else { // Negative batch sizes are silently ignored. if (IsCopy) - urPrint("UR_L0_COPY_BATCH_SIZE: ignored negative value\n"); + logger::warning("UR_L0_COPY_BATCH_SIZE: ignored negative value"); else - urPrint("UR_L0_BATCH_SIZE: ignored negative value\n"); + logger::warning("UR_L0_BATCH_SIZE: ignored negative value"); } } return Config; @@ -1004,7 +1004,7 @@ void ur_queue_handle_t_::adjustBatchSizeForFullBatch(bool IsCopy) { ZeCommandListBatchConfig.NumTimesClosedFullThreshold) { if (QueueBatchSize < ZeCommandListBatchConfig.DynamicSizeMax) { QueueBatchSize += ZeCommandListBatchConfig.DynamicSizeStep; - urPrint("Raising QueueBatchSize to %d\n", QueueBatchSize); + logger::debug("Raising QueueBatchSize to {}", QueueBatchSize); } CommandBatch.NumTimesClosedEarly = 0; CommandBatch.NumTimesClosedFull = 0; @@ -1031,7 +1031,7 @@ void ur_queue_handle_t_::adjustBatchSizeForPartialBatch(bool IsCopy) { QueueBatchSize = CommandBatch.OpenCommandList->second.size() - 1; if (QueueBatchSize < 1) QueueBatchSize = 1; - urPrint("Lowering QueueBatchSize to %d\n", QueueBatchSize); + logger::debug("Lowering QueueBatchSize to {}", QueueBatchSize); CommandBatch.NumTimesClosedEarly = 0; CommandBatch.NumTimesClosedFull = 0; } @@ -1327,14 +1327,14 @@ ur_result_t urQueueReleaseInternal(ur_queue_handle_t Queue) { } } - urPrint("urQueueRelease(compute) NumTimesClosedFull %d, " - "NumTimesClosedEarly %d\n", - UrQueue->ComputeCommandBatch.NumTimesClosedFull, - UrQueue->ComputeCommandBatch.NumTimesClosedEarly); - urPrint("urQueueRelease(copy) NumTimesClosedFull %d, NumTimesClosedEarly " - "%d\n", - UrQueue->CopyCommandBatch.NumTimesClosedFull, - UrQueue->CopyCommandBatch.NumTimesClosedEarly); + logger::debug("urQueueRelease(compute) NumTimesClosedFull {}, " + "NumTimesClosedEarly {}", + UrQueue->ComputeCommandBatch.NumTimesClosedFull, + UrQueue->ComputeCommandBatch.NumTimesClosedEarly); + logger::debug( + "urQueueRelease(copy) NumTimesClosedFull {}, NumTimesClosedEarly {}", + UrQueue->CopyCommandBatch.NumTimesClosedFull, + UrQueue->CopyCommandBatch.NumTimesClosedEarly); delete UrQueue; @@ -1810,10 +1810,10 @@ ur_queue_handle_t_::ur_queue_group_t::getZeQueue(uint32_t *QueueGroupOrdinal) { ZeCommandQueueDesc.flags = ZE_COMMAND_QUEUE_FLAG_EXPLICIT_ONLY; } - urPrint("[getZeQueue]: create queue ordinal = %d, index = %d " - "(round robin in [%d, %d]) priority = %s\n", - ZeCommandQueueDesc.ordinal, ZeCommandQueueDesc.index, LowerIndex, - UpperIndex, Priority); + logger::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, @@ -2006,10 +2006,10 @@ 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) { - urPrint("[getZeQueue]: create queue ordinal = %d, index = %d " - "(round robin in [%d, %d]) priority = %s\n", - ZeCommandQueueDesc.ordinal, ZeCommandQueueDesc.index, LowerIndex, - UpperIndex, Priority); + logger::debug("[getZeQueue]: create queue ordinal = {}, index = {} " + "(round robin in [{}, {}]) priority = {}", + ZeCommandQueueDesc.ordinal, ZeCommandQueueDesc.index, + LowerIndex, UpperIndex, Priority); 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 f32c59aeeb..13bb525542 100644 --- a/source/adapters/level_zero/sampler.cpp +++ b/source/adapters/level_zero/sampler.cpp @@ -9,6 +9,7 @@ //===----------------------------------------------------------------------===// #include "sampler.hpp" +#include "logger/ur_logger.hpp" #include "ur_level_zero.hpp" UR_APIEXPORT ur_result_t UR_APICALL urSamplerCreate( @@ -75,9 +76,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urSamplerCreate( ZeSamplerDesc.addressMode = ZE_SAMPLER_ADDRESS_MODE_MIRROR; break; default: - urPrint("urSamplerCreate: unsupported " - "UR_SAMPLER_PROPERTIES_ADDRESSING_MODEE " - "value\n"); + logger::error("urSamplerCreate: unsupported " + "UR_SAMPLER_PROPERTIES_ADDRESSING_MODEE " + "value"); return UR_RESULT_ERROR_INVALID_VALUE; } @@ -86,7 +87,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urSamplerCreate( else if (Props->filterMode == UR_SAMPLER_FILTER_MODE_LINEAR) ZeSamplerDesc.filterMode = ZE_SAMPLER_FILTER_MODE_LINEAR; else { - urPrint("urSamplerCreate: unsupported UR_SAMPLER_FILTER_MODE value\n"); + logger::error( + "urSamplerCreate: unsupported UR_SAMPLER_FILTER_MODE value"); return UR_RESULT_ERROR_INVALID_VALUE; } } @@ -144,7 +146,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urSamplerGetInfo( std::ignore = PropValueSize; std::ignore = PropValue; std::ignore = PropSizeRet; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -155,7 +157,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urSamplerGetNativeHandle( ) { std::ignore = Sampler; std::ignore = NativeSampler; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -173,6 +175,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urSamplerCreateWithNativeHandle( std::ignore = Context; std::ignore = Properties; std::ignore = Sampler; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } diff --git a/source/adapters/level_zero/usm.cpp b/source/adapters/level_zero/usm.cpp index daec0408fb..8918d364ad 100644 --- a/source/adapters/level_zero/usm.cpp +++ b/source/adapters/level_zero/usm.cpp @@ -16,6 +16,7 @@ #include "event.hpp" #include "usm.hpp" +#include "logger/ur_logger.hpp" #include "ur_level_zero.hpp" #include @@ -574,7 +575,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMGetMemAllocInfo( MemAllocaType = UR_USM_TYPE_SHARED; break; default: - urPrint("urUSMGetMemAllocInfo: unexpected usm memory type\n"); + logger::error("urUSMGetMemAllocInfo: unexpected usm memory type"); return UR_RESULT_ERROR_INVALID_VALUE; } return ReturnValue(MemAllocaType); @@ -598,7 +599,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMGetMemAllocInfo( return ReturnValue(Size); } default: - urPrint("urUSMGetMemAllocInfo: unsupported ParamName\n"); + logger::error("urUSMGetMemAllocInfo: unsupported ParamName"); return UR_RESULT_ERROR_INVALID_VALUE; } return UR_RESULT_SUCCESS; @@ -764,7 +765,7 @@ ur_usm_pool_handle_t_::ur_usm_pool_handle_t_(ur_context_handle_t Context, break; } default: { - urPrint("urUSMPoolCreate: unexpected chained stype\n"); + logger::error("urUSMPoolCreate: unexpected chained stype"); throw UsmAllocationException(UR_RESULT_ERROR_INVALID_ARGUMENT); } } @@ -864,7 +865,7 @@ ur_result_t urUSMPoolGetInfo( std::ignore = PropSize; std::ignore = PropValue; std::ignore = PropSizeRet; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } diff --git a/source/adapters/level_zero/usm_p2p.cpp b/source/adapters/level_zero/usm_p2p.cpp index dc59bbcc4b..49d6ed2fc2 100644 --- a/source/adapters/level_zero/usm_p2p.cpp +++ b/source/adapters/level_zero/usm_p2p.cpp @@ -8,6 +8,7 @@ // //===----------------------------------------------------------------------===// +#include "logger/ur_logger.hpp" #include "ur_level_zero.hpp" UR_APIEXPORT ur_result_t UR_APICALL urUsmP2PEnablePeerAccessExp( @@ -16,7 +17,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urUsmP2PEnablePeerAccessExp( std::ignore = commandDevice; std::ignore = peerDevice; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -26,7 +27,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urUsmP2PDisablePeerAccessExp( std::ignore = commandDevice; std::ignore = peerDevice; - urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__); + logger::error("{} function not implemented!", __FUNCTION__); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; }