consider the case where a single thread (say, the master) has a private vector x and submits a number of tasks which update different coefficients of x. Here is a simple (fortran) code that does this
- Code: Select all
integer, allocatable :: x(:)
integer :: m, j
m = 10
!$omp parallel private(x)
do j=1, m
!$omp task firstprivate(j) shared(x)
x(j) = j
!$omp end task
!$omp end master
!$omp end parallel
end program main
I would like to know whether this code is OpenMP compliant and/or correct.
My understanding is that the shared clause in the task construct is such that within the task the actual x array is the one that was allocated by the master, regardless of the thread executing the task. Is this correct?
This code does not work with intel ifort. The compiler complains about x not being allocated (if I turn on the compiler bounds check whistles). If I remove the deallocate statement then the code works ok but because of the taskwait, the deallocation should not be executed before all the tasks are done and thus this behavior seems totally strange to me. Also, the code works fine if I make x a pointer instead of an allocatable.
The code works fine with gfortran.
Is this an ifort bug?