Skip to content

Commit 5e1d659

Browse files
[UR] added filename and line number to logs
Co-authored-by: Łukasz Ślusarczyk <[email protected]> Co-authored-by: Mateusz P. Nowak <[email protected]>
1 parent 5c5954e commit 5e1d659

File tree

85 files changed

+2057
-2022
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+2057
-2022
lines changed

unified-runtime/scripts/templates/valddi.cpp.mako

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ namespace ur_validation_layer
9393
%>
9494
%if tp_input_handle_funcs and not is_related_create_get_retain_release_func:
9595
if (getContext()->enableLifetimeValidation && !getContext()->refCountContext->isReferenceValid(${tp['name']})) {
96-
getContext()->refCountContext->logInvalidReference(${tp['name']});
96+
URLOG_CTX_INVALID_REFERENCES(${tp['name']});
9797
}
9898
%endif
9999
%endfor

unified-runtime/source/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
add_definitions(-DUR_VERSION="${PROJECT_VERSION_MAJOR}")
77
add_definitions(-DUR_VALIDATION_LAYER_SUPPORTED_VERSION="${PROJECT_VERSION_MAJOR}")
88

9+
string(LENGTH "${CMAKE_SOURCE_DIR}/" SRC_PATH_SIZE)
10+
add_definitions("-DSRC_PATH_SIZE=${SRC_PATH_SIZE}") # for nicer log messages
11+
912
add_subdirectory(common)
1013
add_subdirectory(loader)
1114
add_subdirectory(mock)

