@@ -76,8 +76,8 @@ void emitMemAllocEndTrace(uintptr_t ObjHandle, uintptr_t AllocPtr,
76
76
uint64_t emitMemReleaseBeginTrace (uintptr_t ObjHandle, uintptr_t AllocPtr) {
77
77
(void )ObjHandle;
78
78
(void )AllocPtr;
79
- #ifdef XPTI_ENABLE_INSTRUMENTATION
80
79
uint64_t CorrelationID = 0 ;
80
+ #ifdef XPTI_ENABLE_INSTRUMENTATION
81
81
if (xptiTraceEnabled ()) {
82
82
xpti::mem_alloc_data_t MemAlloc{ObjHandle, AllocPtr, 0 /* alloc size */ ,
83
83
0 /* guard zone */ };
@@ -127,9 +127,12 @@ static void waitForEvents(const std::vector<EventImplPtr> &Events) {
127
127
void memBufferCreateHelper (const plugin &Plugin, pi_context Ctx,
128
128
pi_mem_flags Flags, size_t Size, void *HostPtr,
129
129
pi_mem *RetMem, const pi_mem_properties *Props) {
130
+ #ifdef XPTI_ENABLE_INSTRUMENTATION
130
131
uint64_t CorrID = 0 ;
132
+ #endif
131
133
// We only want to instrument piMemBufferCreate
132
134
{
135
+ #ifdef XPTI_ENABLE_INSTRUMENTATION
133
136
CorrID =
134
137
emitMemAllocBeginTrace (0 /* mem object */ , Size, 0 /* guard zone */ );
135
138
xpti::utils::finally _{[&] {
@@ -143,6 +146,7 @@ void memBufferCreateHelper(const plugin &Plugin, pi_context Ctx,
143
146
emitMemAllocEndTrace (MemObjID, (uintptr_t )(Ptr), Size, 0 /* guard zone */ ,
144
147
CorrID);
145
148
}};
149
+ #endif
146
150
Plugin.call <PiApiKind::piMemBufferCreate>(Ctx, Flags, Size, HostPtr, RetMem,
147
151
Props);
148
152
}
@@ -152,6 +156,7 @@ void memReleaseHelper(const plugin &Plugin, pi_mem Mem) {
152
156
// FIXME piMemRelease does not guarante memory release. It is only true if
153
157
// reference counter is 1. However, SYCL runtime currently only calls
154
158
// piMemRetain only for OpenCL interop
159
+ #ifdef XPTI_ENABLE_INSTRUMENTATION
155
160
uint64_t CorrID = 0 ;
156
161
// C-style cast is required for MSVC
157
162
uintptr_t MemObjID = (uintptr_t )(Mem);
@@ -162,11 +167,14 @@ void memReleaseHelper(const plugin &Plugin, pi_mem Mem) {
162
167
Plugin.call <PiApiKind::piextMemGetNativeHandle>(Mem, &PtrHandle);
163
168
Ptr = (uintptr_t )(PtrHandle);
164
169
}
170
+ #endif
165
171
// We only want to instrument piMemRelease
166
172
{
173
+ #ifdef XPTI_ENABLE_INSTRUMENTATION
167
174
CorrID = emitMemReleaseBeginTrace (MemObjID, Ptr);
168
175
xpti::utils::finally _{
169
176
[&] { emitMemReleaseEndTrace (MemObjID, Ptr, CorrID); }};
177
+ #endif
170
178
Plugin.call <PiApiKind::piMemRelease>(Mem);
171
179
}
172
180
}
@@ -176,15 +184,19 @@ void memBufferMapHelper(const plugin &Plugin, pi_queue Queue, pi_mem Buffer,
176
184
size_t Size, pi_uint32 NumEvents,
177
185
const pi_event *WaitList, pi_event *Event,
178
186
void **RetMap) {
187
+ #ifdef XPTI_ENABLE_INSTRUMENTATION
179
188
uint64_t CorrID = 0 ;
180
189
uintptr_t MemObjID = (uintptr_t )(Buffer);
190
+ #endif
181
191
// We only want to instrument piEnqueueMemBufferMap
182
192
{
193
+ #ifdef XPTI_ENABLE_INSTRUMENTATION
183
194
CorrID = emitMemAllocBeginTrace (MemObjID, Size, 0 /* guard zone */ );
184
195
xpti::utils::finally _{[&] {
185
196
emitMemAllocEndTrace (MemObjID, (uintptr_t )(*RetMap), Size,
186
197
0 /* guard zone */ , CorrID);
187
198
}};
199
+ #endif
188
200
Plugin.call <PiApiKind::piEnqueueMemBufferMap>(
189
201
Queue, Buffer, Blocking, Flags, Offset, Size, NumEvents, WaitList,
190
202
Event, RetMap);
@@ -194,11 +206,14 @@ void memBufferMapHelper(const plugin &Plugin, pi_queue Queue, pi_mem Buffer,
194
206
void memUnmapHelper (const plugin &Plugin, pi_queue Queue, pi_mem Mem,
195
207
void *MappedPtr, pi_uint32 NumEvents,
196
208
const pi_event *WaitList, pi_event *Event) {
209
+ #ifdef XPTI_ENABLE_INSTRUMENTATION
197
210
uint64_t CorrID = 0 ;
198
211
uintptr_t MemObjID = (uintptr_t )(Mem);
199
212
uintptr_t Ptr = (uintptr_t )(MappedPtr);
213
+ #endif
200
214
// We only want to instrument piEnqueueMemUnmap
201
215
{
216
+ #ifdef XPTI_ENABLE_INSTRUMENTATION
202
217
CorrID = emitMemReleaseBeginTrace (MemObjID, Ptr);
203
218
xpti::utils::finally _{[&] {
204
219
// There's no way for SYCL to know, when the pointer is freed, so we have
@@ -210,6 +225,7 @@ void memUnmapHelper(const plugin &Plugin, pi_queue Queue, pi_mem Mem,
210
225
Plugin.call_nocheck <PiApiKind::piEventsWait>(1 , Event);
211
226
emitMemReleaseEndTrace (MemObjID, Ptr, CorrID);
212
227
}};
228
+ #endif
213
229
Plugin.call <PiApiKind::piEnqueueMemUnmap>(Queue, Mem, MappedPtr, NumEvents,
214
230
WaitList, Event);
215
231
}
0 commit comments