/
hwloc-completion.bash
497 lines (459 loc) · 11.9 KB
/
hwloc-completion.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
#
# Copyright © 2018-2020 Inria. All rights reserved.
# See COPYING in top-level directory.
#
# This file is also compatible with zsh (once bashcompinit is enabled)
# bash < 4 doesn't support compopt
[[ -z "$ZSH_VERSION" ]] && [[ "${BASH_VERSINFO[0]:-0}" -lt 4 ]] && return
# TODO only disable the nospace completion of "--filter"
_lstopo() {
local INPUT_FORMAT=(xml synthetic fsroot cpuid)
local OUTPUT_FORMAT=(console ascii fig pdf ps png svg xml synthetic)
local TYPES=("Machine" "Misc" "Group" "NUMANode" "MemCache" "Package" "Die" "L1" "L2" "L3" "L4" "L5" "L1i" "L2i" "L3i" "Core" "Bridge" "PCIDev" "OSDev" "PU")
local FILTERKINDS=("none" "all" "structure" "important")
local OPTIONS=(-l --logical
-p --physical
--output-format --of
-f --force
--only
-v --verbose
-s --silent
--distances
-c --cpuset
-C --cpuset-only
--taskset
--filter --ignore
--no-caches
--no-useless-caches
--no-icaches
--merge
--no-collapse
--factorize --factorize=
--no-factorize --no-factorize=
--restrict
--restrict-flags
--no-io
--no-bridges
--whole-io
--input -i
--input-format --if
--no-smt
--thissystem
--pid
--disallowed --whole-system
--allow
--flags
--children-order
--fontsize
--gridsize
--linespacing
--horiz --horiz=
--vert --vert=
--rect --rect=
--text --text=
--no-text --no-text=
--index --index=
--no-index --no-index=
--attrs --attrs=
--no-attrs --no-attrs=
--no-legend
--append-legend
--binding-color
--disallowed-color
--top-color
--export-xml-flags
--export-synthetic-flags
--ps --top
--version
-h --help
)
local cur=${COMP_WORDS[COMP_CWORD]}
local prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ $COMP_CWORD == 1 || $cur == -* ]] ; then
COMPREPLY=( `compgen -W "${OPTIONS[*]}" -- "$cur"` )
elif [[ $COMP_CWORD -ge 3 && "${COMP_WORDS[COMP_CWORD-2]}" == "--filter" && "$cur" == ":" ]] ; then
COMPREPLY=( `compgen -W "${FILTERKINDS[*]}"` )
elif [[ $COMP_CWORD -ge 4 && "${COMP_WORDS[COMP_CWORD-3]}" == "--filter" && "$prev" == ":" ]] ; then
COMPREPLY=( `compgen -W "${FILTERKINDS[*]}" -- "$cur"` )
elif [[ "$cur" == "=" && " --horiz --vert --rect --text --no-text --index --no-index --attrs --no-attrs --no-factorize " =~ " $prev " ]] ; then
COMPREPLY=( `compgen -W "${TYPES[*]}"` )
# we could also support "<type1>,<type2>,..." for --index/attrs/text but "," is not a completion word separator
elif [[ $COMP_CWORD -ge 3 && "$prev" == "=" && " --horiz --vert --rect --text --no-text --index --no-index --attrs --no-attrs --no-factorize --factorize " =~ " ${COMP_WORDS[COMP_CWORD-2]} " ]] ; then
COMPREPLY=( `compgen -W "${TYPES[*]}" -- "$cur"` )
elif [[ "$cur" == "=" && "--factorize" = "$prev" ]] ; then
COMPREPLY=( `compgen -W "${TYPES[*]}"` "<N>" "<N,F,L>" )
else
case "$prev" in
--of | --output-format)
COMPREPLY=( `compgen -W "${OUTPUT_FORMAT[*]}" -- "$cur"` )
;;
--only | --ignore)
COMPREPLY=( `compgen -W "${TYPES[*]}" -- "$cur"` )
;;
--filter)
COMPREPLY=( `compgen -W "${TYPES[*]/%/:} cache: icache: io:" -- "$cur"` ) && compopt -o nospace
;;
--restrict)
COMPREPLY=( `compgen -W "binding <cpuset>" -- "$cur"` )
;;
-i | --input)
_filedir xml
;;
--if | --input-format)
COMPREPLY=( `compgen -W "${INPUT_FORMAT[*]}" -- "$cur"` )
;;
--pid)
COMPREPLY=( "<pid>" "" )
;;
--allow)
COMPREPLY=( `compgen -W "all local <mask> nodeset=<mask>" -- "$cur"` )
;;
--restrict-flags | --export-xml-flags | --export-synthetic-flags | --fontsize | --gridsize | --linespacing)
COMPREPLY=( "<integer>" "" )
;;
--append-legend)
COMPREPLY=( "<line of text>" "" )
;;
--binding-color | --disallowed-color)
COMPREPLY=( `compgen -W "none" -- "$cur"` )
;;
--top-color)
COMPREPLY=( `compgen -W "none <#xxyyzz>" -- "$cur"` )
;;
--children-order)
COMPREPLY=( `compgen -W "plain memoryabove" -- "$cur"` )
;;
esac
fi
}
complete -F _lstopo lstopo
complete -F _lstopo lstopo-no-graphics
complete -F _lstopo hwloc-ls
_hwloc_info(){
local TYPES=("Machine" "Misc" "Group" "NUMANode" "MemCache" "Package" "Die" "L1" "L2" "L3" "L4" "L5" "L1i" "L2i" "L3i" "Core" "Bridge" "PCIDev" "OSDev" "PU")
local FILTERKINDS=("none" "all" "structure" "important")
local OPTIONS=(--objects
--topology
--support
-v --verbose
-s --silent
--ancestors
--ancestor
--children
--descendants
-n
--restrict
--filter
--no-icaches
--no-io
--no-bridges
--whole-io
--input -i
--input-format --if
--thissystem
--pid
--disallowed --whole-system
-l --logical
-p --physical
--version
-h --help
)
local cur=${COMP_WORDS[COMP_CWORD]}
local prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ $COMP_CWORD == 1 || $cur == -* ]] ; then
COMPREPLY=( `compgen -W "${OPTIONS[*]}" -- "$cur"` )
elif [[ $COMP_CWORD -ge 3 && "${COMP_WORDS[COMP_CWORD-2]}" == "--filter" && "$cur" == ":" ]] ; then
COMPREPLY=( `compgen -W "${FILTERKINDS[*]}"` )
elif [[ $COMP_CWORD -ge 4 && "${COMP_WORDS[COMP_CWORD-3]}" == "--filter" && "$prev" == ":" ]] ; then
COMPREPLY=( `compgen -W "${FILTERKINDS[*]}" -- "$cur"` )
else
case "$prev" in
--restrict)
COMPREPLY=( `compgen -W "binding <cpuset>" -- "$cur"` )
;;
-i | --input)
_filedir xml
;;
--if | --input-format)
COMPREPLY=( `compgen -W "${INPUT_FORMAT[*]}" -- "$cur"` )
;;
--pid)
COMPREPLY=( "<pid>" "" )
;;
--filter)
COMPREPLY=( `compgen -W "${TYPES[*]/%/:} cache: icache: io:" -- "$cur"` ) && compopt -o nospace
;;
--ancestor | --descendants)
COMPREPLY=( `compgen -W "${TYPES[*]}" -- "$cur"` )
;;
esac
fi
}
complete -F _hwloc_info hwloc-info
_hwloc_bind(){
local OPTIONS=(--cpubind
--membind
--mempolicy
--logical -l
--physical -p
--single
--strict
--get
-e --get-last-cpu-location
--nodeset
--pid
--tid
--taskset
--restrict
--disallowed --whole-system
--hbm
--no-hbm
--no-smt --no-smt=N
-f --force
-q --quiet
-v --verbose
--version
-h --help
)
local cur=${COMP_WORDS[COMP_CWORD]}
local prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ $COMP_CWORD == 1 || $cur == -* ]] ; then
COMPREPLY=( `compgen -W "${OPTIONS[*]}" -- "$cur"` )
else
case "$prev" in
--mempolicy)
COMPREPLY=( `compgen -W "default firsttouch bind interleave nexttouch" -- "$cur"` )
;;
--pid)
COMPREPLY=( "<pid>" "" )
;;
--tid)
COMPREPLY=( "<tid>" "" )
;;
--restrict)
COMPREPLY=( "<bitmask>" "" )
;;
esac
fi
}
complete -F _hwloc_bind hwloc-bind
_hwloc_calc(){
local TYPES=("Machine" "Misc" "Group" "NUMANode" "MemCache" "Package" "Die" "L1" "L2" "L3" "L4" "L5" "L1i" "L2i" "L3i" "Core" "Bridge" "PCIDev" "OSDev" "PU")
local OPTIONS=(-N --number-of
-I --intersect
-H --hierarchical
--largest
-l --logical
-p --physical
--li --logical-input
--lo --logical-output
--pi --physical-input
--po --physical-output
-n --nodeset
--ni --nodeset-input
--no --nodeset-output
--sep
--taskset
--single
--restrict
--disallowed --whole-system
--input -i
--input-format --if
--no-smt --no-smt=N
-q --quiet
-v --verbose
--version
-h --help
)
local cur=${COMP_WORDS[COMP_CWORD]}
local prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ $COMP_CWORD == 1 || $cur == -* ]] ; then
COMPREPLY=( `compgen -W "${OPTIONS[*]}" -- "$cur"` )
else
case "$prev" in
-N | --number-of | -I | --intersect)
COMPREPLY=( `compgen -W "${TYPES[*]}" -- "$cur"` )
;;
-H | --hierarchical)
COMPREPLY=( "<type1>.<type2>..." "" )
;;
--sep)
COMPREPLY=( "<separator>" "" )
;;
-i | --input)
_filedir xml
;;
--if | --input-format)
COMPREPLY=( `compgen -W "${INPUT_FORMAT[*]}" -- "$cur"` )
;;
--restrict)
COMPREPLY=( "<bitmask>" "" )
;;
esac
fi
}
complete -F _hwloc_calc hwloc-calc
_hwloc_annotate(){
local OPTIONS=(--ci --ri --cu --cd -h --help)
local cur=${COMP_WORDS[COMP_CWORD]}
if [[ $COMP_CWORD == 1 || $cur == -* ]] ; then
COMPREPLY=( `compgen -W "${OPTIONS[*]}" -- "$cur"`)
fi
_filedir xml
}
complete -F _hwloc_annotate hwloc-annotate
_hwloc_diff(){
local OPTIONS=(--refname
--version
-h --help
)
local cur=${COMP_WORDS[COMP_CWORD]}
local prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ $COMP_CWORD == 1 || $cur == -* ]] ; then
COMPREPLY=( `compgen -W "${OPTIONS[*]}" -- "$cur"` )
else
case "$prev" in
--refname)
COMPREPLY=( "<reference topology identifier>" "")
;;
esac
fi
_filedir xml
}
complete -F _hwloc_diff hwloc-diff
_hwloc_patch(){
local OPTIONS=(--R --reverse
--version
-h --help
)
local cur=${COMP_WORDS[COMP_CWORD]}
if [[ $COMP_CWORD == 1 || $cur == -* ]] ; then
COMPREPLY=( `compgen -W "${OPTIONS[*]}" -- "$cur"` )
fi
_filedir xml
}
complete -F _hwloc_patch hwloc-patch
_hwloc_compress_dir(){
local OPTIONS=(-R --reverse
-v --verbose
-h --help
)
local cur=${COMP_WORDS[COMP_CWORD]}
if [[ $COMP_CWORD == 1 || $cur == -* ]] ; then
COMPREPLY=( `compgen -W "${OPTIONS[*]}" -- "$cur"` )
fi
_filedir -d
}
complete -F _hwloc_compress_dir hwloc-compress-dir
_hwloc_distrib(){
local TYPES=("Machine" "Misc" "Group" "NUMANode" "MemCache" "Package" "Die" "L1" "L2" "L3" "L4" "L5" "L1i" "L2i" "L3i" "Core" "Bridge" "PCIDev" "OSDev" "PU")
local OPTIONS=(--ignore
--from
--to
--at
--reverse
--restrict
--disallowed --whole-system
--input -i
--input-format --if
--single
--taskset
-v --verbose
--version
-h --help
)
local cur=${COMP_WORDS[COMP_CWORD]}
local prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ $COMP_CWORD == 1 || $cur == -* ]] ; then
COMPREPLY=( `compgen -W "${OPTIONS[*]}" -- "$cur"` )
else
case "$prev" in
--ignore | --from | --to | --at)
COMPREPLY=( `compgen -W "${TYPES[*]}" -- "$cur"` )
;;
-i | --input)
_filedir xml
;;
--if | --input-format)
COMPREPLY=( `compgen -W "${INPUT_FORMAT[*]}" -- "$cur"` )
;;
--restrict)
COMPREPLY=( "<bitmask>" "" )
;;
esac
fi
}
complete -F _hwloc_distrib hwloc-distrib
_hwloc_ps(){
local OPTIONS=(-a
--pid
--name
-l --logical
-p --physical
-c --cpuset
-t --threads
-e --get-last-cpu-location
--pid-cmd
--uid
--disallowed --whole-system
--json-server
--json-port
-v --verbose
-h --help
)
local cur=${COMP_WORDS[COMP_CWORD]}
local prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ $COMP_CWORD == 1 || $cur == -* ]] ; then
COMPREPLY=( `compgen -W "${OPTIONS[*]}" -- "$cur"` )
else
case "$prev" in
--name)
COMPREPLY=( "<task name>" "" )
;;
--uid)
COMPREPLY=( "<uid>" "all" "" )
;;
--pid)
COMPREPLY=( "<pid>" "" )
;;
--pid-cmd)
_filedir
;;
--json-port)
COMPREPLY=( "<port>" "" )
;;
esac
fi
}
complete -F _hwloc_ps hwloc-ps
_hwloc_gather_cpuid(){
local OPTIONS=(-c
-s --silent
-h --help
)
local cur=${COMP_WORDS[COMP_CWORD]}
local prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ $COMP_CWORD == 1 || $cur == -* ]] ; then
COMPREPLY=( `compgen -W "${OPTIONS[*]}" -- "$cur"` )
else
case "$prev" in
-c)
COMPREPLY=( "<index of cpu to operate on>" "" )
;;
esac
fi
}
complete -F _hwloc_gather_cpuid hwloc-gather-cpuid
_hwloc_gather_topology(){
local OPTIONS=(--io
--dmi
--no-cpuid
--keep
-h --help
)
local cur=${COMP_WORDS[COMP_CWORD]}
if [[ $COMP_CWORD == 1 || $cur == -* ]] ; then
COMPREPLY=( `compgen -W "${OPTIONS[*]}" -- "$cur"` )
fi
}
complete -F _hwloc_gather_topology hwloc-gather-topology