@@ -37,6 +37,7 @@ struct hwloc_calc_level {
37
37
int depth ;
38
38
hwloc_obj_type_t type ;
39
39
union hwloc_obj_attr_u attr ;
40
+ char subtype [32 ];
40
41
int pci_vendor , pci_device ;
41
42
int only_hbm ; /* -1 for everything, 0 for only non-HBM, 1 for only HBM numa nodes */
42
43
};
@@ -111,6 +112,10 @@ hwloc_calc_get_nbobjs_inside_sets_by_depth(struct hwloc_calc_location_context_s
111
112
if (only_hbm != obj_is_hbm )
112
113
continue ;
113
114
}
115
+ if (level -> subtype [0 ]) {
116
+ if (!obj -> subtype || strcasecmp (level -> subtype , obj -> subtype ))
117
+ continue ;
118
+ }
114
119
n ++ ;
115
120
}
116
121
return n ;
@@ -140,6 +145,10 @@ hwloc_calc_get_obj_inside_sets_by_depth(struct hwloc_calc_location_context_s *lc
140
145
if (only_hbm != obj_is_hbm )
141
146
continue ;
142
147
}
148
+ if (level -> subtype [0 ]) {
149
+ if (!obj -> subtype || strcasecmp (level -> subtype , obj -> subtype ))
150
+ continue ;
151
+ }
143
152
if (logical ) {
144
153
if (i == ind )
145
154
return obj ;
@@ -181,6 +190,13 @@ hwloc_calc_parse_level_filter(hwloc_topology_t topology __hwloc_attribute_unused
181
190
struct hwloc_calc_level * level )
182
191
{
183
192
const char * current = filter ;
193
+ const char * end ;
194
+ unsigned subtypelen ;
195
+
196
+ if (!strncmp (current , "subtype=" , 8 )) {
197
+ current += 8 ;
198
+ goto subtype ;
199
+ }
184
200
185
201
if (level -> type == HWLOC_OBJ_PCI_DEVICE ) {
186
202
/* try to match by [vendor:device] */
@@ -202,12 +218,15 @@ hwloc_calc_parse_level_filter(hwloc_topology_t topology __hwloc_attribute_unused
202
218
fprintf (stderr , "invalid PCI vendor:device filter specification %s\n" , filter );
203
219
return -1 ;
204
220
}
205
-
206
- } else {
207
- fprintf (stderr , "invalid filter specification %s\n" , filter );
208
- return -1 ;
209
221
}
210
222
223
+ subtype :
224
+ /* assume it's a subtype */
225
+ end = strchr (current , ']' );
226
+ subtypelen = end - current ;
227
+ if (subtypelen >= sizeof (level -> subtype ))
228
+ subtypelen = sizeof (level -> subtype ) - 1 ;
229
+ snprintf (level -> subtype , subtypelen + 1 , "%s" , current );
211
230
return 0 ;
212
231
}
213
232
@@ -221,6 +240,7 @@ hwloc_calc_parse_level(struct hwloc_calc_location_context_s *lcontext,
221
240
char * endptr ;
222
241
int err ;
223
242
243
+ level -> subtype [0 ] = '\0' ;
224
244
level -> pci_device = level -> pci_vendor = -1 ;
225
245
level -> only_hbm = -1 ;
226
246
if (lcontext )
@@ -536,6 +556,11 @@ hwloc_calc_append_iodev_by_index(struct hwloc_calc_location_context_s *lcontext,
536
556
continue ;
537
557
}
538
558
559
+ if (level -> subtype [0 ]) {
560
+ if (!obj -> subtype || strcasecmp (level -> subtype , obj -> subtype ))
561
+ continue ;
562
+ }
563
+
539
564
if (first -- )
540
565
continue ;
541
566
0 commit comments