blob: 3b1304dbee939cc6adb08fe7485d51313e252116 [file] [log] [blame]
Jim Cownie18d84732014-05-10 17:02:09 +00001<ompts:test>
2<ompts:testdescription>Test which checks the omp_testlock function. The test counts the threads entering and exiting a single region which is build with a test_lock in an endless loop.</ompts:testdescription>
3<ompts:ompversion>2.0</ompts:ompversion>
4<ompts:directive>omp_test_lock</ompts:directive>
5<ompts:dependences>omp flush</ompts:dependences>
6<ompts:testcode>
7 INTEGER FUNCTION <ompts:testcode:functionname>omp_testlock</ompts:testcode:functionname>()
8 IMPLICIT NONE
9 INTEGER result
10 INTEGER nr_threads_in_single
11 INTEGER nr_iterations
12 INTEGER i
13 <ompts:orphan:vars>
14 include "omp_lib.h"
15 INTEGER (KIND=OMP_LOCK_KIND)::lock
16 COMMON /orphvars/ lock
17 </ompts:orphan:vars>
18 INCLUDE "omp_testsuite.f"
19
20 nr_iterations=0
21 nr_threads_in_single=0
22 CALL OMP_INIT_LOCK(lock)
23 result=0
24
25!$omp parallel shared(lock,nr_threads_in_single,nr_iterations,result)
26!$omp do
27 DO i=1,LOOPCOUNT
28 <ompts:orphan>
29 <ompts:check>
30 DO WHILE (.NOT. OMP_TEST_LOCK(lock))
31 END DO
32 </ompts:check>
33 </ompts:orphan>
34!$omp flush
35 nr_threads_in_single=nr_threads_in_single+1
36!$omp flush
37 nr_iterations=nr_iterations+1
38 nr_threads_in_single=nr_threads_in_single-1
39 result=result+nr_threads_in_single
40 <ompts:orphan>
41 <ompts:check>
42 CALL OMP_UNSET_LOCK(lock)
43 </ompts:check>
44 </ompts:orphan>
45 END DO
46!$omp end do
47!$omp end parallel
48 CALL OMP_DESTROY_LOCK(lock)
49! print *, result, nr_iterations
50 IF(result.EQ.0 .AND. nr_iterations .EQ. LOOPCOUNT) THEN
51 <testfunctionname></testfunctionname>=1
52 ELSE
53 <testfunctionname></testfunctionname>=0
54 ENDIF
55 END FUNCTION
56</ompts:testcode>
57</ompts:test>