Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
6 changes: 3 additions & 3 deletions sycl/include/sycl/queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2963,7 +2963,9 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
Rest...);
}

#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
buffer<detail::AssertHappened, 1> &getAssertHappenedBuffer();
#endif

event memcpyToDeviceGlobal(void *DeviceGlobalPtr, const void *Src,
bool IsDeviceImageScope, size_t NumBytes,
Expand Down Expand Up @@ -3017,9 +3019,7 @@ class AssertInfoCopier;
*/
event submitAssertCapture(queue &Self, event &Event, queue *SecondaryQueue,
const detail::code_location &CodeLoc) {
using AHBufT = buffer<detail::AssertHappened, 1>;

AHBufT &Buffer = Self.getAssertHappenedBuffer();
Comment thread
maarquitos14 marked this conversation as resolved.
buffer<detail::AssertHappened, 1> Buffer{1};

event CopierEv, CheckerEv, PostCheckerEv;
auto CopierCGF = [&](handler &CGH) {
Expand Down
13 changes: 12 additions & 1 deletion sycl/source/detail/queue_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ class queue_impl {
const async_handler &AsyncHandler, const property_list &PropList)
: MDevice(Device), MContext(Context), MAsyncHandler(AsyncHandler),
MPropList(PropList), MHostQueue(MDevice->is_host()),
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
MAssertHappenedBuffer(range<1>{1}),
#endif
MIsInorder(has_property<property::queue::in_order>()),
MDiscardEvents(
has_property<ext::oneapi::property::queue::discard_events>()),
Expand Down Expand Up @@ -283,7 +285,9 @@ class queue_impl {
queue_impl(sycl::detail::pi::PiQueue PiQueue, const ContextImplPtr &Context,
const async_handler &AsyncHandler)
: MContext(Context), MAsyncHandler(AsyncHandler), MHostQueue(false),
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
MAssertHappenedBuffer(range<1>{1}),
#endif
MIsInorder(has_property<property::queue::in_order>()),
MDiscardEvents(
has_property<ext::oneapi::property::queue::discard_events>()),
Expand All @@ -305,7 +309,10 @@ class queue_impl {
queue_impl(sycl::detail::pi::PiQueue PiQueue, const ContextImplPtr &Context,
const async_handler &AsyncHandler, const property_list &PropList)
: MContext(Context), MAsyncHandler(AsyncHandler), MPropList(PropList),
MHostQueue(false), MAssertHappenedBuffer(range<1>{1}),
MHostQueue(false),
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
MAssertHappenedBuffer(range<1>{1}),
#endif
MIsInorder(has_property<property::queue::in_order>()),
MDiscardEvents(
has_property<ext::oneapi::property::queue::discard_events>()),
Expand Down Expand Up @@ -670,9 +677,11 @@ class queue_impl {
/// \return a native handle.
pi_native_handle getNative(int32_t &NativeHandleDesc) const;

#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
buffer<AssertHappened, 1> &getAssertHappenedBuffer() {
return MAssertHappenedBuffer;
}
#endif

void registerStreamServiceEvent(const EventImplPtr &Event) {
std::lock_guard<std::mutex> Lock(MMutex);
Expand Down Expand Up @@ -888,8 +897,10 @@ class queue_impl {
/// need to emulate it with multiple native in-order queues.
bool MEmulateOOO = false;

#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
// Buffer to store assert failure descriptor
buffer<AssertHappened, 1> MAssertHappenedBuffer;
#endif

// This event is employed for enhanced dependency tracking with in-order queue
// Access to the event should be guarded with MLastEventMtx
Expand Down
2 changes: 2 additions & 0 deletions sycl/source/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,11 @@ pi_native_handle queue::getNative(int32_t &NativeHandleDesc) const {
return impl->getNative(NativeHandleDesc);
}

#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
buffer<detail::AssertHappened, 1> &queue::getAssertHappenedBuffer() {
return impl->getAssertHappenedBuffer();
}
#endif

event queue::memcpyToDeviceGlobal(void *DeviceGlobalPtr, const void *Src,
bool IsDeviceImageScope, size_t NumBytes,
Expand Down
29 changes: 29 additions & 0 deletions sycl/test-e2e/Assert/check_resource_leak.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// RUN: %{build} -o %t.out
// RUN: %if level_zero %{ env UR_L0_LEAKS_DEBUG=1 %} %{run} %t.out

// Device globals aren't supported on opencl:gpu yet.
// UNSUPPORTED: opencl && gpu
#define SYCL_FALLBACK_ASSERT 1

#include <sycl/sycl.hpp>

// DeviceGlobalUSMMem::~DeviceGlobalUSMMem() has asserts to ensure some
// resources have been cleaned up when it's executed. Those asserts used to fail
// when "AssertHappened" buffer used in fallback implementation of the device
// assert was a data member of the queue_impl.
sycl::ext::oneapi::experimental::device_global<int32_t> dg;

int main() {
sycl::queue q;
q.submit([&](sycl::handler &cgh) {
sycl::range<1> R{16};
cgh.parallel_for(sycl::nd_range<1>{R, R}, [=](sycl::nd_item<1> ndi) {
if (ndi.get_global_linear_id() == 0)
dg.get() = 42;
auto sg = sycl::ext::oneapi::experimental::this_sub_group();
auto active = sycl::ext::oneapi::group_ballot(sg, 1);
});
}).wait();

return 0;
}