CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   How to parallelize this fortran code by openmp (https://www.cfd-online.com/Forums/main/14658-how-parallelize-fortran-code-openmp.html)

ronac January 18, 2008 21:36

How to parallelize this fortran code by openmp
 
Dear all,

I have a fortran code to calculate particle motion. there are alway many big loops. Some guy suggest me to use openmp to speed it up. the following is the pseudo code. Do I do it correctly?

c$OMP PARALLEL DO DEFAULT(SHARED), PRIVATE(i,ni,c2,ks,ke)

do i=1,ni

a(i)=c1

c2=0

ks=lfirst(i)

ke=last(i)

do k=ks,ke

c2=c2+f(k)

c3=f1+f2

................

c4=f+f3

enddo

f(i)=c2+c3

enddo

It can be seen that the loop i in the code is independent, but loop k is dependent. All calculations mainly happen in loop k which is small, up to 8. The loop i is always big, up to 200,000. I only want to use openmp for loop i. Your hints would be greatly appreciated. Cheers,ronac

ankeshgoyal May 11, 2016 02:12

i private default shared and reduction (:+c2)


All times are GMT -4. The time now is 02:01.