Test which checks the firstprivate clause of the task directive. We create a set of tasks in a single region. We defines a variable named sum unequal zero which gets declared firstprivate for each task. Now each task calcualtes a sum using this private variable. Before each calcualation step we introduce a flush command so that maybe the private variabel gets bad. At the end we check if the calculated sum was right.
3.0
omp task firstprivate
omp single,omp critical
INCLUDE "omp_my_sleep.f"
INTEGER FUNCTION omp_task_firstprivate()
IMPLICIT NONE
INCLUDE "omp_testsuite.f"
INTEGER j,i
external my_sleep
INTEGER my_sum
INTEGER known_sum
INTEGER rslt
COMMON /orphvars/ my_sum, known_sum, rslt
my_sum = 1234
known_sum = 1234 + (LOOPCOUNT * (LOOPCOUNT + 1)) / 2
!$omp parallel private(j)
!$omp single
do i=1, NUM_TASKS
!$omp task firstprivate(my_sum)
do j = 0, LOOPCOUNT
!$omp flush
my_sum = my_sum + j
end do
! check if calculated my_sum was right
if (my_sum .ne. known_sum) then
!$omp critical
rslt = rslt + 1
!$omp end critical
end if
!$omp end task
end do
!$omp end single
!$omp end parallel
if (rslt .eq. 0) then
= 1
else
= 0
end if
END FUNCTION