I am currently trying to use the *task* construct of OpenMP 4.0 including the *depend* statement for my Fortran codes. Therefore, I create the following example, which should fill up the first row of a matrix with the numbers 1 to M by a task and fill up the remaining elements by a task each whenever the element in the first row is ready. This results in the following piece of code:
PROGRAM OMP_TEST
IMPLICIT NONE
INTEGER K,L
INTEGER M
PARAMETER (M = 8)
INTEGER A(M,M)
A(1:M, 1:M) = 0
!$omp parallel
!$omp single
DO L=1, M
!$omp task depend(out:A(1,L)) default(shared)
A(1,L) = L
!$omp end task
DO K = 2, M
!$omp task depend(in:A(1,L)) default(shared)
A(K,L) = A(1,L)
!$omp end task
END DO
END DO
!$omp taskwait
!$omp end single
!$omp end parallel
DO K =1 , M
WRITE(*,*) A(K,1:M)
END DO
END PROGRAM
Compile with the Intel Fortran 15 compiler, which is according to the documentation aware of the *depend* statement. But the result printed to the screen is different at every execution. Even the initial zeros of the matrix stay at some positions. For example:
1 2 3 4 5 6
7 8
0 0 0 0 0 0
0 0
0 0 3 4 0 0
0 8
1 0 3 4 0 6
0 8
1 0 3 4 5 6
0 8
1 2 3 4 5 6
7 8
0 2 3 4 5 6
7 0
1 2 3 4 5 6
0 8Why does the dependencies between the task do not work correctly as I expect it such that the values 1 to 8 are in each row?