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

Commit afc48b2

Browse files
[SYCL] Adds regression test for reduction resource leak (#624)
Select variants of reductions currently leak additional resources, such as auxiliary buffers. This commit adds a regression test to ensure this leak does not resurface. Signed-off-by: Steffen Larsen <[email protected]>
1 parent e36c713 commit afc48b2

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// REQUIRES: level_zero, level_zero_dev_kit
2+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %level_zero_options %s -o %t.out
3+
// RUN: env SYCL_DEVICE_FILTER=level_zero ZE_DEBUG=4 %GPU_RUN_PLACEHOLDER %t.out 2>&1 %GPU_CHECK_PLACEHOLDER
4+
//
5+
// CHECK-NOT: LEAK
6+
7+
// Tests that additional resources required by discard_write reductions do not
8+
// leak.
9+
10+
#include <CL/sycl.hpp>
11+
12+
using namespace cl::sycl;
13+
14+
int main() {
15+
queue Q;
16+
17+
nd_range<1> NDRange(range<1>{49 * 5}, range<1>{49});
18+
std::plus<> BOp;
19+
20+
buffer<int, 1> OutBuf(1);
21+
buffer<int, 1> InBuf(49 * 5);
22+
Q.submit([&](handler &CGH) {
23+
auto In = InBuf.get_access<access::mode::read>(CGH);
24+
auto Out = OutBuf.get_access<access::mode::discard_write>(CGH);
25+
auto Redu = ext::oneapi::reduction(Out, 0, BOp);
26+
CGH.parallel_for<class DiscardSum>(
27+
NDRange, Redu, [=](nd_item<1> NDIt, auto &Sum) {
28+
Sum.combine(In[NDIt.get_global_linear_id()]);
29+
});
30+
});
31+
return 0;
32+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// REQUIRES: level_zero, level_zero_dev_kit
2+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %level_zero_options %s -o %t.out
3+
// RUN: env SYCL_DEVICE_FILTER=level_zero ZE_DEBUG=4 %GPU_RUN_PLACEHOLDER %t.out 2>&1 %GPU_CHECK_PLACEHOLDER
4+
//
5+
// CHECK-NOT: LEAK
6+
7+
// Tests that additional resources required by USM reductions do not leak.
8+
9+
#include <CL/sycl.hpp>
10+
11+
using namespace cl::sycl;
12+
13+
int main() {
14+
queue Q;
15+
16+
nd_range<1> NDRange(range<1>{49 * 5}, range<1>{49});
17+
std::plus<> BOp;
18+
19+
int *Out = malloc_shared<int>(1, Q);
20+
int *In = malloc_shared<int>(49 * 5, Q);
21+
Q.submit([&](handler &CGH) {
22+
auto Redu = ext::oneapi::reduction(Out, 0, BOp);
23+
CGH.parallel_for<class USMSum>(
24+
NDRange, Redu, [=](nd_item<1> NDIt, auto &Sum) {
25+
Sum.combine(In[NDIt.get_global_linear_id()]);
26+
});
27+
}).wait();
28+
sycl::free(In, Q);
29+
sycl::free(Out, Q);
30+
return 0;
31+
}

0 commit comments

Comments
 (0)