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

Commit a3a7186

Browse files
authored
[SYCL] Test for in-order queue event release verification. (#216)
Test added Signed-off-by: rbegam <[email protected]>
1 parent cd14e89 commit a3a7186

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// UNSUPPORTED: cuda
2+
// CUDA does not support unnamed lambdas.
3+
//
4+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fsycl-unnamed-lambda %s -o %t.out
5+
// RUN: %HOST_RUN_PLACEHOLDER %t.out
6+
// RUN: %ACC_RUN_PLACEHOLDER %t.out
7+
// RUN: %CPU_RUN_PLACEHOLDER %t.out
8+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
9+
10+
//==------ oq_event_release.cpp - SYCL ordered queue event release shortcut test
11+
//--------==//
12+
//
13+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
14+
// See https://llvm.org/LICENSE.txt for license information.
15+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
16+
//
17+
//===----------------------------------------------------------------------===//
18+
19+
#include <CL/sycl.hpp>
20+
#include <iostream>
21+
using namespace cl::sycl;
22+
23+
int main() {
24+
queue q{property::queue::in_order()};
25+
auto dev = q.get_device();
26+
auto ctx = q.get_context();
27+
const int N = 8;
28+
29+
if (dev.get_info<info::device::usm_shared_allocations>()) {
30+
auto A = (int *)malloc_shared(N * sizeof(int), dev, ctx);
31+
32+
for (int i = 0; i < N; i++) {
33+
A[i] = 1;
34+
}
35+
36+
{
37+
id<1> offset(0);
38+
q.parallel_for<class Baz>(range<1>{N}, offset, [=](id<1> ID) {
39+
auto i = ID[0];
40+
A[i]++;
41+
});
42+
43+
q.wait();
44+
}
45+
46+
{
47+
nd_range<1> NDR(range<1>{N}, range<1>{2});
48+
q.parallel_for<class NDFoo>(NDR, [=](nd_item<1> Item) {
49+
auto i = Item.get_global_id(0);
50+
A[i]++;
51+
});
52+
53+
q.wait();
54+
}
55+
56+
for (int i = 0; i < N; i++) {
57+
if (A[i] != 3)
58+
return 1;
59+
}
60+
}
61+
62+
return 0;
63+
}

0 commit comments

Comments
 (0)