@@ -31,21 +31,21 @@ struct hwloc_distrib_iterator{
31
31
};
32
32
33
33
static size_t * range (const size_t n ){
34
- size_t * r = malloc (n * sizeof (* r ));
34
+ size_t * i , r = malloc (n * sizeof (* r ));
35
35
36
36
if (r == NULL )
37
37
return NULL ;
38
- for (size_t i = 0 ; i < n ; i ++ )
38
+ for (i = 0 ; i < n ; i ++ )
39
39
r [i ] = i ;
40
40
return r ;
41
41
}
42
42
43
43
static size_t * reversed_range (const size_t n ){
44
- size_t * r = malloc (n * sizeof (* r ));
44
+ size_t * i , r = malloc (n * sizeof (* r ));
45
45
46
46
if (r == NULL )
47
47
return NULL ;
48
- for (size_t i = 0 ; i < n ; i ++ ){ r [i ] = n - i - 1 ; }
48
+ for (i = 0 ; i < n ; i ++ ){ r [i ] = n - i - 1 ; }
49
49
return r ;
50
50
}
51
51
@@ -98,11 +98,12 @@ hwloc_distrib_root_levels(hwloc_topology_t topology,
98
98
const size_t n_types ,
99
99
const unsigned long flags )
100
100
{
101
+ size_t i ;
101
102
struct hwloc_distrib_level * levels = malloc (n_types * sizeof (* levels ));
102
103
if (levels == NULL )
103
104
return NULL ;
104
105
105
- for (size_t i = 0 ; i < n_types ; i ++ ){
106
+ for (i = 0 ; i < n_types ; i ++ ){
106
107
levels [i ].type = types [i ];
107
108
levels [i ].depth = hwloc_get_type_depth (topology , types [i ]);
108
109
if (levels [i ].depth < 0 ){
@@ -125,7 +126,8 @@ hwloc_distrib_root_levels(hwloc_topology_t topology,
125
126
// Walk from top to bottom and set arity to the maximum arity below root field.
126
127
size_t arity ;
127
128
hwloc_obj_t parent = root ;
128
- for (size_t i = 0 ; i < n_types ; i ++ ){
129
+
130
+ for (i = 0 ; i < n_types ; i ++ ){
129
131
while (parent ) {
130
132
arity = hwloc_get_nbobjs_inside_cpuset_by_depth (topology ,
131
133
parent -> cpuset ,
@@ -150,7 +152,7 @@ hwloc_distrib_root_levels(hwloc_topology_t topology,
150
152
}
151
153
152
154
// Allocate levels index.
153
- for (size_t i = 0 ; i < n_types ; i ++ ){
155
+ for (i = 0 ; i < n_types ; i ++ ){
154
156
if (flags & HWLOC_DISTRIB_FLAG_SHUFFLE ) {
155
157
levels [i ].index = shuffled_range (levels [i ].arity );
156
158
}
@@ -186,7 +188,7 @@ hwloc_distrib_build_iterator(hwloc_topology_t topology,
186
188
const hwloc_obj_type_t * levels ,
187
189
const size_t n_levels ,
188
190
const unsigned long flags ){
189
-
191
+ size_t i ;
190
192
struct hwloc_distrib_iterator * it = malloc (sizeof (* it ) +
191
193
sizeof (* it -> levels ) * n_roots );
192
194
if (it == NULL )
@@ -198,7 +200,7 @@ hwloc_distrib_build_iterator(hwloc_topology_t topology,
198
200
it -> n_levels = n_levels ;
199
201
it -> levels = (struct hwloc_distrib_level * * )((char * )it + sizeof (* it ));
200
202
201
- for (size_t i = 0 ; i < n_roots ; i ++ ){
203
+ for (i = 0 ; i < n_roots ; i ++ ){
202
204
it -> levels [i ] = hwloc_distrib_root_levels (topology , roots [i ], levels , n_levels , flags );
203
205
if (it -> levels [i ] == NULL ){
204
206
while (i -- ){ hwloc_distrib_destroy_level (it -> levels [i ]); }
@@ -245,9 +247,9 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
245
247
246
248
size_t i = 0 , n = 0 ;
247
249
hwloc_obj_t obj , root = hwloc_get_obj_by_depth (topology , 0 , 0 );
248
- obj = root ;
249
-
250
+
250
251
// Count depths with a non empty cpuset.
252
+ obj = root ;
251
253
while (obj ){
252
254
if ((obj -> cpuset != NULL && !hwloc_bitmap_iszero (obj -> cpuset )) &&
253
255
hwloc_get_type_depth (topology , obj -> type ) >= 0 )
@@ -256,10 +258,11 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
256
258
break ;
257
259
obj = obj -> first_child ;
258
260
}
259
-
260
- obj = root ;
261
+
261
262
hwloc_obj_type_t levels [n ];
263
+
262
264
// fill levels array.
265
+ obj = root ;
263
266
while (obj ){
264
267
if ( obj -> cpuset != NULL && !hwloc_bitmap_iszero (obj -> cpuset ) &&
265
268
hwloc_get_type_depth (topology , obj -> type ) >= 0 ){
@@ -274,6 +277,7 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
274
277
struct hwloc_distrib_iterator * it = malloc (sizeof (* it ) +
275
278
sizeof (hwloc_obj_t ) +
276
279
sizeof (struct hwloc_distrib_level * ));
280
+
277
281
if (it == NULL )
278
282
return NULL ;
279
283
@@ -293,7 +297,9 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
293
297
}
294
298
295
299
void hwloc_distrib_destroy_iterator (struct hwloc_distrib_iterator * it ){
296
- for (size_t i = 0 ; i < it -> n_roots ; i ++ )
300
+ size_t i ;
301
+
302
+ for (i = 0 ; i < it -> n_roots ; i ++ )
297
303
hwloc_distrib_destroy_level (it -> levels [i ]);
298
304
free (it );
299
305
}
334
340
hwloc_distrib_iterator_next (hwloc_topology_t topology ,
335
341
struct hwloc_distrib_iterator * it ,
336
342
hwloc_obj_t * next ){
343
+ size_t i ;
337
344
struct hwloc_distrib_level * levels = it -> levels [it -> root_coord ];
338
345
hwloc_obj_t obj = it -> roots [it -> root_coord ];
339
346
size_t coord ;
@@ -344,7 +351,7 @@ hwloc_distrib_iterator_next(hwloc_topology_t topology,
344
351
sizeof (* levels ),
345
352
hwloc_distrib_level_cmp_depth );
346
353
347
- for (size_t i = 0 ; i < it -> n_levels ; i ++ ){
354
+ for (i = 0 ; i < it -> n_levels ; i ++ ){
348
355
coord = levels [i ].index [levels [i ].coord ];
349
356
obj = hwloc_get_obj_inside_cpuset_by_depth (topology ,
350
357
obj -> cpuset ,
0 commit comments