Skip to content

Commit 87f0652

Browse files
Early continue instead of "else"
1 parent f7db2b2 commit 87f0652

File tree

1 file changed

+60
-61
lines changed

1 file changed

+60
-61
lines changed

sycl/source/detail/platform_impl.cpp

Lines changed: 60 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -419,78 +419,77 @@ static std::vector<device> amendDeviceAndSubDevices(
419419
FinalResult.push_back(dev);
420420
deviceAdded = true;
421421
}
422-
} else {
423-
if (!supportsSubPartitioning) {
424-
if (target.DeviceNum ||
425-
(target.DeviceType &&
426-
(target.DeviceType.value() != info::device_type::all))) {
427-
// This device was specifically requested and yet is not
428-
// partitionable.
429-
std::cout << "device is not partitionable: " << target
422+
continue;
423+
}
424+
if (!supportsSubPartitioning) {
425+
if (target.DeviceNum ||
426+
(target.DeviceType &&
427+
(target.DeviceType.value() != info::device_type::all))) {
428+
// This device was specifically requested and yet is not
429+
// partitionable.
430+
std::cout << "device is not partitionable: " << target << std::endl;
431+
}
432+
continue;
433+
}
434+
// -- Add sub sub device.
435+
if (wantSubSubDevice) {
436+
437+
auto subDevicesToPartition =
438+
dev.create_sub_devices<partitionProperty>(affinityDomain);
439+
if (target.SubDeviceNum) {
440+
if (subDevicesToPartition.size() > target.SubDeviceNum.value()) {
441+
subDevicesToPartition[0] =
442+
subDevicesToPartition[target.SubDeviceNum.value()];
443+
subDevicesToPartition.resize(1);
444+
} else {
445+
std::cout << "subdevice index out of bounds: " << target
430446
<< std::endl;
447+
continue;
431448
}
432-
continue;
433449
}
434-
// -- Add sub sub device.
435-
if (wantSubSubDevice) {
436-
437-
auto subDevicesToPartition =
438-
dev.create_sub_devices<partitionProperty>(affinityDomain);
439-
if (target.SubDeviceNum) {
440-
if (subDevicesToPartition.size() > target.SubDeviceNum.value()) {
441-
subDevicesToPartition[0] =
442-
subDevicesToPartition[target.SubDeviceNum.value()];
443-
subDevicesToPartition.resize(1);
444-
} else {
445-
std::cout << "subdevice index out of bounds: " << target
450+
for (device subDev : subDevicesToPartition) {
451+
bool supportsSubSubPartitioning =
452+
(supportsPartitionProperty(subDev, partitionProperty) &&
453+
supportsAffinityDomain(subDev, partitionProperty,
454+
affinityDomain));
455+
if (!supportsSubSubPartitioning) {
456+
if (target.SubDeviceNum) {
457+
// Parent subdevice was specifically requested, yet is not
458+
// partitionable.
459+
std::cout << "sub-device is not partitionable: " << target
446460
<< std::endl;
447-
continue;
448461
}
462+
continue;
449463
}
450-
for (device subDev : subDevicesToPartition) {
451-
bool supportsSubSubPartitioning =
452-
(supportsPartitionProperty(subDev, partitionProperty) &&
453-
supportsAffinityDomain(subDev, partitionProperty,
454-
affinityDomain));
455-
if (!supportsSubSubPartitioning) {
456-
if (target.SubDeviceNum) {
457-
// Parent subdevice was specifically requested, yet is not
458-
// partitionable.
459-
std::cout << "sub-device is not partitionable: " << target
460-
<< std::endl;
461-
}
462-
continue;
463-
}
464-
// Allright, lets get them sub-sub-devices.
465-
auto subSubDevices =
466-
subDev.create_sub_devices<partitionProperty>(affinityDomain);
467-
if (target.HasSubSubDeviceWildCard) {
468-
FinalResult.insert(FinalResult.end(), subSubDevices.begin(),
469-
subSubDevices.end());
464+
// Allright, lets get them sub-sub-devices.
465+
auto subSubDevices =
466+
subDev.create_sub_devices<partitionProperty>(affinityDomain);
467+
if (target.HasSubSubDeviceWildCard) {
468+
FinalResult.insert(FinalResult.end(), subSubDevices.begin(),
469+
subSubDevices.end());
470+
} else {
471+
if (subSubDevices.size() > target.SubSubDeviceNum.value()) {
472+
FinalResult.push_back(
473+
subSubDevices[target.SubSubDeviceNum.value()]);
470474
} else {
471-
if (subSubDevices.size() > target.SubSubDeviceNum.value()) {
472-
FinalResult.push_back(
473-
subSubDevices[target.SubSubDeviceNum.value()]);
474-
} else {
475-
std::cout << "sub-sub-device index out of bounds: " << target
476-
<< std::endl;
477-
}
475+
std::cout << "sub-sub-device index out of bounds: " << target
476+
<< std::endl;
478477
}
479478
}
479+
}
480+
} else {
481+
auto subDevices = dev.create_sub_devices<
482+
info::partition_property::partition_by_affinity_domain>(
483+
affinityDomain);
484+
if (target.HasSubDeviceWildCard) {
485+
FinalResult.insert(FinalResult.end(), subDevices.begin(),
486+
subDevices.end());
480487
} else {
481-
auto subDevices = dev.create_sub_devices<
482-
info::partition_property::partition_by_affinity_domain>(
483-
affinityDomain);
484-
if (target.HasSubDeviceWildCard) {
485-
FinalResult.insert(FinalResult.end(), subDevices.begin(),
486-
subDevices.end());
488+
if (subDevices.size() > target.SubDeviceNum.value()) {
489+
FinalResult.push_back(subDevices[target.SubDeviceNum.value()]);
487490
} else {
488-
if (subDevices.size() > target.SubDeviceNum.value()) {
489-
FinalResult.push_back(subDevices[target.SubDeviceNum.value()]);
490-
} else {
491-
std::cout << "subdevice index out of bounds: " << target
492-
<< std::endl;
493-
}
491+
std::cout << "subdevice index out of bounds: " << target
492+
<< std::endl;
494493
}
495494
}
496495
}

0 commit comments

Comments
 (0)