Skip to content

Commit a2abe2c

Browse files
author
ndenoyelle
committed
fix visualstudio build 5
1 parent 713474b commit a2abe2c

File tree

1 file changed

+25
-53
lines changed

1 file changed

+25
-53
lines changed

hwloc/distrib.c

Lines changed: 25 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ hwloc_distrib_root_levels(hwloc_topology_t topology,
105105
levels[i].type = types[i];
106106
levels[i].depth = hwloc_get_type_depth(topology, types[i]);
107107
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]));
110109
goto failure;
111110
}
112111
levels[i].index = NULL;
@@ -116,37 +115,26 @@ hwloc_distrib_root_levels(hwloc_topology_t topology,
116115
}
117116

118117
// 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);
123119

124120
// Walk from top to bottom and set arity to the maximum arity below root field.
125121
unsigned arity;
126-
hwloc_obj_t parent=root;
127-
122+
hwloc_obj_t parent;
123+
124+
parent=root;
128125
for (i=0; i<n_types; i++){
129126
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);
133128
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);
137130
}
138131

139132
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));
143134
goto failure;
144135
}
145136

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);
150138
}
151139

152140
// Allocate levels index.
@@ -187,8 +175,7 @@ hwloc_distrib_build_iterator(hwloc_topology_t topology,
187175
const unsigned n_levels,
188176
const unsigned long flags){
189177
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);
192179
if(it == NULL)
193180
return NULL;
194181

@@ -201,7 +188,8 @@ hwloc_distrib_build_iterator(hwloc_topology_t topology,
201188
for(i=0; i<n_roots; i++){
202189
it->levels[i] = hwloc_distrib_root_levels(topology, roots[i], levels, n_levels, flags);
203190
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]);
205193
goto failure;
206194
}
207195
}
@@ -218,9 +206,7 @@ hwloc_distrib_iterator_round_robin(hwloc_topology_t topology,
218206
const hwloc_obj_type_t type,
219207
const unsigned long flags){
220208
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*));
224210
if(it == NULL)
225211
return NULL;
226212

@@ -229,9 +215,7 @@ hwloc_distrib_iterator_round_robin(hwloc_topology_t topology,
229215
it->n_roots = 1;
230216
it->root_coord = 0;
231217
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));
235219
*it->levels = hwloc_distrib_root_levels(topology, root, &type, 1, flags);
236220

237221
if (*it->levels == NULL){ free(it); return NULL; }
@@ -249,8 +233,7 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
249233
// Count depths with a non empty cpuset.
250234
obj = root;
251235
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)
254237
n++;
255238
if (obj->type == type)
256239
break;
@@ -262,8 +245,7 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
262245
// fill levels array.
263246
obj = root;
264247
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){
267249
levels[n-1-i] = obj->type;
268250
i++;
269251
}
@@ -272,9 +254,7 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
272254
obj = obj->first_child;
273255
}
274256

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*));
278258

279259
if(it == NULL)
280260
return NULL;
@@ -284,13 +264,14 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
284264
it->n_roots = 1;
285265
it->root_coord = 0;
286266
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));
290268

291269
*it->levels = hwloc_distrib_root_levels(topology, root, levels, n, flags);
292270

293-
if (*it->levels == NULL){ free(it); return NULL; }
271+
if (*it->levels == NULL){
272+
free(it);
273+
return NULL;
274+
}
294275
return it;
295276
}
296277

@@ -312,10 +293,7 @@ hwloc_distrib_iterator_inc(struct hwloc_distrib_iterator *it){
312293
do_root:
313294
// Sort by user_index to increment coordinates.
314295
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);
319297

320298
for (i=it->n_levels-1; i>=0; i--){
321299
if(++levels[i].coord >= levels[i].arity)
@@ -344,17 +322,11 @@ hwloc_distrib_iterator_next(hwloc_topology_t topology,
344322
unsigned coord;
345323

346324
// 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);
351326

352327
for(i=0; i<it->n_levels; i++){
353328
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);
358330
if( obj == NULL)
359331
return hwloc_distrib_iterator_inc(it) && hwloc_distrib_iterator_next(topology, it, next);
360332

0 commit comments

Comments
 (0)