Skip to content

Commit ae89341

Browse files
{SYCL][PI][L0] - Eliminate std::string construction/destruction overhead. (#3931)
This change eliminates std::string construction/destruction overhead for calls to ZeCall::doCall, and similar entry points. The changes have no observable functional effect but reduce the overall size of the built library by 8-9%, and eliminate the memory allocation and std::string construction ond destruction overhead, thus lowering overall execution time on every level zero API call that uses the macros ZE_CALL and ZE_CALL_NOCHECK.
1 parent e8c32cb commit ae89341

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ class ZeCall {
6666
}
6767

6868
// The non-static version just calls static one.
69-
ze_result_t doCall(ze_result_t ZeResult, std::string ZeName,
70-
std::string ZeArgs, bool TraceError = true);
69+
ze_result_t doCall(ze_result_t ZeResult, const char *ZeName,
70+
const char *ZeArgs, bool TraceError = true);
7171
};
7272
std::mutex ZeCall::GlobalLock;
7373

@@ -408,7 +408,7 @@ static pi_result enqueueMemCopyRectHelper(
408408
const pi_event *EventWaitList, pi_event *Event,
409409
bool PreferCopyEngine = false);
410410

411-
inline void zeParseError(ze_result_t ZeError, std::string &ErrorString) {
411+
inline void zeParseError(ze_result_t ZeError, const char *&ErrorString) {
412412
switch (ZeError) {
413413
#define ZE_ERRCASE(ERR) \
414414
case ERR: \
@@ -456,18 +456,18 @@ inline void zeParseError(ze_result_t ZeError, std::string &ErrorString) {
456456
} // switch
457457
}
458458

459-
ze_result_t ZeCall::doCall(ze_result_t ZeResult, std::string ZeName,
460-
std::string ZeArgs, bool TraceError) {
461-
zePrint("ZE ---> %s%s\n", ZeName.c_str(), ZeArgs.c_str());
459+
ze_result_t ZeCall::doCall(ze_result_t ZeResult, const char *ZeName,
460+
const char *ZeArgs, bool TraceError) {
461+
zePrint("ZE ---> %s%s\n", ZeName, ZeArgs);
462462

463463
if (ZeDebug & ZE_DEBUG_CALL_COUNT) {
464464
++(*ZeCallCount)[ZeName];
465465
}
466466

467467
if (ZeResult && TraceError) {
468-
std::string ErrorString;
468+
const char *ErrorString = "Unknown";
469469
zeParseError(ZeResult, ErrorString);
470-
zePrint("Error (%s) in %s\n", ErrorString.c_str(), ZeName.c_str());
470+
zePrint("Error (%s) in %s\n", ErrorString, ZeName);
471471
}
472472
return ZeResult;
473473
}

0 commit comments

Comments
 (0)