Skip to content

Commit 8e033b1

Browse files
authored
[SYCL][NFC] Avoid temporary object creation when do tracing (#20443)
Change tracing functions to avoid temporary `std::string_view` object creation. The issue was that if a string literal is passed as a `Msg` parameter, the temporary `std::string_view` object was created. When the constructor of the `std::string_view` is called, internally it calculates the length of the C-string. This PR avoids that.
1 parent b8a3979 commit 8e033b1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

sycl/source/detail/kernel_program_cache.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,8 @@ class KernelProgramCache {
328328

329329
// Sends message to std:cerr stream when SYCL_CACHE_TRACE environemnt is
330330
// set.
331-
static inline void traceProgram(const std::string &Msg,
331+
template <typename MsgType>
332+
static inline void traceProgram(const MsgType &Msg,
332333
const ProgramCacheKeyT &CacheKey) {
333334
if (!SYCLConfig<SYCL_CACHE_TRACE>::isTraceInMemCache())
334335
return;
@@ -362,8 +363,9 @@ class KernelProgramCache {
362363

363364
// Sends message to std:cerr stream when SYCL_CACHE_TRACE environemnt is
364365
// set.
365-
static inline void traceKernel(std::string_view Msg,
366-
std::string_view KernelName,
366+
template <typename MsgType>
367+
static inline void traceKernel(const MsgType &Msg,
368+
KernelNameStrRefT KernelName,
367369
bool IsFastKernelCache = false) {
368370
if (!SYCLConfig<SYCL_CACHE_TRACE>::isTraceInMemCache())
369371
return;

0 commit comments

Comments
 (0)