CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

OpenMP

Register Blogs Community New Posts Updated Threads Search

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   September 28, 2011, 11:52
Default OpenMP
  #1
maz
New Member
 
Join Date: Sep 2011
Posts: 2
Rep Power: 0
maz is on a distinguished road
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!
maz is offline   Reply With Quote

 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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 02:12
OpenMP in Junction Box Routine Hannes_Kiel CFX 10 September 21, 2010 13:51
About the OpenMP jinwon park Main CFD Forum 5 August 28, 2007 05:47
OpenMP and fortran John Deas Main CFD Forum 0 May 17, 2007 16:53
Parallel computing and OpenMP ganesh Main CFD Forum 7 October 27, 2006 10:15


All times are GMT -4. The time now is 14:10.