Skip to content

Commit f9a1377

Browse files
More refactoring in platform_impl::filterDeviceFilter
1 parent d97d989 commit f9a1377

File tree

1 file changed

+16
-42
lines changed

1 file changed

+16
-42
lines changed

sycl/source/detail/platform_impl.cpp

Lines changed: 16 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -266,59 +266,33 @@ std::vector<int> platform_impl::filterDeviceFilter(
266266
MPlugin->call<PiApiKind::piDeviceGetInfo>(
267267
Device, PI_DEVICE_INFO_TYPE, sizeof(sycl::detail::pi::PiDeviceType),
268268
&PiDevType, nullptr);
269-
// Assumption here is that there is 1-to-1 mapping between PiDevType and
270-
// Sycl device type for GPU, CPU, and ACC.
271-
info::device_type DeviceType = pi::cast<info::device_type>(PiDevType);
272269

273270
for (const FilterT &Filter : FilterList->get()) {
274271
backend FilterBackend = Filter.Backend.value_or(backend::all);
275-
// First, match the backend entry
272+
// First, match the backend entry.
276273
if (FilterBackend != Backend && FilterBackend != backend::all)
277274
continue;
278-
info::device_type FilterDevType =
279-
Filter.DeviceType.value_or(info::device_type::all);
280275

281-
// match the device_num entry
276+
// Match the device_num entry.
282277
if (Filter.DeviceNum && DeviceNum != Filter.DeviceNum.value())
283278
continue;
284279

285-
// Next, match the device_type entry
286-
if (FilterDevType == info::device_type::all) {
287-
if constexpr (is_ods_target) { // dealing with ODS filters
288-
if (!Blacklist[DeviceNum]) { // ensure it is not blacklisted
289-
if (!Filter.IsNegativeTarget) { // is filter positive?
290-
PiDevices[InsertIDx++] = Device;
291-
original_indices.push_back(DeviceNum);
292-
} else {
293-
// Filter is negative and the device matches the filter so
294-
// blacklist the device.
295-
Blacklist[DeviceNum] = true;
296-
}
297-
}
298-
} else { // dealing with SYCL_DEVICE_FILTER
299-
PiDevices[InsertIDx++] = Device;
300-
original_indices.push_back(DeviceNum);
301-
}
302-
break;
303-
}
304-
if (FilterDevType == DeviceType) {
305-
if constexpr (is_ods_target) {
306-
if (!Blacklist[DeviceNum]) {
307-
if (!Filter.IsNegativeTarget) {
308-
PiDevices[InsertIDx++] = Device;
309-
original_indices.push_back(DeviceNum);
310-
} else {
311-
// Filter is negative and the device matches the filter so
312-
// blacklist the device.
313-
Blacklist[DeviceNum] = true;
314-
}
315-
}
316-
} else {
317-
PiDevices[InsertIDx++] = Device;
318-
original_indices.push_back(DeviceNum);
280+
if constexpr (is_ods_target) {
281+
// Dealing with ONEAPI_DEVICE_SELECTOR - check for negative filters.
282+
if (Blacklist[DeviceNum]) // already blacklisted.
283+
break;
284+
285+
if (Filter.IsNegativeTarget) {
286+
// Filter is negative and the device matches the filter so
287+
// blacklist the device now.
288+
Blacklist[DeviceNum] = true;
289+
break;
319290
}
320-
break;
321291
}
292+
293+
PiDevices[InsertIDx++] = Device;
294+
original_indices.push_back(DeviceNum);
295+
break;
322296
}
323297
DeviceNum++;
324298
}

0 commit comments

Comments
 (0)