Skip to content

Commit a063711

Browse files
dm-vodopyanovbb-sycl
authored andcommitted
[SYCL] Add tests for sycl_ext_intel_device_architecture for AOT (intel#1322)
Implementation: intel/llvm#7008
1 parent 3c68604 commit a063711

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// REQUIRES: opencl-aot, cpu
2+
3+
// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64 %s -o %t.out
4+
// RUN: %t.out
5+
6+
#include <sycl/ext/intel/experimental/device_architecture.hpp>
7+
#include <sycl/sycl.hpp>
8+
9+
using namespace sycl;
10+
using namespace sycl::ext::intel::experimental;
11+
12+
int main() {
13+
std::vector<int> vec(2);
14+
{
15+
buffer<int> buf(vec.data(), vec.size());
16+
17+
queue q(cpu_selector_v);
18+
19+
// test if_architecture_is
20+
q.submit([&](handler &cgh) {
21+
auto acc = buf.get_access<access::mode::read_write>(cgh);
22+
cgh.single_task([=]() {
23+
if_architecture_is<architecture::x86_64>([&]() {
24+
acc[0] = 1;
25+
}).otherwise([&]() { acc[0] = 0; });
26+
});
27+
});
28+
29+
// test else_if_architecture_is
30+
q.submit([&](handler &cgh) {
31+
auto acc = buf.get_access<access::mode::read_write>(cgh);
32+
cgh.single_task([=]() {
33+
if_architecture_is<architecture::intel_gpu_dg1>([&]() {
34+
acc[1] = 0;
35+
}).else_if_architecture_is<architecture::x86_64>([&]() {
36+
acc[1] = 2;
37+
}).otherwise([&]() { acc[1] = 0; });
38+
});
39+
});
40+
41+
// test otherwise
42+
q.submit([&](handler &cgh) {
43+
auto acc = buf.get_access<access::mode::read_write>(cgh);
44+
cgh.single_task([=]() {
45+
if_architecture_is<architecture::intel_gpu_dg1>([&]() {
46+
acc[2] = 0;
47+
}).otherwise([&]() { acc[2] = 3; });
48+
});
49+
});
50+
51+
// test more than one architecture template parameter is passed to
52+
// if_architecture_is
53+
q.submit([&](handler &cgh) {
54+
auto acc = buf.get_access<access::mode::read_write>(cgh);
55+
cgh.single_task([=]() {
56+
if_architecture_is<architecture::intel_gpu_dg1, architecture::x86_64>(
57+
[&]() { acc[3] = 4; })
58+
.otherwise([&]() { acc[3] = 0; });
59+
});
60+
});
61+
}
62+
63+
assert(vec[0] == 1);
64+
assert(vec[1] == 2);
65+
assert(vec[2] == 3);
66+
assert(vec[3] == 4);
67+
68+
return 0;
69+
}

0 commit comments

Comments
 (0)