2014-05-11 01:02:09 +08:00
<ompt s : test >
2014-06-02 02:28:36 +08:00
<ompt s : testdescription > Test which checks the omp barrier directive . The test creates several threads and sends one of them sleeping before setting a flag. After the barrier the other ones do some little work depending on the flag.</ ompts:testdescription>
2014-05-11 01:02:09 +08:00
<ompt s : ompversion > 2.0 < / ompts : ompversion >
<ompt s : directive > omp barrier < / ompts : directive >
<ompt s : testcode >
SUBROUTINE do_some_work3 ( )
REAL i
INTRINSIC sqrt
DOUBLE PRECISION sum
INCLUDE "omp_testsuite.f"
sum = 0.0
DO WHILE ( i < LOOPCOUNT - 1 )
sum = sum + sqrt ( i )
i = i + 1
END DO
END
INTEGER FUNCTION < ompts : testcode : functionname > omp_barrier < / ompts : t estcode:functionname>()
IMPLICIT NONE
INTEGER sleeptime
INTEGER omp_get_thread_num
INTEGER result1 , result2 , rank
result1 = 0
result2 = 0
sleeptime = 1
!$omp parallel private(rank)
rank = omp_get_thread_num ( )
! PRINT *, "rank", rank
IF ( rank . EQ . 1 ) THEN
CALL sleep ( sleeptime )
result2 = 3
END IF
< ompts : orphan >
< ompts : check >
!$omp barrier
< / ompts : check >
< / ompts : orphan >
IF ( rank . EQ . 0 ) THEN
result1 = result2
END IF
!$omp end parallel
IF ( result1 . EQ . 3 ) THEN
< testfunctionname > < / testfunctionname > = 1
ELSE
< testfunctionname > < / testfunctionname > = 0
END IF
END
</omp t s : testcode >
</omp t s : test >