HWLOC-PS(1)
π
HWLOC-PS(1) β the hwloc manual, bestie edition β¨
okay so you found the page for hwloc-ps, part of the hwloc manual set β congrats, you're about to know exactly which processes are pinned to what. let's go π
πΈ NAME πΈ
hwloc-ps β lists all the currently-running processes or threads that are bound, iykyk. that's literally the whole job π
β SYNOPSIS β
hwloc-ps [options]
π¦ OPTIONS π¦
-aβ show everything, even the processes that aren't bound to any particular part of the machine. no filter, no gatekeeping π--pid <pid>β only show the process with PID <pid>, even if it's not bound to anything specific. just that one. main character only π--children-of-pid <pid>β show the process with PID <pid> and its whole hierarchy of children, even if they're not bound to any specific part of the machine. family tree slay π--name <name>β only show processes whose name contains <name>, even if they're not bound to any specific part of the machine. β οΈ heads up: this is not supported on all operating systems, so vibe-check your OS first.--uid <uid>β only show processes belonging to the user whose UID is <uid>, or processes of all users ifallis given. by default only the current user's processes are displayed. π§ this is currently only supported on Linux.-p,--physicalβ report OS/physical indexes instead of logical indexes.-l,--logicalβ report logical indexes instead of physical/OS indexes. this is the default, so if you do nothing you're already here π«Ά-c,--cpusetβ show process bindings as cpusets instead of objects.-t,--threadsβ show threads inside processes. if-ais also given, list all threads within each process. otherwise, show all threads inside each process where at least one thread is bound. π§ this is currently only supported on Linux.--single-ancestorβ when the object is bound to different objects, report their common ancestor instead (even if that ancestor may be larger than the actual binding). lowkey a glow-up for readability β¨-e,--get-last-cpu-locationβ report the last processors where the process/thread ran. π big caveat: the result may already be outdated by the time you see it, because the operating system can move tasks to other processors at any time according to the binding. it's giving racing conditions.--disallowedβ include objects disallowed by administrative limitations.--pid-cmd <cmd>β append the output of the given command to each PID line. for each displayed process ID, it executes<cmd> <pid>and appends the first line of its output to the regularhwloc-psline. π«Ά--pid-cmd env=<name>β on Linux, try to read the value of the environment variable name in each process and display it at the end of the line. π§--pid-cmd mpirankβ on Linux, try to find the process's MPI rank (by querying some widespread environment variables) and display it at the end of the line. π§--lstopo-misc <file>β output a file that may be given tolstopo --misc-fromfor displaying processes/threads as Misc objects. peep the EXAMPLES below π--json-serverβ run the tool as a JSON server that waits for other processes' requests on a port and sends back binding information. seecontrib/hwloc-ps.www/for the deets π--json-port <port>β use the given port number instead of the default8888. π-v,--verboseβ increase verbosity of the JSON server. chatty queen π¬--short-nameβ show only the process short name instead of the path. concise icon π--versionβ report version and exit.-h,--helpβ display help message and exit.
π DESCRIPTION π
by default, hwloc-ps lists only those currently-running processes that are bound. if -t is given, processes that aren't bound but contain at least one bound thread are also displayed β plus all their threads. no cap, that's the whole filter logic π§
hwloc-ps displays the process identifier, the command-line, and the binding. the binding may be reported as objects or as cpusets.
by default, process bindings are restricted to the currently available topology. so if some processes are bound to processors that are not available to the current process, they get ignored β unless you pass --disallowed. π
the output is a plain list. if you actually want to annotate the hierarchical topology with processes so you can see how they're really distributed on the machine, you might wanna use lstopo --ps instead (which also only shows processes that are bound). different tool, different vibe π¦
and the -a switch can be used to show all processes, if that's what you're into. go off π
π₯ EXAMPLES π₯
if a process is bound, it shows up in the default output:
$ hwloc-ps
4759 Core:0 myprogram
if a process is bound on two cores of a larger package, the output shows those cores. but --single-ancestor will instead return the package β even if it's actually larger than the binding here (the process is not bound to Core:0 of Package:0):
$ hwloc-ps
4863 Core:1 Core:2 myprogram
$ hwloc-ps --single-ancestor
4863 Package:0 myprogram
if a process is not bound but 3 of its 4 threads are bound, it only appears in the thread-aware output (or if it's explicitly selected):
$ hwloc-ps
$ hwloc-ps -t
4759 Machine:0 myprogram
4759 Machine:0
4761 PU:0
4762 PU:2
4765 PU:1
$ hwloc-ps --pid 4759
4759 Machine:0 myprogram
π Example with lstopo integration
the output may be a file that lstopo uses for adding Misc objects (a more flexible version of lstopo --top):
$ hwloc-ps --misc-from foo
$ cat foo
name=12444 myprogram
cpuset=0x000000f0
subtype=Process
name=12444 mythread1
cpuset=0x00000050
subtype=Thread
name=12444 mythread2
cpuset=0x000000a0
subtype=Thread
and this may be directly given to lstopo:
$ hwloc-ps --misc-from - | lstopo --misc-from -
π Examples with MPI processes
on Linux, hwloc-ps may also display some process-specific environment variable at the end of the line. this is, for instance, useful for identifying MPI ranks among processes:
$ hwloc-ps --pid-cmd env=OMPI_COMM_WORLD_RANK
29093 PU:0 myprogram OMPI_COMM_WORLD_RANK=0
29094 PU:2 myprogram OMPI_COMM_WORLD_RANK=1
29095 PU:1 myprogram OMPI_COMM_WORLD_RANK=2
29096 PU:3 myprogram OMPI_COMM_WORLD_RANK=3
some widespread MPI-specific environment variables (OMPI_COMM_WORLD_RANK, PMIX_RANK, PMI_RANK and SLURM_PROCID) are actually directly recognized by hwloc-ps when you request the mpirank command:
$ hwloc-ps --pid-cmd mpirank
29093 PU:0 myprogram PMIX_RANK=0
29094 PU:2 myprogram PMIX_RANK=1
29095 PU:1 myprogram PMIX_RANK=2
29096 PU:3 myprogram PMIX_RANK=3
besides reading environment variables, hwloc-ps may also append the output of a custom program. again, for reading the Open MPI process rank:
$ hwloc-ps --pid-cmd myscript
29093 PU:0 myprogram OMPI_COMM_WORLD_RANK=0
29094 PU:2 myprogram OMPI_COMM_WORLD_RANK=1
29095 PU:1 myprogram OMPI_COMM_WORLD_RANK=2
29096 PU:3 myprogram OMPI_COMM_WORLD_RANK=3
where myscript is a shell script doing:
#!/bin/sh
cat /proc/$1/environ 2>/dev/null | xargs --null --max-args=1 echo |
grep OMPI_COMM_WORLD_RANK
π SEE ALSO π
hwloc(7), lstopo(1), hwloc-calc(1), hwloc-distrib(1), and hwloc-ps.www/README β go read them, they're iconic too π
anyway that's the whole page, bestie. this edition was brought to you by 2.15.0, dated Sep 23, 2026 β mwah, go pin some processes π
β¨π
π¦ where this page comes from
- arch rolling: hwloc 2.15.0-1 Β· BSD-3-Clause
- π the page's license: BSD-3-Clause
- Copyright Β© 2010-2024 Inria. All rights reserved
- Copyright Β© 2009-2010 Cisco Systems, Inc. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms