• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Any way to assign CPU affinity when executing a program?

slugg

Diamond Member
Let's say I have a program that I have a program that eats through CPU cycles for a long time (something like 5 hours). How would I guarantee that 8 instances are running on 8 unique cores?
 
AFAIK, Windows does that automatically so well that it isn't worth worrying about.

EDIT: Sry, just realized this was in *nix.
 
use taskset

you can get usage info with 'man taskset'
you could probably even combine it with 'nice' to make sure the program takes over the cpu completely, just be sure you leave one cpu core for the system to use.

so maybe something like this "sudo taskset -c N nice -n -20 myprogram' where N is the cpu core you want this instance of the program to run on. Also, you have to use sudo to use nice with higher priorities.
 
Originally posted by: Brazen
use taskset

you can get usage info with 'man taskset'
you could probably even combine it with 'nice' to make sure the program takes over the cpu completely, just be sure you leave one cpu core for the system to use.

so maybe something like this "sudo taskset -c N nice -n -20 myprogram' where N is the cpu core you want this instance of the program to run on. Also, you have to use sudo to use nice with higher priorities.

That did the trick!

I'm running 7 threads with 1 core available for general use. I didn't use nice, but that wasn't really needed. 7 threads per node is fine for my needs (4 nodes, 32 cores). I'd say 28 3.6 ghz Xeon's at 100% load is enough throughput for now 😛
 
That's generally a bad idea because the kernel is smart enough to leave long running processes on the same CPU and to balance CPU hogs across available cores but now the Linux kernel has it's hands tied in how it can manage the available CPUs.
 
Back
Top