PDA

View Full Version : control number of cpu's used in a multithreadprogram



monkeyking
May 7th, 2007, 01:31 PM
I'm doing a multithread program, on a system with 4 dual core cpu's.

And I want to check how well it scales.

Is there a way to control the number of cpu's used by a program?

thanks in advance

Quikee
May 7th, 2007, 04:43 PM
I'm doing a multithread program, on a system with 4 dual core cpu's.

And I want to check how well it scales.

Is there a way to control the number of cpu's used by a program?

thanks in advance

Look for package "schedutils" in synaptic - one of the tools is "taskset" for setting CPU affinity for a process.

amo-ej1
May 8th, 2007, 07:18 AM
You might wish to examine man 2 sched_setaffinity:



DESCRIPTION
A processís CPU affinity mask determines the set of CPUs on which it is
eligible to run. On a multiprocessor system, setting the CPU affinity
mask can be used to obtain performance benefits. For example, by dedi‐
cating one CPU to a particular process (i.e., setting the affinity mask
of that process to specify a single CPU, and setting the affinity mask
of all other processes to exclude that CPU), it is possible to ensure
maximum execution speed for that process. Restricting a process to run
on a single CPU also prevents the performance cost caused by the cache
invalidation that occurs when a process ceases to execute on one CPU
and then recommences execution on a different CPU.

monkeyking
May 8th, 2007, 06:11 PM
Thanks I went for the schedutils,
it was excatly want I wanted.

I get the following with the other



man 2 sched_setaffinity
No manual entry for sched_setaffinity in section 2