@@ -1130,12 +1130,10 @@ hwloc_type_cmp(hwloc_obj_t obj1, hwloc_obj_t obj2)
1130
1130
/*
1131
1131
* How to compare objects based on cpusets.
1132
1132
*/
1133
-
1134
1133
static int
1135
1134
hwloc_obj_cmp_sets (hwloc_obj_t obj1 , hwloc_obj_t obj2 )
1136
1135
{
1137
1136
hwloc_bitmap_t set1 , set2 ;
1138
- int res = HWLOC_OBJ_DIFFERENT ;
1139
1137
1140
1138
assert (!hwloc__obj_type_is_special (obj1 -> type ));
1141
1139
assert (!hwloc__obj_type_is_special (obj2 -> type ));
@@ -1148,45 +1146,10 @@ hwloc_obj_cmp_sets(hwloc_obj_t obj1, hwloc_obj_t obj2)
1148
1146
set1 = obj1 -> cpuset ;
1149
1147
set2 = obj2 -> cpuset ;
1150
1148
}
1151
- if (set1 && set2 && !hwloc_bitmap_iszero (set1 ) && !hwloc_bitmap_iszero (set2 )) {
1152
- res = hwloc_bitmap_compare_inclusion (set1 , set2 );
1153
- if (res == HWLOC_OBJ_INTERSECTS )
1154
- return HWLOC_OBJ_INTERSECTS ;
1155
- }
1156
-
1157
- /* then compare nodesets, and combine the results */
1158
- if (obj1 -> complete_nodeset && obj2 -> complete_nodeset ) {
1159
- set1 = obj1 -> complete_nodeset ;
1160
- set2 = obj2 -> complete_nodeset ;
1161
- } else {
1162
- set1 = obj1 -> nodeset ;
1163
- set2 = obj2 -> nodeset ;
1164
- }
1165
- if (set1 && set2 && !hwloc_bitmap_iszero (set1 ) && !hwloc_bitmap_iszero (set2 )) {
1166
- int noderes = hwloc_bitmap_compare_inclusion (set1 , set2 );
1167
- /* deal with conflicting cpusets/nodesets inclusions */
1168
- if (noderes == HWLOC_OBJ_INCLUDED ) {
1169
- if (res == HWLOC_OBJ_CONTAINS )
1170
- /* contradicting order for cpusets and nodesets */
1171
- return HWLOC_OBJ_INTERSECTS ;
1172
- res = HWLOC_OBJ_INCLUDED ;
1173
-
1174
- } else if (noderes == HWLOC_OBJ_CONTAINS ) {
1175
- if (res == HWLOC_OBJ_INCLUDED )
1176
- /* contradicting order for cpusets and nodesets */
1177
- return HWLOC_OBJ_INTERSECTS ;
1178
- res = HWLOC_OBJ_CONTAINS ;
1179
-
1180
- } else if (noderes == HWLOC_OBJ_INTERSECTS ) {
1181
- return HWLOC_OBJ_INTERSECTS ;
1182
-
1183
- } else {
1184
- /* nodesets are different, keep the cpuset order */
1185
-
1186
- }
1187
- }
1149
+ if (set1 && set2 && !hwloc_bitmap_iszero (set1 ) && !hwloc_bitmap_iszero (set2 ))
1150
+ return hwloc_bitmap_compare_inclusion (set1 , set2 );
1188
1151
1189
- return res ;
1152
+ return HWLOC_OBJ_DIFFERENT ;
1190
1153
}
1191
1154
1192
1155
/* Compare object cpusets based on complete_cpuset if defined (always correctly ordered),
@@ -1201,10 +1164,6 @@ hwloc__object_cpusets_compare_first(hwloc_obj_t obj1, hwloc_obj_t obj2)
1201
1164
return hwloc_bitmap_compare_first (obj1 -> complete_cpuset , obj2 -> complete_cpuset );
1202
1165
else if (obj1 -> cpuset && obj2 -> cpuset )
1203
1166
return hwloc_bitmap_compare_first (obj1 -> cpuset , obj2 -> cpuset );
1204
- else if (obj1 -> complete_nodeset && obj2 -> complete_nodeset )
1205
- return hwloc_bitmap_compare_first (obj1 -> complete_nodeset , obj2 -> complete_nodeset );
1206
- else if (obj1 -> nodeset && obj2 -> nodeset )
1207
- return hwloc_bitmap_compare_first (obj1 -> nodeset , obj2 -> nodeset );
1208
1167
return 0 ;
1209
1168
}
1210
1169
@@ -1343,7 +1302,11 @@ hwloc__insert_try_merge_group(hwloc_obj_t old, hwloc_obj_t new)
1343
1302
return NULL ;
1344
1303
}
1345
1304
1346
- /* Try to insert OBJ in CUR, recurse if needed.
1305
+ /*
1306
+ * The main insertion routine, only used for CPU-side object (normal types)
1307
+ * uisng cpuset only (or complete_cpuset).
1308
+ *
1309
+ * Try to insert OBJ in CUR, recurse if needed.
1347
1310
* Returns the object if it was inserted,
1348
1311
* the remaining object it was merged,
1349
1312
* NULL if failed to insert.
@@ -1817,12 +1780,30 @@ hwloc_topology_insert_group_object(struct hwloc_topology *topology, hwloc_obj_t
1817
1780
hwloc_bitmap_and (obj -> complete_nodeset , obj -> complete_nodeset , root -> complete_nodeset );
1818
1781
1819
1782
if ((!obj -> cpuset || hwloc_bitmap_iszero (obj -> cpuset ))
1820
- && (!obj -> complete_cpuset || hwloc_bitmap_iszero (obj -> complete_cpuset ))
1821
- && (!obj -> nodeset || hwloc_bitmap_iszero (obj -> nodeset ))
1822
- && (!obj -> complete_nodeset || hwloc_bitmap_iszero (obj -> complete_nodeset ))) {
1823
- hwloc_free_unlinked_object (obj );
1824
- errno = EINVAL ;
1825
- return NULL ;
1783
+ && (!obj -> complete_cpuset || hwloc_bitmap_iszero (obj -> complete_cpuset ))) {
1784
+ /* we'll insert by cpuset, so build cpuset from the nodeset */
1785
+ hwloc_const_bitmap_t nodeset = obj -> nodeset ? obj -> nodeset : obj -> complete_nodeset ;
1786
+ hwloc_obj_t numa ;
1787
+
1788
+ if ((!obj -> nodeset || hwloc_bitmap_iszero (obj -> nodeset ))
1789
+ && (!obj -> complete_nodeset || hwloc_bitmap_iszero (obj -> complete_nodeset ))) {
1790
+ hwloc_free_unlinked_object (obj );
1791
+ errno = EINVAL ;
1792
+ return NULL ;
1793
+ }
1794
+
1795
+ if (!obj -> cpuset ) {
1796
+ obj -> cpuset = hwloc_bitmap_alloc ();
1797
+ if (!obj -> cpuset ) {
1798
+ hwloc_free_unlinked_object (obj );
1799
+ return NULL ;
1800
+ }
1801
+ }
1802
+
1803
+ numa = NULL ;
1804
+ while ((numa = hwloc_get_next_obj_by_type (topology , HWLOC_OBJ_NUMANODE , numa )) != NULL )
1805
+ if (hwloc_bitmap_isset (nodeset , numa -> os_index ))
1806
+ hwloc_bitmap_or (obj -> cpuset , obj -> cpuset , numa -> cpuset );
1826
1807
}
1827
1808
1828
1809
cmp = hwloc_obj_cmp_sets (obj , root );
0 commit comments