Skip to content

Commit 255af95

Browse files
committed
[SYCL] Promoted REJECT_DEVICE_SCORE as class member
Signed-off-by: Ruyman Reyes <[email protected]>
1 parent aedaacc commit 255af95

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

sycl/include/CL/sycl/device_selector.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ namespace sycl {
1919
class device;
2020

2121
class __SYCL_EXPORT device_selector {
22+
protected:
23+
static const int REJECT_DEVICE_SCORE = -1;
24+
2225
public:
2326
virtual ~device_selector() = default;
2427

sycl/source/device_selector.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ static bool isDeviceOfPreferredSyclBe(const device &Device) {
3131
device device_selector::select_device() const {
3232
vector_class<device> devices = device::get_devices();
3333
// SYCL specification uses -1 to reject a device from selection
34-
const int REJECT_DEVICE_SCORE = -1;
3534
int score = REJECT_DEVICE_SCORE;
3635
const device *res = nullptr;
3736

@@ -91,7 +90,7 @@ device device_selector::select_device() const {
9190

9291
int default_selector::operator()(const device &dev) const {
9392

94-
int Score = -1;
93+
int Score = REJECT_DEVICE_SCORE;
9594

9695
// Give preference to device of SYCL BE.
9796
if (isDeviceOfPreferredSyclBe(dev))
@@ -114,7 +113,8 @@ int default_selector::operator()(const device &dev) const {
114113
}
115114

116115
int gpu_selector::operator()(const device &dev) const {
117-
int Score = -1;
116+
int Score = REJECT_DEVICE_SCORE;
117+
118118
if (dev.is_gpu()) {
119119
Score = 1000;
120120
// Give preference to device of SYCL BE.
@@ -125,7 +125,7 @@ int gpu_selector::operator()(const device &dev) const {
125125
}
126126

127127
int cpu_selector::operator()(const device &dev) const {
128-
int Score = -1;
128+
int Score = REJECT_DEVICE_SCORE;
129129
if (dev.is_cpu()) {
130130
Score = 1000;
131131
// Give preference to device of SYCL BE.
@@ -136,7 +136,7 @@ int cpu_selector::operator()(const device &dev) const {
136136
}
137137

138138
int accelerator_selector::operator()(const device &dev) const {
139-
int Score = -1;
139+
int Score = REJECT_DEVICE_SCORE;
140140
if (dev.is_accelerator()) {
141141
Score = 1000;
142142
// Give preference to device of SYCL BE.
@@ -147,7 +147,7 @@ int accelerator_selector::operator()(const device &dev) const {
147147
}
148148

149149
int host_selector::operator()(const device &dev) const {
150-
int Score = -1;
150+
int Score = REJECT_DEVICE_SCORE;
151151
if (dev.is_host()) {
152152
Score = 1000;
153153
// Give preference to device of SYCL BE.

0 commit comments

Comments
 (0)