two threads take twice as long

General OpenMP discussion

two threads take twice as long

Postby danieleinst » Wed Oct 05, 2011 4:27 pm

Hi,

I am new to openMP and have been working to parallelize a FORTRAN code I wrote to map 3D image data to unstructured meshes. After some effort, I managed to get the do loop I am focused on to produce the correct results independent of the OMP_NUM_THREADS. The trouble now is that the code takes twice as long with 2 threads, 4 times as long with four and so on. Not only that, all of the other sections of the code outside of the parallel section also take longer by roughly the same factor. I am using PGFortran 6.2 and my compilation is like this:

pgf95 -c -O2 -mp=nonuma code1.c code2.f90 code3.f90 code4.f90

The section of code in question is something like this:

do a bunch of stuff outside the parallel section

!$OMP PARALLEL DEFAULT(PRIVATE) SHARED(sharedvar_1 .....)
!$OMP DO PRIVATE(privatevar_1 ...)

do i=1:10000000

! do somethings in here and call some subroutines

enddo
!$OMP END DO
!$OMP END PARALLEL

do a bunch of stuff outside the parallel section



This is probably a pretty newbie question but I would be grateful for any help.

Dan
danieleinst
 
Posts: 2
Joined: Wed Oct 05, 2011 4:12 pm

Re: two threads take twice as long

Postby ftinetti » Thu Oct 06, 2011 3:32 am

Hi,

How are you measuring runtime? I suggest using OMP_GET_WTIME()
ftinetti
 
Posts: 558
Joined: Wed Feb 10, 2010 2:44 pm

Re: two threads take twice as long

Postby danieleinst » Thu Oct 06, 2011 9:23 am

Hi,

Thanks. using omp_get_wtime eliminates the mysterious apparent slowing down of those sections of the code untouched by omp directives. Now I just need to focus on those parts that I am attempting to speed up - which is exactly where I want to be. Many thanks

Dan
danieleinst
 
Posts: 2
Joined: Wed Oct 05, 2011 4:12 pm


Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 10 guests