File tree 2 files changed +31
-4
lines changed
2 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -42,16 +42,15 @@ device device_selector::select_device() const {
42
42
string_class DeviceName = dev.get_info <info::device::name>();
43
43
std::cout << " SYCL_PI_TRACE[all]: "
44
44
<< " select_device(): -> score = " << score
45
- << ((score == REJECT_DEVICE_SCORE) ? " (REJECTED)" : " " )
46
- << std::endl
45
+ << ((score < 0 ) ? " (REJECTED)" : " " ) << std::endl
47
46
<< " SYCL_PI_TRACE[all]: "
48
47
<< " platform: " << PlatformVersion << std::endl
49
48
<< " SYCL_PI_TRACE[all]: "
50
49
<< " device: " << DeviceName << std::endl;
51
50
}
52
51
53
- // Device is discarded if is marked with REJECT_DEVICE_SCORE
54
- if (dev_score == REJECT_DEVICE_SCORE )
52
+ // A negative score means that a device must not be selected.
53
+ if (dev_score < 0 )
55
54
continue ;
56
55
57
56
// SYCL spec says: "If more than one device receives the high score then
Original file line number Diff line number Diff line change
1
+ // RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2
+ // RUN: env SYCL_BE=%sycl_be %t.out
3
+ //
4
+ // Checks that no device is selected when no device of desired type is
5
+ // available.
6
+
7
+ #include < CL/sycl.hpp>
8
+
9
+ #include < iostream>
10
+
11
+ class RejectEverything : public sycl ::device_selector {
12
+ public:
13
+ int operator ()(const sycl::device &Device) const final {
14
+ // Negative value means that a device must not be selected
15
+ return -1 ;
16
+ }
17
+ };
18
+
19
+ int main () {
20
+ RejectEverything Selector;
21
+ try {
22
+ sycl::device Device (Selector);
23
+ } catch (sycl::runtime_error &E) {
24
+ return 0 ;
25
+ }
26
+ std::cerr << " Error. A device is found." << std::endl;
27
+ return 1 ;
28
+ }
You can’t perform that action at this time.
0 commit comments