Date: Wed, 17 Oct 2007 16:42:04 +0000 From: "B. Estrade" <estrabd@gmail.com> To: freebsd-smp <freebsd-smp@freebsd.org> Subject: multi-threading with gcc43 openmp on dual core Message-ID: <20071017164204.GG76582@bc1.hpc.lsu.edu>
next in thread | raw e-mail | index | archive | help
I am messing around with gcc43's openmp capabilities on an IBM Thinkcentre, which has a dual core Intel vPro. I am running FreeBSD 6.2 with SMP. At this stage in the game I am trying to push around the limits of the systems capabilities, and I was wondering if FreeBSD attempts to offload some of the threads to the 2nd core. I admittedly don't know the chip architecure or how FreeBSD handles man threads in SMP, but I'd like too, which is why I am playing with this. As the number of threads increases, one core seems to be oversubscribed according to top (i.e., wcpu > 100%) yet the system is said to be 50% idle (+/- a few points). The load average also seems to not get much higher than 1.0. While I am happy with the load handling, I am wondering: 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? 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. Here is the code I am using right now: #include <stdio.h> int main (int argc, char *argv[]) { int i,j,k,m,n; int MAX=500; n=omp_get_max_threads(); for (m=1;m<=n;m++) { k=0; omp_set_num_threads(m); #pragma omp parallel private(i,j) shared(MAX) reduction(+:k) { for (i=0;i<MAX;i++) { for (j=0;j<MAX;j++) { k = j+i; } #pragma omp barrier } } printf("%8d threads: %d\n",m,k); } return 0; } It is compiled and executed with the following command: % gcc43 -fopenmp test.c && export OMP_NUM_THREADS=1500 && ./a.out Any thoughts? Once I get familiar with what 6.x is doing, I plan on putting 7.0 on this system to see how it compares. Ultimately, I'd like to a straightforward code I can use to evaluate how a particular SMP system running FreeBSD scales. I know it is not a "real" workload, but it would give /me some information that I'd find useful. TIA && Cheers, Brett -- HPC Enablement Group Louisiana Optical Network Initiative http://www.loni.org 225-578-1920
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071017164204.GG76582>