Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

why openmp is slower?

pt663359
Beginner
618 Views
Hi there,

I am trying some parallelisation using openMP but to my surprize all I get is slower execution times.
See the example below: with openmp is about 4 time slower.

Any ideea what can be helpfull here? Thanks.

!$OMP parallel shared(V,V1,V2) , private(k)
!$OMP do schedule (static)

do k=1,10000000
do i =1,Nmax
! j=OMP_GET_THREAD_NUM()
! print*,j,'i=',i
V (i)=V1(i)*V2(i)
enddo
enddo
!$OMP end do
!$OMP END parallel

!master:~/debug$ ifc -O3 -tpp7 -xW -openmp t1_omp.f90
!time a.out
!real 5m8.800s
!user 19m8.230s
!sys 0m3.000s !with openmp
!
!master:~/debug$ ifc -O3 -tpp7 -xW t1_omp.f90
!time a.out
!
!real 1m59.402s
!user 1m59.160s
!sys 0m0.000s !without openmp
0 Kudos
2 Replies
TimP
Honored Contributor III
618 Views
If your program is so simple, more than embarrassingly parallel, such that the compiler can shortcut your loops, parallelizing it may force it to perform several times as much work.
0 Kudos
pt663359
Beginner
618 Views
OK, thanks for replay, I think your explanation make sense, actually this is what I suspected: In the case of loops like:
do i=1,N
do j=1,M
do few things
do one more thing :)
endo
endo

ifc alone is already doing a very good job and overloading openmp stuff may actually slow down things.
0 Kudos
Reply