[Omp] openMP threads not starting simultaneously

Chandan Basu cbasu at rediffmail.com
Thu Oct 18 03:25:58 PDT 2007


Hi Bernd,

I have tried to replace rand with 1 but same problem persists. The threads are not running parallely.

thanks

Chandan
  


On Thu, 18 Oct 2007 Bernd Dammann wrote :
>Hi Chandan,
>
> >    Please help me with a question related to openMP parallelization. I am
> >    running the following code on a 8 core intel clovertown machine. The
> >    code is compiled by intel c compiler, icc, with -openmp option. The
> >    code compiles and runs without trouble. It also creates 8 openmp
> >    threads as set in the program. But If I look at the processor
> >    utilization (by using top command) it shows that only one core is
> >    being used. Timing wise also the 8 thread case is taking more time
> >    than one thread case. It seems threads are running sequentially. Can
> >    any one explain if there is a bug in the code :
>
>My guess is, that your problem is in fun1():
>
> >      for(i=0; i< MAX; i++)
> >           for(col = 0; col < 200; col++)
> >                cnt += rand();
>
>The call to rand() with many threads probably causes some locking
>mechanism to set in (if rand() is thread-safe).  Try to replace rand()
>with 1 - and see if the code behaves as you expect.
>
>Regards,
>Bernd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://openmp.org/pipermail/omp/attachments/20071018/56360b92/attachment.html 


More information about the Omp mailing list