@@ -407,6 +407,7 @@ static std::vector<device> amendDeviceAndSubDevices(
407
407
408
408
if (!deviceMatch)
409
409
continue ;
410
+
410
411
// Top level matches. Do we add it, or subdevices, or sub-sub-devices?
411
412
bool wantSubDevice = target.SubDeviceNum || target.HasSubDeviceWildCard ;
412
413
bool supportsSubPartitioning =
@@ -415,8 +416,8 @@ static std::vector<device> amendDeviceAndSubDevices(
415
416
bool wantSubSubDevice =
416
417
target.SubSubDeviceNum || target.HasSubSubDeviceWildCard ;
417
418
418
- // -- Add top level device.
419
419
if (!wantSubDevice) {
420
+ // -- Add top level device only.
420
421
if (!deviceAdded) {
421
422
FinalResult.push_back (dev);
422
423
deviceAdded = true ;
@@ -435,39 +436,27 @@ static std::vector<device> amendDeviceAndSubDevices(
435
436
continue ;
436
437
}
437
438
438
- if (!wantSubSubDevice) {
439
- // -- Add sub device.
440
- auto subDevices = dev.create_sub_devices <
441
- info::partition_property::partition_by_affinity_domain>(
442
- affinityDomain);
443
- if (target.HasSubDeviceWildCard ) {
444
- FinalResult.insert (FinalResult.end (), subDevices.begin (),
445
- subDevices.end ());
446
- } else {
447
- if (subDevices.size () > target.SubDeviceNum .value ()) {
448
- FinalResult.push_back (subDevices[target.SubDeviceNum .value ()]);
449
- } else {
450
- std::cout << " subdevice index out of bounds: " << target
451
- << std::endl;
452
- }
453
- }
454
- continue ;
455
- }
456
-
457
- // -- Add sub sub device.
458
- auto subDevicesToPartition =
459
- dev.create_sub_devices <partitionProperty>(affinityDomain);
439
+ auto subDevices = dev.create_sub_devices <
440
+ info::partition_property::partition_by_affinity_domain>(
441
+ affinityDomain);
460
442
if (target.SubDeviceNum ) {
461
- if (subDevicesToPartition.size () > target.SubDeviceNum .value ()) {
462
- subDevicesToPartition[0 ] =
463
- subDevicesToPartition[target.SubDeviceNum .value ()];
464
- subDevicesToPartition.resize (1 );
465
- } else {
443
+ if (subDevices.size () <= target.SubDeviceNum .value ()) {
466
444
std::cout << " subdevice index out of bounds: " << target << std::endl;
467
445
continue ;
468
446
}
447
+ subDevices[0 ] = subDevices[target.SubDeviceNum .value ()];
448
+ subDevices.resize (1 );
469
449
}
470
- for (device subDev : subDevicesToPartition) {
450
+
451
+ if (!wantSubSubDevice) {
452
+ // -- Add sub device(s) only.
453
+ FinalResult.insert (FinalResult.end (), subDevices.begin (),
454
+ subDevices.end ());
455
+ continue ;
456
+ }
457
+
458
+ // -- Add sub sub device(s).
459
+ for (device subDev : subDevices) {
471
460
bool supportsSubSubPartitioning =
472
461
(supportsPartitionProperty (subDev, partitionProperty) &&
473
462
supportsAffinityDomain (subDev, partitionProperty, affinityDomain));
@@ -480,23 +469,22 @@ static std::vector<device> amendDeviceAndSubDevices(
480
469
}
481
470
continue ;
482
471
}
472
+
483
473
// Allright, lets get them sub-sub-devices.
484
474
auto subSubDevices =
485
475
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 {
476
+ if (target.SubSubDeviceNum ) {
477
+ if (subSubDevices.size () <= target.SubSubDeviceNum .value ()) {
494
478
std::cout << " sub-sub-device index out of bounds: " << target
495
479
<< std::endl;
480
+ continue ;
496
481
}
482
+ subSubDevices[0 ] = subSubDevices[target.SubSubDeviceNum .value ()];
483
+ subSubDevices.resize (1 );
497
484
}
485
+ FinalResult.insert (FinalResult.end (), subSubDevices.begin (),
486
+ subSubDevices.end ());
498
487
}
499
- continue ;
500
488
}
501
489
}
502
490
return FinalResult;
0 commit comments