@@ -35,24 +35,25 @@ void usage(const char *name, FILE *where)
35
35
fprintf (where , " --no-smt Only keep a single PU per core\n" );
36
36
fprintf (where , " --restrict [nodeset=]<bitmap>\n" );
37
37
fprintf (where , " Restrict the topology to some processors or NUMA nodes.\n" );
38
- fprintf (where , " --restrict-flags <n> Set the flags to be used during restrict\n" );
38
+ fprintf (where , " --restrict-flags <n>\n" );
39
+ fprintf (where , " Set the flags to be used during restrict\n" );
39
40
fprintf (where , " --disallowed Include objects disallowed by administrative limitations\n" );
40
41
fprintf (where , " --hbm Only consider high bandwidth memory nodes\n" );
41
42
fprintf (where , " --no-hbm Ignore high-bandwidth memory nodes\n" );
42
43
fprintf (where , "Options:\n" );
43
44
fprintf (where , " --cpubind Use following arguments for cpu binding (default)\n" );
44
45
fprintf (where , " --membind Use following arguments for memory binding\n" );
45
- fprintf (where , " --mempolicy <default|firsttouch|bind|interleave|nexttouch>\n"
46
- " Change policy that --membind applies (default is bind)\n" );
46
+ fprintf (where , " --mempolicy <default|firsttouch|bind|interleave|nexttouch>\n" );
47
+ fprintf ( where , " Change policy that --membind applies (default is bind)\n" );
47
48
fprintf (where , " --best-memattr <attr>\n" );
48
49
fprintf (where , " Select the best target node in the given memory binding\n" );
49
50
fprintf (where , " -l --logical Take logical object indexes (default)\n" );
50
51
fprintf (where , " -p --physical Take physical object indexes\n" );
51
52
fprintf (where , " --single Bind on a single CPU to prevent migration\n" );
52
53
fprintf (where , " --strict Require strict binding\n" );
53
54
fprintf (where , " --get Retrieve current process binding\n" );
54
- fprintf (where , " -e --get-last-cpu-location\n"
55
- " Retrieve the last processors where the current process ran\n" );
55
+ fprintf (where , " -e --get-last-cpu-location\n" );
56
+ fprintf ( where , " Retrieve the last processors where the current process ran\n" );
56
57
fprintf (where , " --nodeset Display (and parse) cpusets as nodesets\n" );
57
58
fprintf (where , " --pid <pid> Operate on process <pid>\n" );
58
59
#ifdef HWLOC_LINUX_SYS
@@ -120,8 +121,13 @@ int main(int argc, char *argv[])
120
121
while (argc >= 1 ) {
121
122
opt = 0 ;
122
123
123
- if (!strcmp (argv [0 ], "--disallowed" ) || !strcmp (argv [0 ], "--whole-system" )) {
124
- flags |= HWLOC_TOPOLOGY_FLAG_INCLUDE_DISALLOWED ;
124
+ /* Topology */
125
+ if (!strcmp (argv [0 ], "--no-smt" )) {
126
+ no_smt = 0 ;
127
+ goto next_config ;
128
+ }
129
+ if (!strncmp (argv [0 ], "--no-smt=" , 9 )) {
130
+ no_smt = atoi (argv [0 ] + 9 );
125
131
goto next_config ;
126
132
}
127
133
if (!strcmp (argv [0 ], "--restrict" )) {
@@ -147,12 +153,8 @@ int main(int argc, char *argv[])
147
153
opt = 1 ;
148
154
goto next_config ;
149
155
}
150
- if (!strcmp (argv [0 ], "--no-smt" )) {
151
- no_smt = 0 ;
152
- goto next_config ;
153
- }
154
- if (!strncmp (argv [0 ], "--no-smt=" , 9 )) {
155
- no_smt = atoi (argv [0 ] + 9 );
156
+ if (!strcmp (argv [0 ], "--disallowed" ) || !strcmp (argv [0 ], "--whole-system" )) {
157
+ flags |= HWLOC_TOPOLOGY_FLAG_INCLUDE_DISALLOWED ;
156
158
goto next_config ;
157
159
}
158
160
if (!strcmp (argv [0 ], "--hbm" )) {
@@ -163,15 +165,6 @@ int main(int argc, char *argv[])
163
165
only_hbm = 0 ;
164
166
goto next_config ;
165
167
}
166
- if (!strcmp (argv [0 ], "--best-memattr" )) {
167
- if (argc < 2 ) {
168
- usage (callname , stderr );
169
- exit (EXIT_FAILURE );
170
- }
171
- best_memattr_str = argv [1 ];
172
- opt = 1 ;
173
- goto next_config ;
174
- }
175
168
176
169
break ;
177
170
@@ -213,30 +206,72 @@ int main(int argc, char *argv[])
213
206
opt = 0 ;
214
207
215
208
if (* argv [0 ] == '-' ) {
216
- if (!strcmp (argv [0 ], "-v" ) || !strcmp (argv [0 ], "--verbose" )) {
217
- verbose ++ ;
218
- goto next ;
209
+ /* Options */
210
+ if (!strcmp (argv [0 ], "--cpubind" )) {
211
+ working_on_cpubind = 1 ;
212
+ goto next ;
219
213
}
220
- if (!strcmp ( argv [ 0 ], "-q" ) || ! strcmp (argv [0 ], "--quiet " )) {
221
- verbose -- ;
222
- goto next ;
214
+ if (!strcmp (argv [0 ], "--membind " )) {
215
+ working_on_cpubind = 0 ;
216
+ goto next ;
223
217
}
224
- if (!strcmp (argv [0 ], "-h" ) || !strcmp (argv [0 ], "--help" )) {
225
- usage (callname , stdout );
226
- return EXIT_SUCCESS ;
218
+ if (!strcmp (argv [0 ], "--mempolicy" )) {
219
+ if (!strncmp (argv [1 ], "default" , 2 ))
220
+ membind_policy = HWLOC_MEMBIND_DEFAULT ;
221
+ else if (!strncmp (argv [1 ], "firsttouch" , 2 ))
222
+ membind_policy = HWLOC_MEMBIND_FIRSTTOUCH ;
223
+ else if (!strncmp (argv [1 ], "bind" , 2 ))
224
+ membind_policy = HWLOC_MEMBIND_BIND ;
225
+ else if (!strncmp (argv [1 ], "interleave" , 2 ))
226
+ membind_policy = HWLOC_MEMBIND_INTERLEAVE ;
227
+ else if (!strncmp (argv [1 ], "nexttouch" , 2 ))
228
+ membind_policy = HWLOC_MEMBIND_NEXTTOUCH ;
229
+ else {
230
+ fprintf (stderr , "Unrecognized memory binding policy %s\n" , argv [1 ]);
231
+ usage (callname , stderr );
232
+ exit (EXIT_FAILURE );
233
+ }
234
+ got_mempolicy = 1 ;
235
+ opt = 1 ;
236
+ goto next ;
227
237
}
228
- if (!strcmp (argv [0 ], "--single" )) {
229
- single = 1 ;
230
- goto next ;
238
+ if (!strcmp (argv [0 ], "--best-memattr" )) {
239
+ if (argc < 2 ) {
240
+ usage (callname , stderr );
241
+ exit (EXIT_FAILURE );
242
+ }
243
+ best_memattr_str = argv [1 ];
244
+ opt = 1 ;
245
+ goto next ;
231
246
}
232
- if (!strcmp (argv [0 ], "-f" ) || !strcmp (argv [0 ], "--force" )) {
233
- force = 1 ;
234
- goto next ;
247
+ if (!strcmp (argv [0 ], "-l" ) || !strcmp (argv [0 ], "--logical" )) {
248
+ logical = 1 ;
249
+ goto next ;
250
+ }
251
+ if (!strcmp (argv [0 ], "-p" ) || !strcmp (argv [0 ], "--physical" )) {
252
+ logical = 0 ;
253
+ goto next ;
254
+ }
255
+ if (!strcmp (argv [0 ], "--single" )) {
256
+ single = 1 ;
257
+ goto next ;
235
258
}
236
259
if (!strcmp (argv [0 ], "--strict" )) {
237
- cpubind_flags |= HWLOC_CPUBIND_STRICT ;
238
- membind_flags |= HWLOC_MEMBIND_STRICT ;
239
- goto next ;
260
+ cpubind_flags |= HWLOC_CPUBIND_STRICT ;
261
+ membind_flags |= HWLOC_MEMBIND_STRICT ;
262
+ goto next ;
263
+ }
264
+ if (!strcmp (argv [0 ], "--get" )) {
265
+ get_binding = 1 ;
266
+ goto next ;
267
+ }
268
+ if (!strcmp (argv [0 ], "-e" ) || !strncmp (argv [0 ], "--get-last-cpu-location" , 10 )) {
269
+ get_last_cpu_location = 1 ;
270
+ goto next ;
271
+ }
272
+ if (!strcmp (argv [0 ], "--nodeset" )) {
273
+ use_nodeset = 1 ;
274
+ goto next ;
240
275
}
241
276
if (!strcmp (argv [0 ], "--pid" )) {
242
277
if (argc < 2 ) {
@@ -258,63 +293,33 @@ int main(int argc, char *argv[])
258
293
goto next ;
259
294
}
260
295
#endif
261
- if (!strcmp (argv [0 ], "--version" )) {
262
- printf ("%s %s\n" , callname , HWLOC_VERSION );
263
- exit (EXIT_SUCCESS );
264
- }
265
- if (!strcmp (argv [0 ], "-l" ) || !strcmp (argv [0 ], "--logical" )) {
266
- logical = 1 ;
267
- goto next ;
268
- }
269
- if (!strcmp (argv [0 ], "-p" ) || !strcmp (argv [0 ], "--physical" )) {
270
- logical = 0 ;
271
- goto next ;
272
- }
273
296
if (!strcmp (argv [0 ], "--taskset" )) {
274
297
taskset = 1 ;
275
298
goto next ;
276
299
}
277
- if (!strcmp (argv [0 ], "-e" ) || !strncmp (argv [0 ], "--get-last-cpu-location" , 10 )) {
278
- get_last_cpu_location = 1 ;
279
- goto next ;
280
- }
281
- if (!strcmp (argv [0 ], "--get" )) {
282
- get_binding = 1 ;
283
- goto next ;
300
+ /* Misc */
301
+ if (!strcmp (argv [0 ], "-f" ) || !strcmp (argv [0 ], "--force" )) {
302
+ force = 1 ;
303
+ goto next ;
284
304
}
285
- if (!strcmp (argv [0 ], "--nodeset " )) {
286
- use_nodeset = 1 ;
287
- goto next ;
305
+ if (!strcmp ( argv [ 0 ], "-q" ) || ! strcmp (argv [0 ], "--quiet " )) {
306
+ verbose -- ;
307
+ goto next ;
288
308
}
289
- if (!strcmp (argv [0 ], "--cpubind " )) {
290
- working_on_cpubind = 1 ;
291
- goto next ;
309
+ if (!strcmp ( argv [ 0 ], "-v" ) || ! strcmp (argv [0 ], "--verbose " )) {
310
+ verbose ++ ;
311
+ goto next ;
292
312
}
293
- if (!strcmp (argv [0 ], "--membind " )) {
294
- working_on_cpubind = 0 ;
295
- goto next ;
313
+ if (!strcmp (argv [0 ], "--version " )) {
314
+ printf ( "%s %s\n" , callname , HWLOC_VERSION ) ;
315
+ exit ( EXIT_SUCCESS ) ;
296
316
}
297
- if (!strcmp (argv [0 ], "--mempolicy" )) {
298
- if (!strncmp (argv [1 ], "default" , 2 ))
299
- membind_policy = HWLOC_MEMBIND_DEFAULT ;
300
- else if (!strncmp (argv [1 ], "firsttouch" , 2 ))
301
- membind_policy = HWLOC_MEMBIND_FIRSTTOUCH ;
302
- else if (!strncmp (argv [1 ], "bind" , 2 ))
303
- membind_policy = HWLOC_MEMBIND_BIND ;
304
- else if (!strncmp (argv [1 ], "interleave" , 2 ))
305
- membind_policy = HWLOC_MEMBIND_INTERLEAVE ;
306
- else if (!strncmp (argv [1 ], "nexttouch" , 2 ))
307
- membind_policy = HWLOC_MEMBIND_NEXTTOUCH ;
308
- else {
309
- fprintf (stderr , "Unrecognized memory binding policy %s\n" , argv [1 ]);
310
- usage (callname , stderr );
311
- exit (EXIT_FAILURE );
312
- }
313
- got_mempolicy = 1 ;
314
- opt = 1 ;
315
- goto next ;
317
+ if (!strcmp (argv [0 ], "-h" ) || !strcmp (argv [0 ], "--help" )) {
318
+ usage (callname , stdout );
319
+ return EXIT_SUCCESS ;
316
320
}
317
321
322
+ /* Errors */
318
323
fprintf (stderr , "Unrecognized option: %s\n" , argv [0 ]);
319
324
usage (callname , stderr );
320
325
return EXIT_FAILURE ;
0 commit comments