Skip to content

Commit fb97d21

Browse files
[SYCL][PI][L0][NFC] Change std:string to const char * for ZeCallCount (#4018)
This changes to use plain const char * for the ZeCallCount map rather than std:string. This saves std:string construction and destruction overhead when ZE_DEBUG=4 is being used. It also saves about 2% code size for the shared library due to this overhead being removed. This change should not result in any noticeable change in the plug-ins behavior.
1 parent b3ebc62 commit fb97d21

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static pi_result mapError(ze_result_t ZeResult) {
115115
}
116116

117117
// This will count the calls to Level-Zero
118-
static std::map<std::string, int> *ZeCallCount = nullptr;
118+
static std::map<const char *, int> *ZeCallCount = nullptr;
119119

120120
// Trace a call to Level-Zero RT
121121
#define ZE_CALL(ZeName, ZeArgs) \
@@ -1226,7 +1226,7 @@ pi_result piPlatformsGet(pi_uint32 NumEntries, pi_platform *Platforms,
12261226
ZeDebug = DebugModeValue;
12271227

12281228
if (ZeDebug & ZE_DEBUG_CALL_COUNT) {
1229-
ZeCallCount = new std::map<std::string, int>;
1229+
ZeCallCount = new std::map<const char *, int>;
12301230
}
12311231

12321232
if (NumEntries == 0 && Platforms != nullptr) {
@@ -6474,7 +6474,7 @@ pi_result piTearDown(void *PluginParameter) {
64746474
// one are allocating objects of that type, while the last element is known
64756475
// to deallocate objects of that type.
64766476
//
6477-
std::vector<std::vector<std::string>> CreateDestroySet = {
6477+
std::vector<std::vector<const char *>> CreateDestroySet = {
64786478
{"zeContextCreate", "zeContextDestroy"},
64796479
{"zeCommandQueueCreate", "zeCommandQueueDestroy"},
64806480
{"zeModuleCreate", "zeModuleDestroy"},
@@ -6514,7 +6514,7 @@ pi_result piTearDown(void *PluginParameter) {
65146514
for (const auto &Row : CreateDestroySet) {
65156515
int diff = 0;
65166516
for (auto I = Row.begin(); I != Row.end();) {
6517-
const auto &ZeName = I->c_str();
6517+
const char *ZeName = *I;
65186518
const auto &ZeCount = (*ZeCallCount)[*I];
65196519

65206520
bool First = (I == Row.begin());

0 commit comments

Comments
 (0)