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

Commit af701be

Browse files
authored
[SYCL] Test for get_backend() methods (#162)
Signed-off-by: mdimakov <[email protected]>
1 parent c451dc5 commit af701be

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

SYCL/Basic/get_backend.cpp

+34-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -fsycl %s -o %t.out
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
22
// RUN: %t.out
33
//
44
//==----------------- get_backend.cpp ------------------------==//
@@ -26,12 +26,43 @@ bool check(backend be) {
2626
return false;
2727
}
2828

29+
inline void return_fail() {
30+
std::cout << "Failed" << std::endl;
31+
exit(1);
32+
}
33+
2934
int main() {
3035
for (const auto &plt : platform::get_platforms()) {
3136
if (!plt.is_host()) {
3237
if (check(plt.get_backend()) == false) {
33-
std::cout << "Failed" << std::endl;
34-
return 1;
38+
return_fail();
39+
}
40+
41+
context c(plt);
42+
if (c.get_backend() != plt.get_backend()) {
43+
return_fail();
44+
}
45+
46+
program prog(c);
47+
if (prog.get_backend() != plt.get_backend()) {
48+
return_fail();
49+
}
50+
51+
default_selector sel;
52+
queue q(c, sel);
53+
if (q.get_backend() != plt.get_backend()) {
54+
return_fail();
55+
}
56+
57+
auto device = q.get_device();
58+
if (device.get_backend() != plt.get_backend()) {
59+
return_fail();
60+
}
61+
62+
unsigned char *HostAlloc = (unsigned char *)malloc_host(1, c);
63+
auto e = q.memset(HostAlloc, 42, 1);
64+
if (e.get_backend() != plt.get_backend()) {
65+
return_fail();
3566
}
3667
}
3768
}

0 commit comments

Comments
 (0)