Skip to content

Commit f951846

Browse files
Early continues in place of "!Filter.DeviceNum || DeviceNum ==
Filter.DeviceNum.value()" checks
1 parent 4615fde commit f951846

File tree

1 file changed

+33
-31
lines changed

1 file changed

+33
-31
lines changed

sycl/source/detail/platform_impl.cpp

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -280,44 +280,46 @@ std::vector<int> platform_impl::filterDeviceFilter(
280280
// Next, match the device_type entry
281281
if (FilterDevType == info::device_type::all) {
282282
// Last, match the device_num entry
283-
if (!Filter.DeviceNum || DeviceNum == Filter.DeviceNum.value()) {
284-
if constexpr (is_ods_target) { // dealing with ODS filters
285-
if (!Blacklist[DeviceNum]) { // ensure it is not blacklisted
286-
if (!Filter.IsNegativeTarget) { // is filter positive?
287-
PiDevices[InsertIDx++] = Device;
288-
original_indices.push_back(DeviceNum);
289-
} else {
290-
// Filter is negative and the device matches the filter so
291-
// blacklist the device.
292-
Blacklist[DeviceNum] = true;
293-
}
283+
if (Filter.DeviceNum && DeviceNum != Filter.DeviceNum.value())
284+
continue;
285+
286+
if constexpr (is_ods_target) { // dealing with ODS filters
287+
if (!Blacklist[DeviceNum]) { // ensure it is not blacklisted
288+
if (!Filter.IsNegativeTarget) { // is filter positive?
289+
PiDevices[InsertIDx++] = Device;
290+
original_indices.push_back(DeviceNum);
291+
} else {
292+
// Filter is negative and the device matches the filter so
293+
// blacklist the device.
294+
Blacklist[DeviceNum] = true;
294295
}
295-
} else { // dealing with SYCL_DEVICE_FILTER
296-
PiDevices[InsertIDx++] = Device;
297-
original_indices.push_back(DeviceNum);
298296
}
299-
break;
297+
} else { // dealing with SYCL_DEVICE_FILTER
298+
PiDevices[InsertIDx++] = Device;
299+
original_indices.push_back(DeviceNum);
300300
}
301+
break;
302+
}
303+
if (FilterDevType == DeviceType) {
304+
if (Filter.DeviceNum && DeviceNum != Filter.DeviceNum.value())
305+
continue;
301306

302-
} else if (FilterDevType == DeviceType) {
303-
if (!Filter.DeviceNum || DeviceNum == Filter.DeviceNum.value()) {
304-
if constexpr (is_ods_target) {
305-
if (!Blacklist[DeviceNum]) {
306-
if (!Filter.IsNegativeTarget) {
307-
PiDevices[InsertIDx++] = Device;
308-
original_indices.push_back(DeviceNum);
309-
} else {
310-
// Filter is negative and the device matches the filter so
311-
// blacklist the device.
312-
Blacklist[DeviceNum] = true;
313-
}
307+
if constexpr (is_ods_target) {
308+
if (!Blacklist[DeviceNum]) {
309+
if (!Filter.IsNegativeTarget) {
310+
PiDevices[InsertIDx++] = Device;
311+
original_indices.push_back(DeviceNum);
312+
} else {
313+
// Filter is negative and the device matches the filter so
314+
// blacklist the device.
315+
Blacklist[DeviceNum] = true;
314316
}
315-
} else {
316-
PiDevices[InsertIDx++] = Device;
317-
original_indices.push_back(DeviceNum);
318317
}
319-
break;
318+
} else {
319+
PiDevices[InsertIDx++] = Device;
320+
original_indices.push_back(DeviceNum);
320321
}
322+
break;
321323
}
322324
}
323325
DeviceNum++;

0 commit comments

Comments
 (0)