@@ -37,31 +37,6 @@ static bool isDeviceOfPreferredSyclBe(const device &Device) {
37
37
backend::ext_oneapi_level_zero;
38
38
}
39
39
40
- // Return true if the given device 'Dev' matches with any filter
41
- static bool isForcedDevice (const device &Dev, int Index = -1 ) {
42
- detail::device_filter_list *FilterList =
43
- detail::SYCLConfig<detail::SYCL_DEVICE_FILTER>::get ();
44
-
45
- if (!FilterList)
46
- return false ;
47
- info::device_type Type = Dev.get_info <info::device::device_type>();
48
- backend Backend;
49
- if (Type == info::device_type::host)
50
- Backend = backend::host;
51
- else
52
- Backend = detail::getSyclObjImpl (Dev)->getPlugin ().getBackend ();
53
-
54
- for (const detail::device_filter &Filter : FilterList->get ()) {
55
- if ((Filter.Backend == Backend || Filter.Backend == backend::all) &&
56
- (Filter.DeviceType == Type ||
57
- Filter.DeviceType == info::device_type::all)) {
58
- if (Index < 0 || (Filter.HasDeviceNum && Filter.DeviceNum == Index))
59
- return true ;
60
- }
61
- }
62
- return false ;
63
- }
64
-
65
40
device device_selector::select_device () const {
66
41
std::vector<device> devices = device::get_devices ();
67
42
int score = REJECT_DEVICE_SCORE;
@@ -87,13 +62,6 @@ device device_selector::select_device() const {
87
62
if (dev_score < 0 )
88
63
continue ;
89
64
90
- // If SYCL_DEVICE_FILTER is set, give a bonus point for the device
91
- // whose index matches with desired device number.
92
- int index = &dev - &devices[0 ];
93
- if (isForcedDevice (dev, index)) {
94
- dev_score += 1000 ;
95
- }
96
-
97
65
// SYCL spec says: "If more than one device receives the high score then
98
66
// one of those tied devices will be returned, but which of the devices
99
67
// from the tied set is to be returned is not defined". Here we give a
@@ -141,12 +109,10 @@ int default_selector::operator()(const device &dev) const {
141
109
// All unmatched devices should never be selected.
142
110
detail::device_filter_list *FilterList =
143
111
detail::SYCLConfig<detail::SYCL_DEVICE_FILTER>::get ();
144
- if (FilterList) {
145
- if (isForcedDevice (dev))
146
- Score = 1000 ;
147
- else
148
- return REJECT_DEVICE_SCORE;
149
- }
112
+ // device::get_devices returns filtered list of devices.
113
+ // Keep 1000 for default score when filters were applied.
114
+ if (FilterList)
115
+ Score = 1000 ;
150
116
151
117
if (dev.get_info <info::device::device_type>() == detail::get_forced_type ())
152
118
Score += 1000 ;
@@ -173,16 +139,8 @@ int gpu_selector::operator()(const device &dev) const {
173
139
int Score = REJECT_DEVICE_SCORE;
174
140
175
141
if (dev.is_gpu ()) {
176
- detail::device_filter_list *FilterList =
177
- detail::SYCLConfig<detail::SYCL_DEVICE_FILTER>::get ();
178
- if (FilterList) {
179
- if (isForcedDevice (dev))
180
- Score = 1000 ;
181
- else
182
- return Score;
183
- } else {
184
- Score = 1000 ;
185
- }
142
+ // device::get_devices returns filtered list of devices.
143
+ Score = 1000 ;
186
144
// Give preference to device of SYCL BE.
187
145
if (isDeviceOfPreferredSyclBe (dev))
188
146
Score += 50 ;
@@ -194,16 +152,9 @@ int cpu_selector::operator()(const device &dev) const {
194
152
int Score = REJECT_DEVICE_SCORE;
195
153
196
154
if (dev.is_cpu ()) {
197
- detail::device_filter_list *FilterList =
198
- detail::SYCLConfig<detail::SYCL_DEVICE_FILTER>::get ();
199
- if (FilterList) {
200
- if (isForcedDevice (dev))
201
- Score = 1000 ;
202
- else
203
- return Score;
204
- } else {
205
- Score = 1000 ;
206
- }
155
+ // device::get_devices returns filtered list of devices.
156
+ Score = 1000 ;
157
+
207
158
// Give preference to device of SYCL BE.
208
159
if (isDeviceOfPreferredSyclBe (dev))
209
160
Score += 50 ;
@@ -215,16 +166,9 @@ int accelerator_selector::operator()(const device &dev) const {
215
166
int Score = REJECT_DEVICE_SCORE;
216
167
217
168
if (dev.is_accelerator ()) {
218
- detail::device_filter_list *FilterList =
219
- detail::SYCLConfig<detail::SYCL_DEVICE_FILTER>::get ();
220
- if (FilterList) {
221
- if (isForcedDevice (dev))
222
- Score = 1000 ;
223
- else
224
- return Score;
225
- } else {
226
- Score = 1000 ;
227
- }
169
+ // device::get_devices returns filtered list of devices.
170
+ Score = 1000 ;
171
+
228
172
// Give preference to device of SYCL BE.
229
173
if (isDeviceOfPreferredSyclBe (dev))
230
174
Score += 50 ;
0 commit comments