@@ -29,40 +29,6 @@ static bool isDeviceOfPreferredSyclBe(const device &Device) {
2929 backend::opencl;
3030}
3131
32- // @return True if the device is invalid for the current backend preferences
33- static bool isDeviceInvalidForBe (const device &Device) {
34-
35- if (Device.is_host ())
36- return false ;
37-
38- // Taking the version information from the platform gives us more useful
39- // information than the driver_version of the device.
40- const platform platform = Device.get_info <info::device::platform>();
41- const std::string platformVersion =
42- platform.get_info <info::platform::version>();
43-
44- backend *BackendPref = detail::SYCLConfig<detail::SYCL_BE>::get ();
45- auto BackendType = detail::getSyclObjImpl (Device)->getPlugin ().getBackend ();
46- static_assert (std::is_same<backend, decltype (BackendType)>(),
47- " Type is not the same" );
48-
49- // If no preference, assume OpenCL and reject CUDA backend
50- if (BackendType == backend::cuda && !BackendPref) {
51- return true ;
52- } else if (!BackendPref)
53- return false ;
54-
55- // If using PI_CUDA, don't accept a non-CUDA device
56- if (BackendType == backend::opencl && *BackendPref == backend::cuda)
57- return true ;
58-
59- // If using PI_OPENCL, don't accept a non-OpenCL device
60- if (BackendType == backend::cuda && *BackendPref == backend::opencl)
61- return true ;
62-
63- return false ;
64- }
65-
6632device device_selector::select_device () const {
6733 vector_class<device> devices = device::get_devices ();
6834 int score = -1 ;
@@ -102,7 +68,8 @@ device device_selector::select_device() const {
10268 // preference to the device of the preferred BE.
10369 //
10470 if (score < dev_score ||
105- (score == dev_score && isDeviceOfPreferredSyclBe (dev))) {
71+ (score == dev_score && isDeviceOfPreferredSyclBe (dev)
72+ && dev_score != -1 )) {
10673 res = &dev;
10774 score = dev_score;
10875 }
@@ -131,9 +98,6 @@ int default_selector::operator()(const device &dev) const {
13198
13299 int Score = -1 ;
133100
134- if (isDeviceInvalidForBe (dev))
135- return -1 ;
136-
137101 // Give preference to device of SYCL BE.
138102 if (isDeviceOfPreferredSyclBe (dev))
139103 Score = 50 ;
@@ -157,9 +121,6 @@ int default_selector::operator()(const device &dev) const {
157121int gpu_selector::operator ()(const device &dev) const {
158122 int Score = -1 ;
159123
160- if (isDeviceInvalidForBe (dev))
161- return -1 ;
162-
163124 if (dev.is_gpu ()) {
164125 Score = 1000 ;
165126 // Give preference to device of SYCL BE.
@@ -172,9 +133,6 @@ int gpu_selector::operator()(const device &dev) const {
172133int cpu_selector::operator ()(const device &dev) const {
173134 int Score = -1 ;
174135
175- if (isDeviceInvalidForBe (dev))
176- return -1 ;
177-
178136 if (dev.is_cpu ()) {
179137 Score = 1000 ;
180138
@@ -188,9 +146,6 @@ int cpu_selector::operator()(const device &dev) const {
188146int accelerator_selector::operator ()(const device &dev) const {
189147 int Score = -1 ;
190148
191- if (isDeviceInvalidForBe (dev))
192- return -1 ;
193-
194149 if (dev.is_accelerator ()) {
195150 Score = 1000 ;
196151 // Give preference to device of SYCL BE.
@@ -205,10 +160,8 @@ int host_selector::operator()(const device &dev) const {
205160 if (dev.is_host ()) {
206161 Score = 1000 ;
207162 // Give preference to device of SYCL BE.
208- if (isDeviceOfPreferredSyclBe (dev)) {
163+ if (isDeviceOfPreferredSyclBe (dev))
209164 Score += 50 ;
210- } else if (isDeviceInvalidForBe (dev))
211- return -1 ;
212165 }
213166 return Score;
214167}
0 commit comments