Skip to content

Commit

Permalink
[SYCL][UR][L0] Use std::string instead of const char * in call map (#…
Browse files Browse the repository at this point in the history
…10252)

Signed-off-by: jaime.a.arteaga.molina <jarteaga@scsel-cfl-10.sc.intel.com>
Co-authored-by: jaime.a.arteaga.molina <jarteaga@scsel-cfl-10.sc.intel.com>
  • Loading branch information
2 people authored and omarahmed1111 committed Oct 23, 2023
1 parent a02312b commit e32f6a9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ bool setEnvVar(const char *name, const char *value) {
ZeUSMImportExtension ZeUSMImport;

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

inline void zeParseError(ze_result_t ZeError, const char *&ErrorString) {
switch (ZeError) {
Expand Down
2 changes: 1 addition & 1 deletion common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ class ZeUSMImportExtension {
extern ZeUSMImportExtension ZeUSMImport;

// This will count the calls to Level-Zero
extern std::map<const char *, int> *ZeCallCount;
extern std::map<std::string, int> *ZeCallCount;

// Some opencl extensions we know are supported by all Level Zero devices.
constexpr char ZE_SUPPORTED_EXTENSIONS[] =
Expand Down
7 changes: 4 additions & 3 deletions platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urTearDown(
delete PiPlatformsCacheMutex;

bool LeakFound = false;

// Print the balance of various create/destroy native calls.
// The idea is to verify if the number of create(+) and destroy(-) calls are
// matched.
Expand All @@ -43,7 +44,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urTearDown(
// one are allocating objects of that type, while the last element is known
// to deallocate objects of that type.
//
std::vector<std::vector<const char *>> CreateDestroySet = {
std::vector<std::vector<std::string>> CreateDestroySet = {
{"zeContextCreate", "zeContextDestroy"},
{"zeCommandQueueCreate", "zeCommandQueueDestroy"},
{"zeModuleCreate", "zeModuleDestroy"},
Expand Down Expand Up @@ -83,7 +84,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urTearDown(
for (const auto &Row : CreateDestroySet) {
int diff = 0;
for (auto I = Row.begin(); I != Row.end();) {
const char *ZeName = *I;
const char *ZeName = (*I).c_str();
const auto &ZeCount = (*ZeCallCount)[*I];

bool First = (I == Row.begin());
Expand Down Expand Up @@ -137,7 +138,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urPlatformGet(
try {
std::call_once(ZeCallCountInitialized, []() {
if (UrL0Debug & UR_L0_DEBUG_CALL_COUNT) {
ZeCallCount = new std::map<const char *, int>;
ZeCallCount = new std::map<std::string, int>;
}
});
} catch (const std::bad_alloc &) {
Expand Down

0 comments on commit e32f6a9

Please sign in to comment.