Skip to content

Commit ff9412a

Browse files
committed
[SYCL] add test for device selector exception message
1 parent c66a526 commit ff9412a

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2+
// RUN: env SYCL_DEVICE_FILTER="" %t.out
3+
4+
#include <sycl/sycl.hpp>
5+
using namespace sycl;
6+
7+
int refuse_any_device_f(const device &d) { return -1; }
8+
9+
int main() {
10+
11+
// Check exception message for custom device selector
12+
try {
13+
queue custom_queue(refuse_any_device_f);
14+
} catch (exception &E) {
15+
assert(std::string(E.what()).find("info::device_type::") ==
16+
std::string::npos &&
17+
"Incorrect device type in exception message for custom selector.");
18+
}
19+
20+
// Check exception message for pre-defined devices
21+
try {
22+
queue gpu_queue(gpu_selector_v);
23+
} catch (exception &E) {
24+
assert(std::string(E.what()).find("info::device_type::gpu") !=
25+
std::string::npos &&
26+
"Incorrect device type in exception message for GPU device.");
27+
}
28+
try {
29+
queue cpu_queue(cpu_selector_v);
30+
} catch (exception &E) {
31+
assert(std::string(E.what()).find("info::device_type::cpu") !=
32+
std::string::npos &&
33+
"Incorrect device type in exception message for CPU device.");
34+
}
35+
try {
36+
queue acc_queue(accelerator_selector_v);
37+
} catch (exception &E) {
38+
assert(
39+
std::string(E.what()).find("info::device_type::accelerator") !=
40+
std::string::npos &&
41+
"Incorrect device type in exception message for Accelerator device.");
42+
}
43+
44+
return 0;
45+
}

0 commit comments

Comments
 (0)