unified-runtime/source/adapters/cuda/command_buffer.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
#define UR_CALL(Call, Result) \
3030
{ \
3131
if (PrintTrace) \
32-
logger::always("UR ---> {}", #Call); \
32+
URLOG_ALWAYS("UR ---> {}", #Call); \
3333
Result = (Call); \
3434
if (PrintTrace) \
35-
logger::always("UR <--- {}({})", #Call, Result); \
35+
URLOG_ALWAYS("UR <--- {}({})", #Call, Result); \
3636
}
3737

3838
enum class CommandType {

unified-runtime/source/adapters/cuda/common.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void checkErrorUR(CUresult Result, const char *Function, int Line,
5353
<< "\n\tDescription: " << ErrorString
5454
<< "\n\tFunction: " << Function << "\n\tSource Location: " << File
5555
<< ":" << Line << "\n";
56-
logger::error("{}", SS.str());
56+
URLOG(ERR, "{}", SS.str());
5757

5858
if (std::getenv("PI_CUDA_ABORT") != nullptr ||
5959
std::getenv("UR_CUDA_ABORT") != nullptr) {
@@ -73,7 +73,7 @@ void checkErrorUR(ur_result_t Result, const char *Function, int Line,
7373
SS << "\nUR ERROR:"
7474
<< "\n\tValue: " << Result << "\n\tFunction: " << Function
7575
<< "\n\tSource Location: " << File << ":" << Line << "\n";
76-
logger::error("{}", SS.str());
76+
URLOG(ERR, "{}", SS.str());
7777

7878
if (std::getenv("PI_CUDA_ABORT") != nullptr) {
7979
std::abort();
@@ -93,7 +93,7 @@ std::string getCudaVersionString() {
9393
}
9494

9595
void detail::ur::die(const char *Message) {
96-
logger::always("ur_die:{}", Message);
96+
URLOG_ALWAYS("ur_die:{}", Message);
9797
std::terminate();
9898
}
9999

unified-runtime/source/adapters/cuda/device.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
284284
} else if (std::getenv("SYCL_UR_CUDA_ENABLE_IMAGE_SUPPORT") != nullptr) {
285285
Enabled = true;
286286
} else {
287-
logger::always(
287+
URLOG_ALWAYS(
288288
"Images are not fully supported by the CUDA BE, their support is "
289289
"disabled by default. Their partial support can be activated by "
290290
"setting SYCL_UR_CUDA_ENABLE_IMAGE_SUPPORT environment variable at "

unified-runtime/source/adapters/cuda/image.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -806,8 +806,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
806806

807807
// we don't support copying between different image types.
808808
if (pSrcImageDesc->type != pDstImageDesc->type) {
809-
logger::error(
810-
"Unsupported copy operation between different type of images");
809+
URLOG(ERR,
810+
"Unsupported copy operation between different type of images");
811811
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
812812
}
813813

unified-runtime/source/adapters/hip/common.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void checkErrorUR(amd_comgr_status_t Result, const char *Function, int Line,
8686
<< "\n\tDescription: " << ErrorString
8787
<< "\n\tFunction: " << Function << "\n\tSource Location: " << File
8888
<< ":" << Line << "\n";
89-
logger::error("{}", SS.str());
89+
URLOG(ERR, "{}", SS.str());
9090

9191
if (std::getenv("PI_HIP_ABORT") != nullptr ||
9292
std::getenv("UR_HIP_ABORT") != nullptr) {
@@ -113,7 +113,7 @@ void checkErrorUR(hipError_t Result, const char *Function, int Line,
113113
<< "\n\tDescription: " << ErrorString
114114
<< "\n\tFunction: " << Function << "\n\tSource Location: " << File
115115
<< ":" << Line << "\n";
116-
logger::error("{}", SS.str());
116+
URLOG(ERR, "{}", SS.str());
117117

118118
if (std::getenv("PI_HIP_ABORT") != nullptr ||
119119
std::getenv("UR_HIP_ABORT") != nullptr) {
@@ -133,7 +133,7 @@ void checkErrorUR(ur_result_t Result, const char *Function, int Line,
133133
SS << "\nUR HIP ERROR:"
134134
<< "\n\tValue: " << Result << "\n\tFunction: " << Function
135135
<< "\n\tSource Location: " << File << ":" << Line << "\n";
136-
logger::error("{}", SS.str());
136+
URLOG(ERR, "{}", SS.str());
137137

138138
if (std::getenv("PI_HIP_ABORT") != nullptr ||
139139
std::getenv("UR_HIP_ABORT") != nullptr) {
@@ -157,7 +157,7 @@ hipError_t getHipVersionString(std::string &Version) {
157157
}
158158

159159
void detail::ur::die(const char *pMessage) {
160-
logger::always("ur_die: {}", pMessage);
160+
URLOG_ALWAYS("ur_die: {}", pMessage);
161161
std::terminate();
162162
}
163163

unified-runtime/source/adapters/hip/image.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
825825

826826
// we don't support copying between different image types.
827827
if (pSrcImageDesc->type != pDstImageDesc->type) {
828-
logger::error(
829-
"Unsupported copy operation between different type of images");
828+
URLOG(ERR,
829+
"Unsupported copy operation between different type of images");
830830
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
831831
}
832832

unified-runtime/source/adapters/level_zero/adapter.cpp

+21-20
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ ur_result_t initPlatforms(PlatformVec &platforms,
163163
ZE2UR_CALL(zeDriverGet, (&ZeDriverGetCount, ZeDriverGetHandles.data()));
164164
}
165165
if (ZeDriverGetCount == 0 && GlobalAdapter->ZeInitDriversCount == 0) {
166-
logger::error("\nNo Valid L0 Drivers found.\n");
166+
URLOG(ERR, "\nNo Valid L0 Drivers found.\n");
167167
return UR_RESULT_SUCCESS;
168168
}
169169

@@ -188,9 +188,10 @@ ur_result_t initPlatforms(PlatformVec &platforms,
188188
// newer drivers.
189189
if (ZeDriverGetProperties.driverVersion !=
190190
ZeInitDriverProperties.driverVersion) {
191-
logger::debug("\nzeDriverHandle {} added to the zeInitDrivers list "
192-
"of possible handles.\n",
193-
ZeDriverGetHandles[Y]);
191+
URLOG(DEBUG,
192+
"\nzeDriverHandle {} added to the zeInitDrivers list "
193+
"of possible handles.\n",
194+
ZeDriverGetHandles[Y]);
194195
ZeDrivers.push_back(ZeDriverGetHandles[Y]);
195196
}
196197
}
@@ -201,7 +202,7 @@ ur_result_t initPlatforms(PlatformVec &platforms,
201202
ZeDrivers.assign(ZeDriverGetHandles.begin(), ZeDriverGetHandles.end());
202203
}
203204
ZeDriverCount = ZeDrivers.size();
204-
logger::debug("\n{} L0 Drivers found.\n", ZeDriverCount);
205+
URLOG(DEBUG, "\n{} L0 Drivers found.\n", ZeDriverCount);
205206
for (uint32_t I = 0; I < ZeDriverCount; ++I) {
206207
// Keep track of the first platform init for this Driver
207208
bool DriverPlatformInit = false;
@@ -359,8 +360,8 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()
359360
}
360361

361362
if (getenv("SYCL_ENABLE_PCI") != nullptr) {
362-
logger::warning(
363-
"WARNING: SYCL_ENABLE_PCI is deprecated and no longer needed.\n");
363+
URLOG(WARN,
364+
"WARNING: SYCL_ENABLE_PCI is deprecated and no longer needed.\n");
364365
}
365366

366367
// TODO: We can still safely recover if something goes wrong during the
@@ -381,13 +382,13 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()
381382
if (UrL0InitAllDrivers) {
382383
L0InitFlags |= ZE_INIT_FLAG_VPU_ONLY;
383384
}
384-
logger::debug("\nzeInit with flags value of {}\n",
385-
static_cast<int>(L0InitFlags));
385+
URLOG(DEBUG, "\nzeInit with flags value of {}\n",
386+
static_cast<int>(L0InitFlags));
386387
GlobalAdapter->ZeInitResult = ZE_CALL_NOCHECK(zeInit, (L0InitFlags));
387388
if (GlobalAdapter->ZeInitResult != ZE_RESULT_SUCCESS) {
388389
const char *ErrorString = "Unknown";
389390
zeParseError(GlobalAdapter->ZeInitResult, ErrorString);
390-
logger::error("\nzeInit failed with {}\n", ErrorString);
391+
URLOG(ERR, "\nzeInit failed with {}\n", ErrorString);
391392
}
392393

393394
bool useInitDrivers = false;
@@ -403,9 +404,9 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()
403404
if (strncmp(versions[i].component_name, "loader",
404405
strlen("loader")) == 0) {
405406
loader_version = versions[i].component_lib_version;
406-
logger::debug("\nLevel Zero Loader Version: {}.{}.{}\n",
407-
loader_version.major, loader_version.minor,
408-
loader_version.patch);
407+
URLOG(DEBUG, "\nLevel Zero Loader Version: {}.{}.{}\n",
408+
loader_version.major, loader_version.minor,
409+
loader_version.patch);
409410
break;
410411
}
411412
}
@@ -428,8 +429,8 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()
428429
GlobalAdapter->processHandle, "zeInitDrivers");
429430
#endif
430431
if (GlobalAdapter->initDriversFunctionPtr) {
431-
logger::debug("\nzeInitDrivers with flags value of {}\n",
432-
static_cast<int>(GlobalAdapter->InitDriversDesc.flags));
432+
URLOG(DEBUG, "\nzeInitDrivers with flags value of {}\n",
433+
static_cast<int>(GlobalAdapter->InitDriversDesc.flags));
433434
GlobalAdapter->ZeInitDriversResult =
434435
ZE_CALL_NOCHECK(GlobalAdapter->initDriversFunctionPtr,
435436
(&GlobalAdapter->ZeInitDriversCount, nullptr,
@@ -439,7 +440,7 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()
439440
} else {
440441
const char *ErrorString = "Unknown";
441442
zeParseError(GlobalAdapter->ZeInitDriversResult, ErrorString);
442-
logger::error("\nzeInitDrivers failed with {}\n", ErrorString);
443+
URLOG(ERR, "\nzeInitDrivers failed with {}\n", ErrorString);
443444
}
444445
}
445446
}
@@ -457,12 +458,12 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()
457458

458459
// Absorb the ZE_RESULT_ERROR_UNINITIALIZED and just return 0 Platforms.
459460
if (*GlobalAdapter->ZeResult == ZE_RESULT_ERROR_UNINITIALIZED) {
460-
logger::error("Level Zero Uninitialized\n");
461+
URLOG(ERR, "Level Zero Uninitialized\n");
461462
result = std::move(platforms);
462463
return;
463464
}
464465
if (*GlobalAdapter->ZeResult != ZE_RESULT_SUCCESS) {
465-
logger::error("Level Zero initialization failure\n");
466+
URLOG(ERR, "Level Zero initialization failure\n");
466467
result = ze2urResult(*GlobalAdapter->ZeResult);
467468

468469
return;
@@ -509,8 +510,8 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()
509510
GlobalAdapter->getSysManDriversFunctionPtr &&
510511
GlobalAdapter->sysManInitFunctionPtr) {
511512
ze_init_flags_t L0ZesInitFlags = 0;
512-
logger::debug("\nzesInit with flags value of {}\n",
513-
static_cast<int>(L0ZesInitFlags));
513+
URLOG(DEBUG, "\nzesInit with flags value of {}\n",
514+
static_cast<int>(L0ZesInitFlags));
514515
GlobalAdapter->ZesResult = ZE_CALL_NOCHECK(
515516
GlobalAdapter->sysManInitFunctionPtr, (L0ZesInitFlags));
516517
} else {

unified-runtime/source/adapters/level_zero/async_alloc.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static ur_result_t enqueueUSMAllocHelper(
9292
CommandType = UR_COMMAND_ENQUEUE_USM_SHARED_ALLOC_EXP;
9393
break;
9494
default:
95-
logger::error("enqueueUSMAllocHelper: unsupported USM type");
95+
URLOG(ERR, "enqueueUSMAllocHelper: unsupported USM type");
9696
throw UR_RESULT_ERROR_UNKNOWN;
9797
}
9898
UR_CALL(createEventAndAssociateQueue(Queue, Event, CommandType, CommandList,

unified-runtime/source/adapters/level_zero/command_buffer.cpp

+12-11
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020

2121
// Print the name of a variable and its value in the L0 debug log
22-
#define DEBUG_LOG(VAR) logger::debug(#VAR " {}", VAR);
22+
#define DEBUG_LOG(VAR) URLOG(DEBUG, #VAR " {}", VAR);
2323

2424
namespace {
2525

@@ -44,17 +44,18 @@ bool checkImmediateAppendSupport(ur_context_handle_t Context,
4444
const bool EnableAppendPath = std::atoi(UrRet) == 1;
4545

4646
if (EnableAppendPath && !Device->ImmCommandListUsed) {
47-
logger::error("{} is set but immediate command-lists are currently "
48-
"disabled. Immediate command-lists are "
49-
"required to use the immediate append path.",
50-
AppendEnvVarName);
47+
URLOG(ERR,
48+
"{} is set but immediate command-lists are currently "
49+
"disabled. Immediate command-lists are "
50+
"required to use the immediate append path.",
51+
AppendEnvVarName);
5152
std::abort();
5253
}
5354
if (EnableAppendPath && !DriverSupportsImmediateAppend) {
54-
logger::error("{} is set but "
55-
"the current driver does not support the "
56-
"zeCommandListImmediateAppendCommandListsExp entrypoint.",
57-
AppendEnvVarName);
55+
URLOG(ERR,
56+
"{} is set but the current driver does not support the "
57+
"zeCommandListImmediateAppendCommandListsExp entrypoint.",
58+
AppendEnvVarName);
5859
std::abort();
5960
}
6061

@@ -1840,7 +1841,7 @@ ur_result_t validateCommandDesc(
18401841
auto SupportedFeatures =
18411842
CommandBuffer->Device->ZeDeviceMutableCmdListsProperties
18421843
->mutableCommandFlags;
1843-
logger::debug("Mutable features supported by device {}", SupportedFeatures);
1844+
URLOG(DEBUG, "Mutable features supported by device {}", SupportedFeatures);
18441845

18451846
auto Command = static_cast<kernel_command_handle *>(CommandDesc.hCommand);
18461847
UR_ASSERT(CommandBuffer == Command->CommandBuffer,
@@ -1869,7 +1870,7 @@ ur_result_t validateCommandDesc(
18691870
if (NewGlobalWorkOffset) {
18701871
if (!CommandBuffer->Context->getPlatform()
18711872
->ZeDriverGlobalOffsetExtensionFound) {
1872-
logger::error("No global offset extension found on this driver");
1873+
URLOG(ERR, "No global offset extension found on this driver");
18731874
return UR_RESULT_ERROR_INVALID_VALUE;
18741875
}
18751876
}

unified-runtime/source/adapters/level_zero/common.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ bool setEnvVar(const char *name, const char *value) {
7676
int Res = setenv(name, value, 1);
7777
#endif
7878
if (Res != 0) {
79-
logger::debug(
80-
"UR L0 Adapter was unable to set the environment variable: {}", name);
79+
URLOG(DEBUG, "UR L0 Adapter was unable to set the environment variable: {}",
80+
name);
8181
return false;
8282
}
8383
return true;
@@ -138,7 +138,7 @@ void zeParseError(ze_result_t ZeError, const char *&ErrorString) {
138138

139139
ze_result_t ZeCall::doCall(ze_result_t ZeResult, const char *ZeName,
140140
const char *ZeArgs, bool TraceError) {
141-
logger::debug("ZE ---> {}{}", ZeName, ZeArgs);
141+
URLOG(DEBUG, "ZE ---> {}{}", ZeName, ZeArgs);
142142

143143
if (ZeResult == ZE_RESULT_SUCCESS) {
144144
if (UrL0LeaksDebug) {
@@ -150,7 +150,7 @@ ze_result_t ZeCall::doCall(ze_result_t ZeResult, const char *ZeName,
150150
if (TraceError) {
151151
const char *ErrorString = "Unknown";
152152
zeParseError(ZeResult, ErrorString);
153-
logger::error("Error ({}) in {}", ErrorString, ZeName);
153+
URLOG(ERR, "Error ({}) in {}", ErrorString, ZeName);
154154
}
155155
return ZeResult;
156156
}

0 commit comments

Comments
 (0)