-
Notifications
You must be signed in to change notification settings - Fork 790
[SYCL] Add code location data to XPTI trace in case of exception thrown #8101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bbbe150
1e26df7
f31d458
b755296
a5bbf26
83da734
b6a3338
0e70171
a64195f
2eafcbc
35e9755
0f8ff4d
e9b046a
8cd2264
0b39cc4
e43141c
3a0e455
23d1b5f
7792103
1813df1
89f9eed
043ffdc
b7130e6
2522163
6f65c99
981142e
9894d95
509fe1f
66c98a8
a38601e
3bd6301
7cdaef5
be35232
3c38840
3d2733f
4bfed74
b8ccd32
c2a3cb7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,49 @@ std::atomic_uint ObjectUsageCounter::MCounter{0}; | |
GlobalHandler::GlobalHandler() = default; | ||
GlobalHandler::~GlobalHandler() = default; | ||
|
||
void GlobalHandler::InitXPTI() { | ||
#ifdef XPTI_ENABLE_INSTRUMENTATION | ||
// Let subscribers know a new stream is being initialized | ||
getXPTIRegistry().initializeStream(SYCL_STREAM_NAME, GMajVer, GMinVer, | ||
GVerStr); | ||
xpti::payload_t SYCLPayload("SYCL Runtime Exceptions"); | ||
uint64_t SYCLInstanceNo; | ||
GSYCLCallEvent = xptiMakeEvent("SYCL Try-catch Exceptions", &SYCLPayload, | ||
xpti::trace_algorithm_event, xpti_at::active, | ||
&SYCLInstanceNo); | ||
#endif | ||
} | ||
|
||
void GlobalHandler::TraceEventXPTI(const char *Message) { | ||
#ifdef XPTI_ENABLE_INSTRUMENTATION | ||
if (!Message) | ||
return; | ||
if (xptiTraceEnabled()) { | ||
// We have to handle the cases where: (1) we may have just the code location | ||
// set and not UID and (2) UID set | ||
detail::tls_code_loc_t Tls; | ||
auto CodeLocation = Tls.query(); | ||
|
||
// Creating a tracepoint will convert a CodeLocation to UID, if not set | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If TLS is not set, Tls.query() will return a codelocation object with all data set to null/0. To handle this condition, we may need additional guards. Apologies for missing this in the last review. The below code shows how we can handle this case by creating a unique string based on the message ptr and using that in our trace point. This will create a unique ID that will return a payload with a "Unknown Function" + [Address] for the function name. bool ValidCL = CodeLocation.fileName() && CodeLocation.funtionName(); if (ValidCL) { xpti::framework::tracepoint_t TP(FileName, FuncName,LineNo, ColNo, nullptr); ... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @tovinkere I would suggest to left responsibility how to treat absence of data to subscribers. Adding extra strings to this data brings more contracts between rt and xpti subscribers which I think could lead to confusion and necessity to align them each time we make any change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we are sending in invalid event types on occasion where code location is not available, we should be documenting it or the "sycl" stream as one of the possibilities for the trace type in question so the callback handler can handle it. All other trace types that are a part of this stream will be sending in valid events, if I am not mistaken. Either we fix it in code or we add documentation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tovinkere why is it invalid event? If we not specify code location - event should be still valid. We still could trace exception using its message. When subscriber receives event it will check if it has code location since we have flags to check. Now we could not guarantee that any exception sent will contain code location - at least because not all APIs has instrumentation. But it is not the reason to not trace exceptions at all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @KseniyaTikhomirova The section in the documentation for the "sycl" stream should be updated to include expected inputs for xpti::trace_diagnostics. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for pointing me to that, updated be35232 😊 |
||
xpti::framework::tracepoint_t TP( | ||
CodeLocation.fileName(), CodeLocation.functionName(), | ||
CodeLocation.lineNumber(), CodeLocation.columnNumber(), nullptr); | ||
|
||
// The call to notify will have the signature of: | ||
// (1) the stream defined in .stream() | ||
// (2) The trace type equal to what is set by .trace_type() | ||
// (3) Parent event set to NULL | ||
// (4) Current event set to one created from CodeLocation and UID | ||
// (5) An instance ID that records the number of times this code location | ||
// has been seen (6) The message generated by the exception handler | ||
TP.stream(SYCL_STREAM_NAME) | ||
.trace_type(xpti::trace_point_type_t::diagnostics) | ||
.notify(static_cast<const void *>(Message)); | ||
} | ||
|
||
#endif | ||
} | ||
|
||
GlobalHandler *&GlobalHandler::getInstancePtr() { | ||
static GlobalHandler *RTGlobalObjHandler = new GlobalHandler(); | ||
return RTGlobalObjHandler; | ||
|
@@ -79,6 +122,13 @@ GlobalHandler *&GlobalHandler::getInstancePtr() { | |
GlobalHandler &GlobalHandler::instance() { | ||
GlobalHandler *RTGlobalObjHandler = GlobalHandler::getInstancePtr(); | ||
assert(RTGlobalObjHandler && "Handler must not be deallocated earlier"); | ||
|
||
KseniyaTikhomirova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#ifdef XPTI_ENABLE_INSTRUMENTATION | ||
static std::once_flag InitXPTIFlag; | ||
if (xptiTraceEnabled()) { | ||
std::call_once(InitXPTIFlag, [&]() { RTGlobalObjHandler->InitXPTI(); }); | ||
} | ||
#endif | ||
return *RTGlobalObjHandler; | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.