hwloc 13 KB

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