|
[Sponsors] |
September 28, 2011, 12:52 |
OpenMP
|
#1 |
New Member
Join Date: Sep 2011
Posts: 2
Rep Power: 0 |
Hi,
Here is an OpenMP implementation of a Laplace solver (a parallel Fortran code). I can get a good speedup on up to 4 processors, but it does not improve when I use more processors. Could you please let me know how I can get a better speedup by using more processors? program lpomp integer imax,jmax,im1,im2,jm1,jm2,it,itmax parameter (imax=4001,jmax=4001) parameter (im1=imax-1,im2=imax-2,jm1=jmax-1,jm2=jmax-2) parameter (itmax=200) real*8 u(imax,jmax),du(imax,jmax),umax,dumax,tol parameter (umax=10.0,tol=1.0e-6) call omp_set_num_threads(2) !$OMP PARALLEL DEFAULT(SHARED) PRIVATE(i,j) !$OMP DO do j=1,jmax do i=1,imax-1 u(i,j)=0.0 du(i,j)=0.0 enddo u(imax,j)=umax enddo !$OMP END DO !$OMP END PARALLEL it=1 dumax=1.0 !$OMP PARALLEL DEFAULT(SHARED) PRIVATE(i,j) ! Main computation loop do it=1,itmax dumax=0.0 !$OMP DO REDUCTION (max:dumax) do j=2,jm1 do i=2,im1 du(i,j)=0.25*(u(i-1,j)+u(i+1,j)+u(i,j-1)+u(i,j+1))-u(i,j) dumax=max(dumax,abs(du(i,j))) enddo enddo !$OMP END DO !$OMP DO do j=2,jm1 do i=2,im1 u(i,j)=u(i,j)+du(i,j) enddo enddo !$OMP END DO enddo !$OMP END PARALLEL stop end Compile: ifort -openmp -parallel Laplace.for Thanks! |
|
September 30, 2011, 17:58 |
|
#2 |
Senior Member
Join Date: Nov 2009
Posts: 411
Rep Power: 20 |
Comment (or erase) this line:
call omp_set_num_threads(2) recompile your code and let me know if you see any improvement. You could also try to enable all optimizations by using for compilation: ifort -O3 -openmp -parallel Laplace.for Do |
|
September 30, 2011, 19:46 |
|
#3 |
New Member
Join Date: Sep 2011
Posts: 2
Rep Power: 0 |
Hi,
I commented the line, but did not see any improvement. Thanks! |
|
September 30, 2011, 21:05 |
|
#4 |
New Member
G.Y.Liang
Join Date: Jan 2011
Posts: 2
Rep Power: 0 |
I can get a good speedup on up to 4 processors, but it does not improve when I use more processors.
Usually I use ifort -fast /Qopenmp filename.f90. I don't know why ifort -fast -openmp cann't be used on my computer(Windows serve OS) For fixed grids, of course, the performance will be slow down if you use more processors. You can fix you processors first, then increase grids to test the speedup. |
|
September 30, 2011, 21:54 |
|
#5 |
Senior Member
Cean
Join Date: Feb 2010
Posts: 128
Rep Power: 16 |
I can compile it with:
gfortran -fopenmp laplace.f90 but when I run it, there is error. Don't kow why? Thx |
|
May 3, 2013, 02:00 |
|
#6 |
Member
Ravindra Shende
Join Date: Feb 2011
Location: Pune, India
Posts: 45
Rep Power: 15 |
Why are you using du(i,j) while you can directly do u(i,j) = 0.25*(u(i-,j)+u(i+1,j)+u(i,j-1)+u(i,j+1)). This will increase the speed of serial code itself.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to parallelize this fortran code by openmp | ronac | Main CFD Forum | 1 | May 11, 2016 03:12 |
OpenMP in Junction Box Routine | Hannes_Kiel | CFX | 10 | September 21, 2010 14:51 |
About the OpenMP | jinwon park | Main CFD Forum | 5 | August 28, 2007 06:47 |
OpenMP and fortran | John Deas | Main CFD Forum | 0 | May 17, 2007 17:53 |
Parallel computing and OpenMP | ganesh | Main CFD Forum | 7 | October 27, 2006 11:15 |