@@ -520,6 +520,54 @@ qvi_hwsplit::split_affinity_preserving(void)
520
520
return split_devices_affinity_preserving ();
521
521
}
522
522
523
+ // TODO(skg) Add device splitting.
524
+ int
525
+ qvi_hwsplit::split_packed (void )
526
+ {
527
+ // cpusets used for mapping.
528
+ qvi_hwloc_cpusets_t cpusets;
529
+ // Get the primary cpusets for the mapping.
530
+ int rc = primary_cpusets (cpusets);
531
+ if (rc != QV_SUCCESS) return rc;
532
+ // Maintains the mapping between task (consumer) IDs and resource IDs.
533
+ qvi_map_t map;
534
+ rc = qvi_map_packed (map, m_group_size, cpusets);
535
+ if (rc != QV_SUCCESS) return rc;
536
+ // Make sure that we mapped all the tasks. If not, this is a bug.
537
+ if (qvi_map_nfids_mapped (map) != m_group_size) {
538
+ qvi_abort ();
539
+ }
540
+ qvi_hwloc_t *const hwloc = m_rmi->hwloc ();
541
+ // Update the hardware pools and colors to reflect the new mapping.
542
+ return apply_cpuset_mapping (
543
+ hwloc, map, cpusets, m_hwpools, m_colors
544
+ );
545
+ }
546
+
547
+ // TODO(skg) Add device splitting.
548
+ int
549
+ qvi_hwsplit::split_spread (void )
550
+ {
551
+ // cpusets used for mapping.
552
+ qvi_hwloc_cpusets_t cpusets;
553
+ // Get the primary cpusets for the mapping.
554
+ int rc = primary_cpusets (cpusets);
555
+ if (rc != QV_SUCCESS) return rc;
556
+ // Maintains the mapping between task (consumer) IDs and resource IDs.
557
+ qvi_map_t map;
558
+ rc = qvi_map_spread (map, m_group_size, cpusets);
559
+ if (rc != QV_SUCCESS) return rc;
560
+ // Make sure that we mapped all the tasks. If not, this is a bug.
561
+ if (qvi_map_nfids_mapped (map) != m_group_size) {
562
+ qvi_abort ();
563
+ }
564
+ qvi_hwloc_t *const hwloc = m_rmi->hwloc ();
565
+ // Update the hardware pools and colors to reflect the new mapping.
566
+ return apply_cpuset_mapping (
567
+ hwloc, map, cpusets, m_hwpools, m_colors
568
+ );
569
+ }
570
+
523
571
/* *
524
572
* Takes a vector of colors and clamps their values to [0, ndc)
525
573
* in place, where ndc is the number of distinct numbers found in values.
@@ -590,6 +638,10 @@ qvi_hwsplit::split(void)
590
638
switch (m_colors[0 ]) {
591
639
case QV_SCOPE_SPLIT_AFFINITY_PRESERVING:
592
640
return split_affinity_preserving ();
641
+ case QV_SCOPE_SPLIT_PACKED:
642
+ return split_packed ();
643
+ case QV_SCOPE_SPLIT_SPREAD:
644
+ return split_spread ();
593
645
default :
594
646
rc = QV_ERR_INVLD_ARG;
595
647
break ;
0 commit comments