@@ -72,6 +72,9 @@ static hwloc_obj_type_t parse_policy_type(const char* type){
72
72
73
73
// Parse string in arg_types after topology create, load, filter etc...
74
74
static void parse_policy (void ){
75
+ size_t i ;
76
+ char * type ;
77
+
75
78
if (policy == ROUND_ROBIN ){
76
79
num_types = 1 ;
77
80
policy_types = malloc (sizeof (* policy_types ));
@@ -83,9 +86,6 @@ static void parse_policy(void){
83
86
* policy_types = parse_policy_type (arg_types );
84
87
}
85
88
else {
86
- size_t i ;
87
- char * type ;
88
-
89
89
for (i = 0 ; i < strlen (arg_types ); i ++ )
90
90
if (arg_types [i ] == ':' )
91
91
num_types ++ ;
@@ -104,19 +104,27 @@ int main(int argc, char *argv[])
104
104
{
105
105
long n = -1 ;
106
106
char * input = NULL ;
107
+ char * restrictstring = NULL ;
108
+ char * str = NULL ;
107
109
enum hwloc_utils_input_format input_format = HWLOC_UTILS_INPUT_DEFAULT ;
108
110
int taskset = 0 ;
109
111
int singlify = 0 ;
110
112
int logical_index = 0 ;
111
113
int physical_index = 0 ;
112
114
int verbose = 0 ;
113
- char * restrictstring = NULL ;
115
+ int continue_it = 1 ;
114
116
int from_index = -1 ;
115
- unsigned long flags = 0 ;
116
- unsigned long dflags = 0 ;
117
117
int opt ;
118
118
int err ;
119
-
119
+ unsigned long flags = 0 ;
120
+ unsigned long dflags = 0 ;
121
+ unsigned last ;
122
+ struct hwloc_distrib_iterator * it ;
123
+ hwloc_obj_type_t type ;
124
+ hwloc_bitmap_t cpuset ;
125
+ hwloc_bitmap_t restrictset ;
126
+ hwloc_obj_t root , next ;
127
+
120
128
callname = argv [0 ];
121
129
hwloc_utils_check_api_version (callname );
122
130
@@ -207,7 +215,6 @@ int main(int argc, char *argv[])
207
215
goto next ;
208
216
}
209
217
else if (!strcmp (argv [0 ], "--ignore" )) {
210
- hwloc_obj_type_t type ;
211
218
if (argc < 2 ) {
212
219
usage (callname , stdout );
213
220
exit (EXIT_FAILURE );
@@ -273,12 +280,8 @@ int main(int argc, char *argv[])
273
280
argv ++ ;
274
281
}
275
282
276
- {
277
- hwloc_bitmap_t cpuset = hwloc_bitmap_alloc ();
278
- struct hwloc_distrib_iterator * it ;
279
- hwloc_obj_t root , next = NULL ;
280
-
281
- if (input ) {
283
+ cpuset = hwloc_bitmap_alloc ();
284
+ if (input ) {
282
285
err = hwloc_utils_enable_input_format (topology , flags , input , & input_format , verbose , callname );
283
286
if (err ) {
284
287
free (cpuset );
@@ -288,12 +291,12 @@ int main(int argc, char *argv[])
288
291
hwloc_topology_set_flags (topology , flags );
289
292
err = hwloc_topology_load (topology );
290
293
if (err < 0 ) {
291
- free (cpuset );
294
+ hwloc_bitmap_free (cpuset );
292
295
return EXIT_FAILURE ;
293
296
}
294
297
295
298
if (restrictstring ) {
296
- hwloc_bitmap_t restrictset = hwloc_bitmap_alloc ();
299
+ restrictset = hwloc_bitmap_alloc ();
297
300
hwloc_bitmap_sscanf (restrictset , restrictstring );
298
301
err = hwloc_topology_restrict (topology , restrictset , 0 );
299
302
if (err ) {
@@ -322,21 +325,18 @@ int main(int argc, char *argv[])
322
325
return EXIT_FAILURE ;
323
326
324
327
// Go to start index.
325
- while ( hwloc_distrib_iterator_next (topology , it , & next ) &&
326
- from_index > 0 && next -> logical_index != from_index );
328
+ while ( hwloc_distrib_iterator_next (topology , it , & next ) && from_index > 0 && next -> logical_index != from_index );
327
329
328
- int continue_it = 1 ;
329
330
do {
330
331
if (logical_index ) {
331
332
printf ("%d\n" , next -> logical_index );
332
333
} else if (physical_index ){
333
334
printf ("%d\n" , next -> os_index );
334
335
} else {
335
336
hwloc_bitmap_copy (cpuset , next -> cpuset );
336
- char * str = NULL ;
337
337
if (singlify ) {
338
338
if (dflags & HWLOC_DISTRIB_FLAG_REVERSE ) {
339
- unsigned last = hwloc_bitmap_last (cpuset );
339
+ last = hwloc_bitmap_last (cpuset );
340
340
hwloc_bitmap_only (cpuset , last );
341
341
} else {
342
342
hwloc_bitmap_singlify (cpuset );
@@ -352,11 +352,10 @@ int main(int argc, char *argv[])
352
352
if ((! continue_it && n < 0 ) || -- n == 0 )
353
353
break ;
354
354
continue_it = hwloc_distrib_iterator_next (topology , it , & next );
355
- } while (1 );
356
- hwloc_bitmap_free (cpuset );
357
- hwloc_distrib_destroy_iterator (it );
358
- free (policy_types );
359
- }
355
+ } while (1 );
356
+ hwloc_bitmap_free (cpuset );
357
+ hwloc_distrib_destroy_iterator (it );
358
+ free (policy_types );
360
359
361
360
hwloc_topology_destroy (topology );
362
361
0 commit comments