Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

[SYCL] Adds regression test for reduction resource leak #624

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
32 changes: 32 additions & 0 deletions SYCL/Regression/reduction_resource_leak_dw.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// REQUIRES: level_zero, level_zero_dev_kit
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %level_zero_options %s -o %t.out
// RUN: env SYCL_DEVICE_FILTER=level_zero ZE_DEBUG=4 %GPU_RUN_PLACEHOLDER %t.out 2>&1 %GPU_CHECK_PLACEHOLDER
//
// CHECK-NOT: LEAK

// Tests that additional resources required by discard_write reductions do not
// leak.

#include <CL/sycl.hpp>

using namespace cl::sycl;

int main() {
queue Q;

nd_range<1> NDRange(range<1>{49 * 5}, range<1>{49});
std::plus<> BOp;

buffer<int, 1> OutBuf(1);
buffer<int, 1> InBuf(49 * 5);
Q.submit([&](handler &CGH) {
auto In = InBuf.get_access<access::mode::read>(CGH);
auto Out = OutBuf.get_access<access::mode::discard_write>(CGH);
auto Redu = ext::oneapi::reduction(Out, 0, BOp);
CGH.parallel_for<class DiscardSum>(
NDRange, Redu, [=](nd_item<1> NDIt, auto &Sum) {
Sum.combine(In[NDIt.get_global_linear_id()]);
});
});
return 0;
}
31 changes: 31 additions & 0 deletions SYCL/Regression/reduction_resource_leak_usm.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// REQUIRES: level_zero, level_zero_dev_kit
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %level_zero_options %s -o %t.out
// RUN: env SYCL_DEVICE_FILTER=level_zero ZE_DEBUG=4 %GPU_RUN_PLACEHOLDER %t.out 2>&1 %GPU_CHECK_PLACEHOLDER
//
// CHECK-NOT: LEAK

// Tests that additional resources required by USM reductions do not leak.

#include <CL/sycl.hpp>

using namespace cl::sycl;

int main() {
queue Q;

nd_range<1> NDRange(range<1>{49 * 5}, range<1>{49});
std::plus<> BOp;

int *Out = malloc_shared<int>(1, Q);
int *In = malloc_shared<int>(49 * 5, Q);
Q.submit([&](handler &CGH) {
auto Redu = ext::oneapi::reduction(Out, 0, BOp);
CGH.parallel_for<class USMSum>(
NDRange, Redu, [=](nd_item<1> NDIt, auto &Sum) {
Sum.combine(In[NDIt.get_global_linear_id()]);
});
}).wait();
sycl::free(In, Q);
sycl::free(Out, Q);
return 0;
}