Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Oct 2007 20:34:07 +0200
From:      Kris Kennaway <kris@FreeBSD.org>
To:        "B. Estrade" <estrabd@gmail.com>
Cc:        freebsd-smp <freebsd-smp@freebsd.org>
Subject:   Re: multi-threading with gcc43 openmp on dual core
Message-ID:  <4716559F.9030908@FreeBSD.org>
In-Reply-To: <20071017180140.GI76582@bc1.hpc.lsu.edu>
References:  <20071017164204.GG76582@bc1.hpc.lsu.edu> <471646D9.5090508@FreeBSD.org> <20071017180140.GI76582@bc1.hpc.lsu.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
B. Estrade wrote:
> 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?

I dunno if there is something special you have to do with OpenMP, with 
pthreads there is nothing special one needs to do, apart from making 
sure your code is such that multiple threads can actually run at once 
(i.e. they are not blocking each other for shared resources).

Kris

P.S. Please wrap your lines, it makes your emails hard to read.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4716559F.9030908>