Jim Cownie | 18d8473 | 2014-05-10 17:02:09 +0000 | [diff] [blame^] | 1 | <ompts:test> |
| 2 | <ompts:testdescription>Test which checks the omp master directive by counting up a variable in a omp master section. It also checks that the master thread has the thread number 0 as specified in the OpenMP standard version 3.0.</ompts:testdescription> |
| 3 | <ompts:ompversion>3.0</ompts:ompversion> |
| 4 | <ompts:directive>omp master</ompts:directive> |
| 5 | <ompts:dependences>omp critical</ompts:dependences> |
| 6 | <ompts:testcode> |
| 7 | INTEGER FUNCTION <ompts:testcode:functionname>omp_master_3</ompts:testcode:functionname>() |
| 8 | IMPLICIT NONE |
| 9 | INTEGER omp_get_thread_num |
| 10 | <ompts:orphan:vars> |
| 11 | INTEGER nthreads, executing_thread |
| 12 | INTEGER tid_result ! counts up the number of wrong thread no. |
| 13 | ! for the master thread |
| 14 | COMMON /orphvars/ nthreads, executing_thread, tid_result |
| 15 | </ompts:orphan:vars> |
| 16 | tid_result = 0 |
| 17 | nthreads=0 |
| 18 | executing_thread=-1 |
| 19 | |
| 20 | !$omp parallel |
| 21 | <ompts:orphan> |
| 22 | <ompts:check> |
| 23 | !$omp master |
| 24 | </ompts:check> |
| 25 | if (omp_get_thread_num() .ne. 0) then |
| 26 | !$omp critical |
| 27 | tid_result = tid_result + 1 |
| 28 | !$omp end critical |
| 29 | end if |
| 30 | !$omp critical |
| 31 | nthreads = nthreads + 1 |
| 32 | !$omp end critical |
| 33 | executing_thread=omp_get_thread_num() |
| 34 | <ompts:check> |
| 35 | !$omp end master |
| 36 | </ompts:check> |
| 37 | </ompts:orphan> |
| 38 | !$omp end parallel |
| 39 | |
| 40 | IF ( (nthreads .EQ. 1) .AND. (executing_thread .EQ. 0) .AND. |
| 41 | & (tid_result .EQ. 0) ) THEN |
| 42 | <testfunctionname></testfunctionname> = 1 |
| 43 | ELSE |
| 44 | <testfunctionname></testfunctionname> = 0 |
| 45 | END IF |
| 46 | END |
| 47 | </ompts:testcode> |
| 48 | </ompts:test> |
| 49 | |