From 529ec08904fb5f729e5b19dbcfd65cb625a9b478 Mon Sep 17 00:00:00 2001 From: Kevin B Smith Date: Sun, 13 Jun 2021 12:12:01 -0700 Subject: [PATCH] {SYCL][PI][L0] - Eliminate std::string construction/destruction overhead. 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. --- sycl/plugins/level_zero/pi_level_zero.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index d193f1028af03..fb156d60f185d 100644 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -66,8 +66,8 @@ class ZeCall { } // The non-static version just calls static one. - ze_result_t doCall(ze_result_t ZeResult, std::string ZeName, - std::string ZeArgs, bool TraceError = true); + ze_result_t doCall(ze_result_t ZeResult, const char *ZeName, + const char *ZeArgs, bool TraceError = true); }; std::mutex ZeCall::GlobalLock; @@ -408,7 +408,7 @@ static pi_result enqueueMemCopyRectHelper( const pi_event *EventWaitList, pi_event *Event, bool PreferCopyEngine = false); -inline void zeParseError(ze_result_t ZeError, std::string &ErrorString) { +inline void zeParseError(ze_result_t ZeError, const char *&ErrorString) { switch (ZeError) { #define ZE_ERRCASE(ERR) \ case ERR: \ @@ -456,18 +456,18 @@ inline void zeParseError(ze_result_t ZeError, std::string &ErrorString) { } // switch } -ze_result_t ZeCall::doCall(ze_result_t ZeResult, std::string ZeName, - std::string ZeArgs, bool TraceError) { - zePrint("ZE ---> %s%s\n", ZeName.c_str(), ZeArgs.c_str()); +ze_result_t ZeCall::doCall(ze_result_t ZeResult, const char *ZeName, + const char *ZeArgs, bool TraceError) { + zePrint("ZE ---> %s%s\n", ZeName, ZeArgs); if (ZeDebug & ZE_DEBUG_CALL_COUNT) { ++(*ZeCallCount)[ZeName]; } if (ZeResult && TraceError) { - std::string ErrorString; + const char *ErrorString = "Unknown"; zeParseError(ZeResult, ErrorString); - zePrint("Error (%s) in %s\n", ErrorString.c_str(), ZeName.c_str()); + zePrint("Error (%s) in %s\n", ErrorString, ZeName); } return ZeResult; }