Can anyone recommend a nice “processor affinity” applet? I’ve been looking around but can’t seem to find anything. Windows Task Manager let’s me right-click and nail MPI threads to specific processors
I only know of the CLI tool taskset.
Using Taskset for Priority Tasks
How to Assign a Process to a Certain CPU Core in Ubuntu Linux
is conky the answer
Thank you, Deano
I came across the taskset command in the util-linux package. I’m not exactly sure how to use it, but I’m reading up… There are so many capabilities at the command line in linux that we KDE folks just don’t know about.
I think OpenMPI may use the taskset command because when invoking mpirun you can tell it to assign threads by-processor or by-CPU
I know conky can monitor stuff - but I don’t think it can pre-assign or reassign threads.
taskset is super simple for it’s basic usage. i just discovered it last night as i had to use it to keep HandBrake from locking up the computer. had to limit it to 4 cpus.
>taskset -c cpu p**rocess
>taskset -pc cpu pid
cpu starts at 0(zero). you can assign a list instead of a single cpu:
>taskset -c 0-3 someprocess
**you can also use strides(every nth cpu):
>taskset -c 0-15:2 someotherprocess (assigns to 0,2,4,6,8,10,12,14)
There is also the whole package (it does it all) with schedtool. I usually symlink it from /usr/sbin/schedtool to /usr/bin/schedtool. Example run handbrake only on cpu 1:
schedtool -a 0 -e ghb
Rather than limiting to cores you are probably better off just using nice to reduce task priority.
I’ve used htop for this. Displays which processor the app/Pid is running on, allows you to set.
Nice/re-nice is an alternative but depends on the situation.
Running a major app on hardware with multiple cores, it can be useful to assign the that app to a particular core so that it can nearly reserve its use for itself. Note that this is a “hard setting” where the app will also be restricted from using any other cores thereby not stepping on other tasks.
Re-nice/nice on the other hand will use the regular scheduler to allocate CPU resources from all cores, and not restricted by any hard settings. There is only a general priority in relation to other running processes.
Note that now systemd provides alternatives to nice/re-nice. I get a headache keeping nice and re-nice info straight (among which direction is higher priority?). And, nice supports only Pids, no names while re-nice supports both. With systemd you only have to declare a non-default priority in the Unit config file.
Thank you for the replies! These look pretty useful. I’ll read up on them, but thanks for the demo code too!