Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions sycl/source/detail/scheduler/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,15 @@ struct DemangleHandle {

~DemangleHandle() { std::free(p); }
};
static std::string demangleKernelName(std::string Name) {
static std::string demangleKernelName(const std::string_view Name) {
int Status = -1; // some arbitrary value to eliminate the compiler warning
DemangleHandle result(abi::__cxa_demangle(Name.c_str(), NULL, NULL, &Status));
return (Status == 0) ? result.p : Name;
DemangleHandle result(abi::__cxa_demangle(Name.data(), NULL, NULL, &Status));
return (Status == 0) ? result.p : std::string(Name);
}
#else
static std::string demangleKernelName(std::string Name) { return Name; }
static std::string demangleKernelName(const std::string_view Name) {
return std::string(Name);
}
#endif

static std::string accessModeToString(access::mode Mode) {
Expand Down Expand Up @@ -1961,7 +1963,7 @@ ExecCGCommand::ExecCGCommand(
#ifdef XPTI_ENABLE_INSTRUMENTATION
std::string instrumentationGetKernelName(
const std::shared_ptr<detail::kernel_impl> &SyclKernel,
const std::string &FunctionName, const std::string &SyclKernelName,
const std::string_view FunctionName, const std::string_view SyclKernelName,
void *&Address, std::optional<bool> &FromSource) {
std::string KernelName;
if (SyclKernel && SyclKernel->isCreatedFromSource()) {
Expand Down Expand Up @@ -2049,17 +2051,17 @@ void instrumentationFillCommonData(const std::string &KernelName,
xpti::payload_t Payload;
if (!FileName.empty()) {
// File name has a valid string
Payload = xpti::payload_t(FuncName.empty() ? KernelName.c_str()
: FuncName.c_str(),
FileName.c_str(), Line, Column, Address);
Payload =
xpti::payload_t(FuncName.empty() ? KernelName.data() : FuncName.data(),
FileName.data(), Line, Column, Address);
HasSourceInfo = true;
} else if (Address) {
// We have a valid function name and an address
Payload = xpti::payload_t(KernelName.c_str(), Address);
Payload = xpti::payload_t(KernelName.data(), Address);
} else {
// In any case, we will have a valid function name and we'll use that to
// create the hash
Payload = xpti::payload_t(KernelName.c_str());
Payload = xpti::payload_t(KernelName.data());
}

uint64_t CGKernelInstanceNo;
Expand Down Expand Up @@ -2096,7 +2098,7 @@ void instrumentationFillCommonData(const std::string &KernelName,
std::pair<xpti_td *, uint64_t> emitKernelInstrumentationData(
int32_t StreamID, const std::shared_ptr<detail::kernel_impl> &SyclKernel,
const detail::code_location &CodeLoc, bool IsTopCodeLoc,
const std::string &SyclKernelName, const QueueImplPtr &Queue,
const std::string_view SyclKernelName, const QueueImplPtr &Queue,
const NDRDescT &NDRDesc,
const std::shared_ptr<detail::kernel_bundle_impl> &KernelBundleImplPtr,
std::vector<ArgDesc> &CGArgs) {
Expand All @@ -2109,8 +2111,7 @@ std::pair<xpti_td *, uint64_t> emitKernelInstrumentationData(
void *Address = nullptr;
std::optional<bool> FromSource;
std::string KernelName = instrumentationGetKernelName(
SyclKernel, std::string(CodeLoc.functionName()), SyclKernelName, Address,
FromSource);
SyclKernel, CodeLoc.functionName(), SyclKernelName, Address, FromSource);

auto &[CmdTraceEvent, InstanceID] = XptiObjects;

Expand All @@ -2135,9 +2136,9 @@ std::pair<xpti_td *, uint64_t> emitKernelInstrumentationData(
if (Queue.get())
xpti::framework::stash_tuple(XPTI_QUEUE_INSTANCE_ID_KEY,
getQueueID(Queue));
instrumentationAddExtraKernelMetadata(CmdTraceEvent, NDRDesc,
KernelBundleImplPtr, SyclKernelName,
SyclKernel, Queue, CGArgs);
instrumentationAddExtraKernelMetadata(
CmdTraceEvent, NDRDesc, KernelBundleImplPtr,
std::string(SyclKernelName), SyclKernel, Queue, CGArgs);

xptiNotifySubscribers(
StreamID, NotificationTraceType, detail::GSYCLGraphEvent, CmdTraceEvent,
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/scheduler/commands.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ class ExecCGCommand : public Command {
std::pair<xpti_td *, uint64_t> emitKernelInstrumentationData(
int32_t StreamID, const std::shared_ptr<detail::kernel_impl> &SyclKernel,
const detail::code_location &CodeLoc, bool IsTopCodeLoc,
const std::string &SyclKernelName, const QueueImplPtr &Queue,
std::string_view SyclKernelName, const QueueImplPtr &Queue,
const NDRDescT &NDRDesc,
const std::shared_ptr<detail::kernel_bundle_impl> &KernelBundleImplPtr,
std::vector<ArgDesc> &CGArgs);
Expand Down