Skip to content

Commit 2382d5b

Browse files
More CFG restructuring for top/sub/subsub device partitioning
1 parent 87f0652 commit 2382d5b

File tree

1 file changed

+51
-47
lines changed

1 file changed

+51
-47
lines changed

sycl/source/detail/platform_impl.cpp

Lines changed: 51 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ static std::vector<device> amendDeviceAndSubDevices(
421421
}
422422
continue;
423423
}
424+
424425
if (!supportsSubPartitioning) {
425426
if (target.DeviceNum ||
426427
(target.DeviceType &&
@@ -431,53 +432,9 @@ static std::vector<device> amendDeviceAndSubDevices(
431432
}
432433
continue;
433434
}
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
446-
<< std::endl;
447-
continue;
448-
}
449-
}
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());
470-
} 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-
}
478-
}
479-
}
480-
} else {
435+
436+
if (!wantSubSubDevice) {
437+
// -- Add sub device.
481438
auto subDevices = dev.create_sub_devices<
482439
info::partition_property::partition_by_affinity_domain>(
483440
affinityDomain);
@@ -492,7 +449,54 @@ static std::vector<device> amendDeviceAndSubDevices(
492449
<< std::endl;
493450
}
494451
}
452+
continue;
453+
}
454+
455+
// -- Add sub sub device.
456+
auto subDevicesToPartition =
457+
dev.create_sub_devices<partitionProperty>(affinityDomain);
458+
if (target.SubDeviceNum) {
459+
if (subDevicesToPartition.size() > target.SubDeviceNum.value()) {
460+
subDevicesToPartition[0] =
461+
subDevicesToPartition[target.SubDeviceNum.value()];
462+
subDevicesToPartition.resize(1);
463+
} else {
464+
std::cout << "subdevice index out of bounds: " << target
465+
<< std::endl;
466+
continue;
467+
}
468+
}
469+
for (device subDev : subDevicesToPartition) {
470+
bool supportsSubSubPartitioning =
471+
(supportsPartitionProperty(subDev, partitionProperty) &&
472+
supportsAffinityDomain(subDev, partitionProperty,
473+
affinityDomain));
474+
if (!supportsSubSubPartitioning) {
475+
if (target.SubDeviceNum) {
476+
// Parent subdevice was specifically requested, yet is not
477+
// partitionable.
478+
std::cout << "sub-device is not partitionable: " << target
479+
<< std::endl;
480+
}
481+
continue;
482+
}
483+
// Allright, lets get them sub-sub-devices.
484+
auto subSubDevices =
485+
subDev.create_sub_devices<partitionProperty>(affinityDomain);
486+
if (target.HasSubSubDeviceWildCard) {
487+
FinalResult.insert(FinalResult.end(), subSubDevices.begin(),
488+
subSubDevices.end());
489+
} else {
490+
if (subSubDevices.size() > target.SubSubDeviceNum.value()) {
491+
FinalResult.push_back(
492+
subSubDevices[target.SubSubDeviceNum.value()]);
493+
} else {
494+
std::cout << "sub-sub-device index out of bounds: " << target
495+
<< std::endl;
496+
}
497+
}
495498
}
499+
continue;
496500
}
497501
} // /for
498502
} // /for

0 commit comments

Comments
 (0)