In Fortran, given arrays A(1000000) and B(1000000), and to compute the sum you simply write:
C = A + B
However, when I want to implement OpenMP, I have to write an explicit loop:
!$OMP PARALLEL DO
DO I = 1, 1000000
C(I) = A(I) + B(I)
END DO
!$OMP END PARALLEL DO
Is there a better way to do this? I know there is -parallel
compiler flag but it gives less performance.
-parallel
is a GCC/gfortran option only. $\endgroup$ifort
intel compiler. $\endgroup$-parallel
flag gives almost x2 slowdown in my case. $\endgroup$