Skip to content

Commit 3492a78

Browse files
[SYCL][NFC] Lower overhead of making plugin calls (#3982)
This change lowers the overhead of plugin calls by using const char * strings, rather than std::string. This completely eliminates the calls to new and delete to allocate the strings, and also gets rid of the std:string construction/destruction. This also reduces the code size of the library by about 0.5 percent. This change should be NFC in terms of user visible changes to SYCL behavior.
1 parent 43c49ec commit 3492a78

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

sycl/include/CL/sycl/detail/pi.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ template <PiApiKind PiApiOffset> struct PiFuncInfo {};
163163
#define _PI_API(api) \
164164
template <> struct PiFuncInfo<PiApiKind::api> { \
165165
using FuncPtrT = decltype(&::api); \
166-
inline std::string getFuncName() { return #api; } \
166+
inline const char *getFuncName() { return #api; } \
167167
inline FuncPtrT getFuncPtr(PiPlugin MPlugin) { \
168168
return MPlugin.PiFunctionTable.api; \
169169
} \

sycl/source/detail/plugin.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ class plugin {
7373
// Emit a function_begin trace for the PI API before the call is executed.
7474
// If arguments need to be captured, then a data structure can be sent in
7575
// the per_instance_user_data field.
76-
std::string PIFnName = PiCallInfo.getFuncName();
77-
uint64_t CorrelationID = pi::emitFunctionBeginTrace(PIFnName.c_str());
76+
const char *PIFnName = PiCallInfo.getFuncName();
77+
uint64_t CorrelationID = pi::emitFunctionBeginTrace(PIFnName);
7878
#endif
7979
RT::PiResult R;
8080
if (pi::trace(pi::TraceLevel::PI_TRACE_CALLS)) {
8181
std::lock_guard<std::mutex> Guard(*TracingMutex);
82-
std::string FnName = PiCallInfo.getFuncName();
82+
const char *FnName = PiCallInfo.getFuncName();
8383
std::cout << "---> " << FnName << "(" << std::endl;
8484
RT::printArgs(Args...);
8585
R = PiCallInfo.getFuncPtr(MPlugin)(Args...);
@@ -92,7 +92,7 @@ class plugin {
9292
}
9393
#ifdef XPTI_ENABLE_INSTRUMENTATION
9494
// Close the function begin with a call to function end
95-
pi::emitFunctionEndTrace(CorrelationID, PIFnName.c_str());
95+
pi::emitFunctionEndTrace(CorrelationID, PIFnName);
9696
#endif
9797
return R;
9898
}

0 commit comments

Comments
 (0)