Skip to content

Commit 42b17c6

Browse files
authored
[SYCL][XPTI] Fix building with XPTI disabled (#7898)
The `XPTIScope` class uses some XPTI types, but the XPTI header is only included if the XPTI tracing is enabled, so when the XPTI tracing is disabled it fails to build. So this patch simply macros out the whole `XPTIScope` class rather than specific member functions. All the uses of `XPTIScope` in the codebase are already guarded by the macro.
1 parent 3ab714b commit 42b17c6

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

sycl/plugins/level_zero/tracing.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "xpti/xpti_data_types.h"
9+
#ifdef XPTI_ENABLE_INSTRUMENTATION
10+
#include <xpti/xpti_data_types.h>
11+
#include <xpti/xpti_trace_framework.h>
12+
#endif
13+
1014
#include <exception>
1115
#include <layers/zel_tracing_api.h>
12-
#include <xpti/xpti_trace_framework.h>
1316
#include <ze_api.h>
1417

1518
#include <sycl/detail/iostream_proxy.hpp>

sycl/source/detail/xpti_registry.hpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class XPTIRegistry {
116116
/// @brief Helper class to enable XPTI implementation
117117
/// @details This class simplifies the instrumentation and encapsulates the
118118
/// verbose call sequences
119+
#if XPTI_ENABLE_INSTRUMENTATION
119120
class XPTIScope {
120121
public:
121122
using TracePoint = xpti::framework::tracepoint_t;
@@ -130,7 +131,6 @@ class XPTIScope {
130131
const char *UserData)
131132
: MUserData(UserData), MStreamID(0), MInstanceID(0), MScopedNotify(false),
132133
MTraceType(0) {
133-
#if XPTI_ENABLE_INSTRUMENTATION
134134
detail::tls_code_loc_t Tls;
135135
auto TData = Tls.query();
136136
// If TLS is not set, we can still genertate universal IDs with user data
@@ -152,7 +152,6 @@ class XPTIScope {
152152
MStreamID = MTP->stream_id();
153153
MInstanceID = MTP->instance_id();
154154
}
155-
#endif
156155
}
157156

158157
xpti::trace_event_data_t *traceEvent() { return MTraceEvent; }
@@ -163,13 +162,11 @@ class XPTIScope {
163162

164163
XPTIScope &
165164
addMetadata(const std::function<void(xpti::trace_event_data_t *)> &Callback) {
166-
#if XPTI_ENABLE_INSTRUMENTATION
167165
if (xptiTraceEnabled() && MTP) {
168166
auto TEvent = const_cast<xpti::trace_event_data_t *>(MTP->trace_event());
169167
Callback(TEvent);
170168
}
171169
return *this;
172-
#endif
173170
}
174171

175172
XPTIScope &notify() {
@@ -180,18 +177,15 @@ class XPTIScope {
180177
/// @brief Method that emits begin/end trace notifications
181178
/// @return Current class
182179
XPTIScope &scopedNotify(uint16_t TraceType) {
183-
#if XPTI_ENABLE_INSTRUMENTATION
184180
if (xptiTraceEnabled() && MTP) {
185181
MTraceType = TraceType & 0xfffe;
186182
MScopedNotify = true;
187183
xptiNotifySubscribers(MStreamID, MTraceType, nullptr, MTraceEvent,
188184
MInstanceID, static_cast<const void *>(MUserData));
189185
}
190186
return *this;
191-
#endif
192187
}
193188
~XPTIScope() {
194-
#if XPTI_ENABLE_INSTRUMENTATION
195189
if (xptiTraceEnabled() && MTP && MScopedNotify) {
196190
if (MTraceType == (uint16_t)xpti::trace_point_type_t::signal ||
197191
MTraceType == (uint16_t)xpti::trace_point_type_t::graph_create ||
@@ -223,7 +217,6 @@ class XPTIScope {
223217
// Delete the tracepoint object which will clear TLS if it is the top of
224218
// the scope
225219
delete MTP;
226-
#endif
227220
}
228221

229222
private:
@@ -243,6 +236,7 @@ class XPTIScope {
243236
// The trace type information for scoped notifications
244237
uint16_t MTraceType;
245238
}; // class XPTIScope
239+
#endif
246240

247241
} // namespace detail
248242
} // __SYCL_INLINE_VER_NAMESPACE(_V1)

0 commit comments

Comments
 (0)