Skip to content

Commit 8a3bd1c

Browse files
[SYCL] Fix dangling pointer in device_event (#5137)
Fixes #4959 This should not break SYCL library ABI but can affect device-code ABI.
1 parent 6f1bd41 commit 8a3bd1c

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

sycl/include/CL/sycl/device_event.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,17 @@ namespace sycl {
2121
/// \ingroup sycl_api
2222
class device_event {
2323
private:
24-
__ocl_event_t *m_Event;
24+
__ocl_event_t m_Event;
2525

2626
public:
2727
device_event(const device_event &rhs) = default;
2828
device_event(device_event &&rhs) = default;
2929
device_event &operator=(const device_event &rhs) = default;
3030
device_event &operator=(device_event &&rhs) = default;
3131

32-
device_event(__ocl_event_t *Event) : m_Event(Event) {}
32+
device_event(__ocl_event_t Event) : m_Event(Event) {}
3333

34-
void wait() {
35-
__spirv_GroupWaitEvents(__spv::Scope::Workgroup, 1, m_Event);
36-
}
34+
void wait() { __spirv_GroupWaitEvents(__spv::Scope::Workgroup, 1, &m_Event); }
3735
};
3836

3937
} // namespace sycl

sycl/include/CL/sycl/group.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ template <int Dimensions = 1> class group {
294294
__ocl_event_t E = __SYCL_OpGroupAsyncCopyGlobalToLocal(
295295
__spv::Scope::Workgroup, DestT(dest.get()), SrcT(src.get()),
296296
numElements, srcStride, 0);
297-
return device_event(&E);
297+
return device_event(E);
298298
}
299299

300300
/// Asynchronously copies a number of elements specified by \p numElements
@@ -312,7 +312,7 @@ template <int Dimensions = 1> class group {
312312
__ocl_event_t E = __SYCL_OpGroupAsyncCopyLocalToGlobal(
313313
__spv::Scope::Workgroup, DestT(dest.get()), SrcT(src.get()),
314314
numElements, destStride, 0);
315-
return device_event(&E);
315+
return device_event(E);
316316
}
317317

318318
/// Specialization for scalar bool type.

0 commit comments

Comments
 (0)