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 |
i private default shared and reduction (:+c2)
|
All times are GMT -4. The time now is 02:01. |