OpenMP Nested Loop SIMD Vectorization

I am trying to vectorize a nested loop using the OpenMP 4.0 function simd, but I am afraid that I am doing it wrong. My loops look like this:

do iy = iyfirst, iylast
    do ix = ixfirst, ixlast

        !$omp simd
        do iz = izfirst, izlast

            dudx(iz,ix,iy) = ax(1)*( u(iz,ix,iy) - u(iz,ix-1,iy) )
            do ishift = 2, ophalf
                dudx(iz,ix,iy) = dudx(iz,ix,iy) + ax(ishift)*( u(iz,ix+ishift-1,iy) - u(iz,ix-ishift,iy) )
            enddo

            dudx(iz,ix,iy) = dudx(iz,ix,iy)*buoy_x(iz,ix,iy)

        enddo
        !$omp end simd

    enddo
enddo

Note that ophalfthis is a small integer, usually 2 or 4, so it makes sense to vectorize a loop izrather than an inner loop.

My question is: Should I mark ishiftas a private variable?

In standard OpenMP loops, parallel doyou will probably need private(ishift)to prevent other threads from stomping on top of each other. However, when I instead rewrite the first line as !$omp simd private(ishift), I get an ifort compilation error:

# 8592: SIMD DO- PRIVATE SIMD. [ISHIFT]

, . , ishift , . ?

: , omp parallel do iy, private(ishift) omp parallel do, omp simd , ?

.

+4
1

, SIMD, , ishift SIMD- SIMD. , , ishift . , SIMD- iz, , iz, ishift - 2 ophalf. , SIMD.

, ishift, , , . , ishift omp parallel do context. , iz.

0

Source: https://habr.com/ru/post/1619950/


All Articles