Jim Cownie | 18d8473 | 2014-05-10 17:02:09 +0000 | [diff] [blame] | 1 | <ompts:test> |
| 2 | <ompts:testdescription>Test if the compiler support nested parallelism.</ompts:testdescription> |
| 3 | <ompts:version>2.5</ompts:version> |
| 4 | <ompts:directive>nestedtest</ompts:directive> |
| 5 | <ompts:dependences>omp critical</ompts:dependences> |
| 6 | <ompts:testcode> |
| 7 | INTEGER FUNCTION <ompts:testcode:functionname>omp_nested</ompts:testcode:functionname>() |
| 8 | IMPLICIT NONE |
| 9 | INCLUDE "omp_testsuite.f" |
| 10 | <ompts:orphan:vars> |
| 11 | INTEGER counter |
| 12 | COMMON /orphvars/ counter |
| 13 | </ompts:orphan:vars> |
| 14 | |
| 15 | counter =0 |
| 16 | |
| 17 | <ompts:check> |
| 18 | !$ CALL OMP_SET_NESTED(.TRUE.) |
| 19 | !#ifdef _OPENMP |
| 20 | ! CALL OMP_SET_NESTED(.TRUE.) |
| 21 | !#endif |
| 22 | </ompts:check> |
| 23 | <ompts:crosscheck> |
| 24 | !$ CALL OMP_SET_NESTED(.FALSE.) |
| 25 | !#ifdef _OPENMP |
| 26 | ! CALL OMP_SET_NESTED(.FALSE.) |
| 27 | !#endif |
| 28 | </ompts:crosscheck> |
| 29 | |
| 30 | !$omp parallel |
| 31 | <ompts:orphan> |
| 32 | !$omp critical |
| 33 | counter = counter + 1 |
| 34 | !$omp end critical |
| 35 | |
| 36 | !$omp parallel |
| 37 | !$omp critical |
| 38 | counter = counter - 1 |
| 39 | !$omp end critical |
| 40 | !$omp end parallel |
| 41 | </ompts:orphan> |
| 42 | !$omp end parallel |
| 43 | |
| 44 | IF (counter .EQ. 0 ) THEN |
| 45 | WRITE (1,*) "Counter was 0" |
| 46 | <testfunctionname></testfunctionname> = 0 |
| 47 | ELSE |
| 48 | WRITE (1,*) "Counter was", counter |
| 49 | <testfunctionname></testfunctionname> = 1 |
| 50 | END IF |
| 51 | END FUNCTION |
| 52 | </ompts:testcode> |
| 53 | </ompts:test> |