@@ -105,8 +105,7 @@ hwloc_distrib_root_levels(hwloc_topology_t topology,
105
105
levels [i ].type = types [i ];
106
106
levels [i ].depth = hwloc_get_type_depth (topology , types [i ]);
107
107
if (levels [i ].depth < 0 ){
108
- fprintf (stderr , "Cannot build iterator with objects %s of negative depth.\n" ,
109
- hwloc_obj_type_string (types [i ]));
108
+ fprintf (stderr , "Cannot build iterator with objects %s of negative depth.\n" , hwloc_obj_type_string (types [i ]));
110
109
goto failure ;
111
110
}
112
111
levels [i ].index = NULL ;
@@ -116,37 +115,26 @@ hwloc_distrib_root_levels(hwloc_topology_t topology,
116
115
}
117
116
118
117
// Sort by depth to compute arities.
119
- qsort (levels ,
120
- n_types ,
121
- sizeof (* levels ),
122
- hwloc_distrib_level_cmp_depth );
118
+ qsort (levels , n_types , sizeof (* levels ), hwloc_distrib_level_cmp_depth );
123
119
124
120
// Walk from top to bottom and set arity to the maximum arity below root field.
125
121
unsigned arity ;
126
- hwloc_obj_t parent = root ;
127
-
122
+ hwloc_obj_t parent ;
123
+
124
+ parent = root ;
128
125
for (i = 0 ; i < n_types ; i ++ ){
129
126
while (parent ) {
130
- arity = hwloc_get_nbobjs_inside_cpuset_by_depth (topology ,
131
- parent -> cpuset ,
132
- levels [i ].depth );
127
+ arity = hwloc_get_nbobjs_inside_cpuset_by_depth (topology , parent -> cpuset , levels [i ].depth );
133
128
levels [i ].arity = arity > levels [i ].arity ? arity : levels [i ].arity ;
134
- parent = hwloc_get_next_obj_inside_cpuset_by_depth (topology ,
135
- root -> cpuset ,
136
- parent -> depth , parent );
129
+ parent = hwloc_get_next_obj_inside_cpuset_by_depth (topology , root -> cpuset , parent -> depth , parent );
137
130
}
138
131
139
132
if (levels [i ].arity == 0 ) {
140
- fprintf (stderr , "No object of type %s below level %s.\n" ,
141
- hwloc_obj_type_string (levels [i ].type ),
142
- hwloc_obj_type_string (levels [i - 1 ].type ));
133
+ fprintf (stderr , "No object of type %s below level %s.\n" , hwloc_obj_type_string (levels [i ].type ), hwloc_obj_type_string (levels [i - 1 ].type ));
143
134
goto failure ;
144
135
}
145
136
146
- parent = hwloc_get_obj_inside_cpuset_by_depth (topology ,
147
- root -> cpuset ,
148
- levels [i ].depth ,
149
- 0 );
137
+ parent = hwloc_get_obj_inside_cpuset_by_depth (topology , root -> cpuset , levels [i ].depth , 0 );
150
138
}
151
139
152
140
// Allocate levels index.
@@ -187,8 +175,7 @@ hwloc_distrib_build_iterator(hwloc_topology_t topology,
187
175
const unsigned n_levels ,
188
176
const unsigned long flags ){
189
177
unsigned i ;
190
- struct hwloc_distrib_iterator * it = malloc (sizeof (* it ) +
191
- sizeof (* it -> levels ) * n_roots );
178
+ struct hwloc_distrib_iterator * it = malloc (sizeof (* it ) + sizeof (* it -> levels ) * n_roots );
192
179
if (it == NULL )
193
180
return NULL ;
194
181
@@ -201,7 +188,8 @@ hwloc_distrib_build_iterator(hwloc_topology_t topology,
201
188
for (i = 0 ; i < n_roots ; i ++ ){
202
189
it -> levels [i ] = hwloc_distrib_root_levels (topology , roots [i ], levels , n_levels , flags );
203
190
if (it -> levels [i ] == NULL ){
204
- while (i -- ){ hwloc_distrib_destroy_level (it -> levels [i ]); }
191
+ while (i -- )
192
+ hwloc_distrib_destroy_level (it -> levels [i ]);
205
193
goto failure ;
206
194
}
207
195
}
@@ -218,9 +206,7 @@ hwloc_distrib_iterator_round_robin(hwloc_topology_t topology,
218
206
const hwloc_obj_type_t type ,
219
207
const unsigned long flags ){
220
208
hwloc_obj_t root = hwloc_get_obj_by_depth (topology , 0 , 0 );
221
- struct hwloc_distrib_iterator * it = malloc (sizeof (* it ) +
222
- sizeof (hwloc_obj_t ) +
223
- sizeof (struct hwloc_distrib_level * ));
209
+ struct hwloc_distrib_iterator * it = malloc (sizeof (* it ) + sizeof (hwloc_obj_t ) + sizeof (struct hwloc_distrib_level * ));
224
210
if (it == NULL )
225
211
return NULL ;
226
212
@@ -229,9 +215,7 @@ hwloc_distrib_iterator_round_robin(hwloc_topology_t topology,
229
215
it -> n_roots = 1 ;
230
216
it -> root_coord = 0 ;
231
217
it -> n_levels = 1 ;
232
- it -> levels = (struct hwloc_distrib_level * * )((char * )it +
233
- sizeof (* it ) +
234
- sizeof (hwloc_obj_t ));
218
+ it -> levels = (struct hwloc_distrib_level * * )((char * )it + sizeof (* it ) + sizeof (hwloc_obj_t ));
235
219
* it -> levels = hwloc_distrib_root_levels (topology , root , & type , 1 , flags );
236
220
237
221
if (* it -> levels == NULL ){ free (it ); return NULL ; }
@@ -249,8 +233,7 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
249
233
// Count depths with a non empty cpuset.
250
234
obj = root ;
251
235
while (obj ){
252
- if ((obj -> cpuset != NULL && !hwloc_bitmap_iszero (obj -> cpuset )) &&
253
- hwloc_get_type_depth (topology , obj -> type ) >= 0 )
236
+ if ((obj -> cpuset != NULL && !hwloc_bitmap_iszero (obj -> cpuset )) && hwloc_get_type_depth (topology , obj -> type ) >= 0 )
254
237
n ++ ;
255
238
if (obj -> type == type )
256
239
break ;
@@ -262,8 +245,7 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
262
245
// fill levels array.
263
246
obj = root ;
264
247
while (obj ){
265
- if ( obj -> cpuset != NULL && !hwloc_bitmap_iszero (obj -> cpuset ) &&
266
- hwloc_get_type_depth (topology , obj -> type ) >= 0 ){
248
+ if ( obj -> cpuset != NULL && !hwloc_bitmap_iszero (obj -> cpuset ) && hwloc_get_type_depth (topology , obj -> type ) >= 0 ){
267
249
levels [n - 1 - i ] = obj -> type ;
268
250
i ++ ;
269
251
}
@@ -272,9 +254,7 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
272
254
obj = obj -> first_child ;
273
255
}
274
256
275
- struct hwloc_distrib_iterator * it = malloc (sizeof (* it ) +
276
- sizeof (hwloc_obj_t ) +
277
- sizeof (struct hwloc_distrib_level * ));
257
+ struct hwloc_distrib_iterator * it = malloc (sizeof (* it ) + sizeof (hwloc_obj_t ) + sizeof (struct hwloc_distrib_level * ));
278
258
279
259
if (it == NULL )
280
260
return NULL ;
@@ -284,13 +264,14 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
284
264
it -> n_roots = 1 ;
285
265
it -> root_coord = 0 ;
286
266
it -> n_levels = n ;
287
- it -> levels = (struct hwloc_distrib_level * * )((char * )it +
288
- sizeof (* it ) +
289
- sizeof (hwloc_obj_t ));
267
+ it -> levels = (struct hwloc_distrib_level * * )((char * )it + sizeof (* it ) + sizeof (hwloc_obj_t ));
290
268
291
269
* it -> levels = hwloc_distrib_root_levels (topology , root , levels , n , flags );
292
270
293
- if (* it -> levels == NULL ){ free (it ); return NULL ; }
271
+ if (* it -> levels == NULL ){
272
+ free (it );
273
+ return NULL ;
274
+ }
294
275
return it ;
295
276
}
296
277
@@ -312,10 +293,7 @@ hwloc_distrib_iterator_inc(struct hwloc_distrib_iterator *it){
312
293
do_root :
313
294
// Sort by user_index to increment coordinates.
314
295
levels = it -> levels [it -> root_coord ];
315
- qsort (levels ,
316
- it -> n_levels ,
317
- sizeof (* levels ),
318
- hwloc_distrib_level_cmp_user_index );
296
+ qsort (levels , it -> n_levels , sizeof (* levels ), hwloc_distrib_level_cmp_user_index );
319
297
320
298
for (i = it -> n_levels - 1 ; i >=0 ; i -- ){
321
299
if (++ levels [i ].coord >= levels [i ].arity )
@@ -344,17 +322,11 @@ hwloc_distrib_iterator_next(hwloc_topology_t topology,
344
322
unsigned coord ;
345
323
346
324
// Sort by depth to walk objects at set coordinates.
347
- qsort (levels ,
348
- it -> n_levels ,
349
- sizeof (* levels ),
350
- hwloc_distrib_level_cmp_depth );
325
+ qsort (levels , it -> n_levels , sizeof (* levels ), hwloc_distrib_level_cmp_depth );
351
326
352
327
for (i = 0 ; i < it -> n_levels ; i ++ ){
353
328
coord = levels [i ].index [levels [i ].coord ];
354
- obj = hwloc_get_obj_inside_cpuset_by_depth (topology ,
355
- obj -> cpuset ,
356
- levels [i ].depth ,
357
- coord );
329
+ obj = hwloc_get_obj_inside_cpuset_by_depth (topology , obj -> cpuset , levels [i ].depth , coord );
358
330
if ( obj == NULL )
359
331
return hwloc_distrib_iterator_inc (it ) && hwloc_distrib_iterator_next (topology , it , next );
360
332
0 commit comments