Jim Cownie | 18d8473 | 2014-05-10 17:02:09 +0000 | [diff] [blame] | 1 | <ompts:test> |
| 2 | <ompts:testdescription>Test which checks the omp_set_lock and the omp_unset_lock function by counting the threads entering and exiting a single region with locks.</ompts:testdescription> |
| 3 | <ompts:ompversion>3.0</ompts:ompversion> |
| 4 | <ompts:directive>omp_lock</ompts:directive> |
| 5 | <ompts:dependences>omp flush</ompts:dependences> |
| 6 | <ompts:testcode> |
| 7 | INTEGER FUNCTION <ompts:testcode:functionname>omp_lock</ompts:testcode:functionname>() |
| 8 | IMPLICIT NONE |
| 9 | INTEGER result |
| 10 | INTEGER nr_threads_in_single |
| 11 | INTEGER nr_iterations |
| 12 | INTEGER i |
| 13 | !lock variable |
| 14 | <ompts:orphan:vars> |
| 15 | INCLUDE "omp_lib.h" |
| 16 | INTEGER (KIND=OMP_LOCK_KIND) :: lock |
| 17 | COMMON /orphvars/ lock |
| 18 | </ompts:orphan:vars> |
| 19 | INCLUDE "omp_testsuite.f" |
| 20 | |
| 21 | !result is: |
| 22 | ! 0 -- if the test fails |
| 23 | ! 1 -- if the test succeeds |
| 24 | CALL omp_init_lock(lock) |
| 25 | nr_iterations=0 |
| 26 | nr_threads_in_single=0 |
| 27 | result=0 |
| 28 | !$omp parallel shared(lock,nr_threads_in_single,nr_iterations,result) |
| 29 | !$omp do |
| 30 | DO i=1,LOOPCOUNT |
| 31 | <ompts:orphan> |
| 32 | <ompts:check> |
| 33 | CALL omp_set_lock(lock) |
| 34 | </ompts:check> |
| 35 | </ompts:orphan> |
| 36 | !$omp flush |
| 37 | nr_threads_in_single=nr_threads_in_single+1 |
| 38 | !$omp flush |
| 39 | nr_iterations=nr_iterations+1 |
| 40 | nr_threads_in_single=nr_threads_in_single-1 |
| 41 | result=result+nr_threads_in_single |
| 42 | <ompts:orphan> |
| 43 | <ompts:check> |
| 44 | CALL omp_unset_lock(lock) |
| 45 | </ompts:check> |
| 46 | </ompts:orphan> |
| 47 | END DO |
| 48 | !$omp end do |
| 49 | !$omp end parallel |
| 50 | CALL omp_destroy_lock(lock) |
| 51 | IF(result.EQ.0 .AND. nr_iterations .EQ. LOOPCOUNT) THEN |
| 52 | <testfunctionname></testfunctionname>=1 |
| 53 | ELSE |
| 54 | <testfunctionname></testfunctionname>=0 |
| 55 | ENDIf |
| 56 | END |
| 57 | </ompts:testcode> |
| 58 | </ompts:test> |