Skip to content

Commit 13b86ce

Browse files
[SYCL] E2E for delayed buffer destruction (intel#1460) (intel#1502)
Signed-off-by: Tikhomirova, Kseniya <[email protected]> Co-authored-by: Kseniya Tikhomirova <[email protected]>
1 parent 44e3353 commit 13b86ce

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

SYCL/Basic/buffer/buffer_release.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2+
// RUN: %CPU_RUN_PLACEHOLDER %t.out
3+
4+
#include <sycl/sycl.hpp>
5+
6+
using namespace sycl;
7+
using namespace sycl::access;
8+
9+
static constexpr size_t BUFFER_SIZE = 256;
10+
11+
void test() {
12+
queue Q;
13+
std::unique_ptr<host_accessor<int>> HostAcc;
14+
{
15+
buffer<int, 1> Buffer{BUFFER_SIZE};
16+
HostAcc.reset(new host_accessor(Buffer));
17+
// Host accessor should block kernel execution
18+
Q.submit([&](handler &CGH) {
19+
auto Acc = Buffer.template get_access<mode::write>(CGH);
20+
CGH.parallel_for<class Test>(BUFFER_SIZE,
21+
[=](item<1> Id) { Acc[Id] = 0; });
22+
});
23+
// Buffer destructor should not wait till all operations completion here
24+
}
25+
// Unblock kernel execution
26+
HostAcc.reset(nullptr);
27+
Q.wait();
28+
}
29+
30+
int main() {
31+
test();
32+
return 0;
33+
}

0 commit comments

Comments
 (0)