@@ -89,13 +89,43 @@ hwloc_calc_append_set(hwloc_bitmap_t set, hwloc_const_bitmap_t newset,
89
89
return 0 ;
90
90
}
91
91
92
+ /* return 1 if obj is filtered out */
93
+ static __hwloc_inline int
94
+ hwloc_calc_check_object_filtered (hwloc_obj_t obj , struct hwloc_calc_level * level )
95
+ {
96
+ if (level -> subtype [0 ]) {
97
+ if (!obj -> subtype || strcasecmp (level -> subtype , obj -> subtype ))
98
+ return 1 ;
99
+ }
100
+
101
+ if (level -> type == HWLOC_OBJ_NUMANODE ) {
102
+ if (level -> only_hbm >= 0 ) {
103
+ /* filter on hbm */
104
+ int obj_is_hbm = obj -> subtype && !strcmp (obj -> subtype , "MCDRAM" );
105
+ if (level -> only_hbm != obj_is_hbm )
106
+ return 1 ;
107
+ }
108
+
109
+ } else if (level -> type == HWLOC_OBJ_PCI_DEVICE ) {
110
+ if (level -> pci_vendor != -1 && (int ) obj -> attr -> pcidev .vendor_id != level -> pci_vendor )
111
+ return 1 ;
112
+ if (level -> pci_device != -1 && (int ) obj -> attr -> pcidev .device_id != level -> pci_device )
113
+ return 1 ;
114
+
115
+ } else if (level -> type == HWLOC_OBJ_OS_DEVICE ) {
116
+ if (level -> attr .osdev .type != 0 && !(obj -> attr -> osdev .type & level -> attr .osdev .type ))
117
+ return 1 ;
118
+ }
119
+
120
+ return 0 ;
121
+ }
122
+
92
123
static __hwloc_inline unsigned
93
124
hwloc_calc_get_nbobjs_inside_sets_by_depth (struct hwloc_calc_location_context_s * lcontext ,
94
125
hwloc_const_bitmap_t cpuset , hwloc_const_bitmap_t nodeset ,
95
126
struct hwloc_calc_level * level )
96
127
{
97
128
hwloc_topology_t topology = lcontext -> topology ;
98
- int only_hbm = level -> only_hbm ;
99
129
hwloc_obj_t obj = NULL ;
100
130
unsigned n = 0 ;
101
131
while ((obj = hwloc_get_next_obj_by_depth (topology , level -> depth , obj )) != NULL ) {
@@ -106,16 +136,8 @@ hwloc_calc_get_nbobjs_inside_sets_by_depth(struct hwloc_calc_location_context_s
106
136
if (hwloc_bitmap_iszero (obj -> cpuset ) && hwloc_bitmap_iszero (obj -> nodeset ))
107
137
/* ignore objects with empty sets (both can be empty when outside of cgroup) */
108
138
continue ;
109
- if (only_hbm >= 0 && obj -> type == HWLOC_OBJ_NUMANODE ) {
110
- /* filter on hbm */
111
- int obj_is_hbm = obj -> subtype && !strcmp (obj -> subtype , "MCDRAM" );
112
- if (only_hbm != obj_is_hbm )
113
- continue ;
114
- }
115
- if (level -> subtype [0 ]) {
116
- if (!obj -> subtype || strcasecmp (level -> subtype , obj -> subtype ))
117
- continue ;
118
- }
139
+ if (hwloc_calc_check_object_filtered (obj , level ))
140
+ continue ;
119
141
n ++ ;
120
142
}
121
143
return n ;
@@ -127,7 +149,6 @@ hwloc_calc_get_obj_inside_sets_by_depth(struct hwloc_calc_location_context_s *lc
127
149
struct hwloc_calc_level * level , unsigned ind )
128
150
{
129
151
hwloc_topology_t topology = lcontext -> topology ;
130
- int only_hbm = level -> only_hbm ;
131
152
int logical = lcontext -> logical ;
132
153
hwloc_obj_t obj = NULL ;
133
154
unsigned i = 0 ;
@@ -139,16 +160,8 @@ hwloc_calc_get_obj_inside_sets_by_depth(struct hwloc_calc_location_context_s *lc
139
160
if (hwloc_bitmap_iszero (obj -> cpuset ) && hwloc_bitmap_iszero (obj -> nodeset ))
140
161
/* ignore objects with empty sets (both can be empty when outside of cgroup) */
141
162
continue ;
142
- if (only_hbm >= 0 && obj -> type == HWLOC_OBJ_NUMANODE ) {
143
- /* filter on hbm */
144
- int obj_is_hbm = obj -> subtype && !strcmp (obj -> subtype , "MCDRAM" );
145
- if (only_hbm != obj_is_hbm )
146
- continue ;
147
- }
148
- if (level -> subtype [0 ]) {
149
- if (!obj -> subtype || strcasecmp (level -> subtype , obj -> subtype ))
150
- continue ;
151
- }
163
+ if (hwloc_calc_check_object_filtered (obj , level ))
164
+ continue ;
152
165
if (logical ) {
153
166
if (i == ind )
154
167
return obj ;
@@ -544,22 +557,8 @@ hwloc_calc_append_iodev_by_index(struct hwloc_calc_location_context_s *lcontext,
544
557
if (obj == prev ) /* already used that object, stop wrapping around */
545
558
break ;
546
559
547
- if (level -> type == HWLOC_OBJ_PCI_DEVICE ) {
548
- if (level -> pci_vendor != -1 && (int ) obj -> attr -> pcidev .vendor_id != level -> pci_vendor )
549
- continue ;
550
- if (level -> pci_device != -1 && (int ) obj -> attr -> pcidev .device_id != level -> pci_device )
551
- continue ;
552
- }
553
-
554
- if (level -> type == HWLOC_OBJ_OS_DEVICE ) {
555
- if ((obj -> attr -> osdev .type & level -> attr .osdev .type ) != level -> attr .osdev .type )
556
- continue ;
557
- }
558
-
559
- if (level -> subtype [0 ]) {
560
- if (!obj -> subtype || strcasecmp (level -> subtype , obj -> subtype ))
561
- continue ;
562
- }
560
+ if (hwloc_calc_check_object_filtered (obj , level ))
561
+ continue ;
563
562
564
563
if (first -- )
565
564
continue ;
0 commit comments