multi-threading with gcc43 openmp on dual core

B. Estrade estrabd at gmail.com
Wed Oct 17 11:05:09 PDT 2007


On Wed, Oct 17, 2007 at 07:31:05PM +0200, Kris Kennaway wrote:
> B. Estrade wrote:
snip
> >1. why are threads not evenly distributed b/w CPU0 and CPU1
> >2. is there a way to explicitly facilitate this thread balancing (don't 
> >know if this is related to CPU affinity)
> >3. what is a good way to push the system? 
snip
> >The program I am running spawns an increasing number of threads from 1 to 
> >OMP_NUM_THREADS, where each thread has its own loop that simply assigns 
> >the sum of j and i to k. My OpenMP-foo is not advanced, but it's steadily 
> >getting there. 
snip
> >Brett
> >
> 
> FreeBSD uses all CPUs for running processes and threads.  This relies on 
> your program being sufficiently parallel though.  I don't know enough 
> about openmp but maybe it is not able to parallelize your workload very 
> well.

Thanks, Kris.  This is what I am trying to determine. After some more observations, it seems as if there is some swapping of duties between CPU0 and CPU1 - but only one of them has the entire set of threads at any one point in time, while the other is idle.  I am execeuting a code that uses only explicitly declared private variables, and this includes taking out the reduction shown in the code above from my original email. It should be obvious to the compiler and OS that these threads are not dependent on each other in any way. 

I am going to look deeper into this - but I am still very interested in anything that anyone wants to say.  I think my question can be best summed up as: how does one make it obvious to FreeBSD that all threads should be shared among all CPUs equally? I don't think this is an OpenMP specific question - I am just using it as a way to generate the threading...is it unreasonable of me to expect that all threads should be shared by all CPUs?

Thanks,
Brett

> 
> Kris

-- 
HPC Enablement Group
Louisiana Optical Network Initiative
http://www.loni.org
225-578-1920



More information about the freebsd-smp mailing list