Skip to content

Commit 02327b3

Browse files
author
ndenoyelle
committed
fix visualstudio build
1 parent 7eca5bd commit 02327b3

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

hwloc/distrib.c

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,21 @@ struct hwloc_distrib_iterator{
3131
};
3232

3333
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));
3535

3636
if(r==NULL)
3737
return NULL;
38-
for(size_t i=0; i<n; i++)
38+
for(i=0; i<n; i++)
3939
r[i] = i;
4040
return r;
4141
}
4242

4343
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));
4545

4646
if(r==NULL)
4747
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; }
4949
return r;
5050
}
5151

@@ -98,11 +98,12 @@ hwloc_distrib_root_levels(hwloc_topology_t topology,
9898
const size_t n_types,
9999
const unsigned long flags)
100100
{
101+
size_t i;
101102
struct hwloc_distrib_level *levels = malloc(n_types * sizeof(*levels));
102103
if(levels == NULL)
103104
return NULL;
104105

105-
for (size_t i=0; i<n_types; i++){
106+
for (i=0; i<n_types; i++){
106107
levels[i].type = types[i];
107108
levels[i].depth = hwloc_get_type_depth(topology, types[i]);
108109
if (levels[i].depth < 0 ){
@@ -125,7 +126,8 @@ hwloc_distrib_root_levels(hwloc_topology_t topology,
125126
// Walk from top to bottom and set arity to the maximum arity below root field.
126127
size_t arity;
127128
hwloc_obj_t parent=root;
128-
for (size_t i=0; i<n_types; i++){
129+
130+
for (i=0; i<n_types; i++){
129131
while (parent) {
130132
arity = hwloc_get_nbobjs_inside_cpuset_by_depth(topology,
131133
parent->cpuset,
@@ -150,7 +152,7 @@ hwloc_distrib_root_levels(hwloc_topology_t topology,
150152
}
151153

152154
// Allocate levels index.
153-
for (size_t i=0; i<n_types; i++){
155+
for (i=0; i<n_types; i++){
154156
if (flags & HWLOC_DISTRIB_FLAG_SHUFFLE) {
155157
levels[i].index = shuffled_range(levels[i].arity);
156158
}
@@ -186,7 +188,7 @@ hwloc_distrib_build_iterator(hwloc_topology_t topology,
186188
const hwloc_obj_type_t *levels,
187189
const size_t n_levels,
188190
const unsigned long flags){
189-
191+
size_t i;
190192
struct hwloc_distrib_iterator *it = malloc(sizeof(*it) +
191193
sizeof(*it->levels) * n_roots);
192194
if(it == NULL)
@@ -198,7 +200,7 @@ hwloc_distrib_build_iterator(hwloc_topology_t topology,
198200
it->n_levels = n_levels;
199201
it->levels = (struct hwloc_distrib_level **)((char*)it + sizeof(*it));
200202

201-
for(size_t i=0; i<n_roots; i++){
203+
for(i=0; i<n_roots; i++){
202204
it->levels[i] = hwloc_distrib_root_levels(topology, roots[i], levels, n_levels, flags);
203205
if(it->levels[i] == NULL){
204206
while(i--){ hwloc_distrib_destroy_level(it->levels[i]); }
@@ -245,9 +247,9 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
245247

246248
size_t i=0, n=0;
247249
hwloc_obj_t obj, root = hwloc_get_obj_by_depth(topology, 0, 0);
248-
obj = root;
249-
250+
250251
// Count depths with a non empty cpuset.
252+
obj = root;
251253
while(obj){
252254
if ((obj->cpuset != NULL && !hwloc_bitmap_iszero(obj->cpuset)) &&
253255
hwloc_get_type_depth(topology, obj->type) >= 0)
@@ -256,10 +258,11 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
256258
break;
257259
obj = obj->first_child;
258260
}
259-
260-
obj = root;
261+
261262
hwloc_obj_type_t levels[n];
263+
262264
// fill levels array.
265+
obj = root;
263266
while(obj){
264267
if( obj->cpuset != NULL && !hwloc_bitmap_iszero(obj->cpuset) &&
265268
hwloc_get_type_depth(topology, obj->type) >= 0){
@@ -274,6 +277,7 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
274277
struct hwloc_distrib_iterator *it = malloc(sizeof(*it) +
275278
sizeof(hwloc_obj_t) +
276279
sizeof(struct hwloc_distrib_level*));
280+
277281
if(it == NULL)
278282
return NULL;
279283

@@ -293,7 +297,9 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
293297
}
294298

295299
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++)
297303
hwloc_distrib_destroy_level(it->levels[i]);
298304
free(it);
299305
}
@@ -334,6 +340,7 @@ int
334340
hwloc_distrib_iterator_next(hwloc_topology_t topology,
335341
struct hwloc_distrib_iterator *it,
336342
hwloc_obj_t *next){
343+
size_t i;
337344
struct hwloc_distrib_level *levels = it->levels[it->root_coord];
338345
hwloc_obj_t obj = it->roots[it->root_coord];
339346
size_t coord;
@@ -344,7 +351,7 @@ hwloc_distrib_iterator_next(hwloc_topology_t topology,
344351
sizeof(*levels),
345352
hwloc_distrib_level_cmp_depth);
346353

347-
for(size_t i=0; i<it->n_levels; i++){
354+
for(i=0; i<it->n_levels; i++){
348355
coord = levels[i].index[levels[i].coord];
349356
obj = hwloc_get_obj_inside_cpuset_by_depth(topology,
350357
obj->cpuset,

0 commit comments

Comments
 (0)