summaryrefslogtreecommitdiffstats
path: root/openmp/testsuite/fortran/omp_nested.f
blob: 5435151f074a5f70241eef829a0fd6efb925d36e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<ompts:test>
<ompts:testdescription>Test if the compiler support nested parallelism.</ompts:testdescription>
<ompts:version>2.5</ompts:version>
<ompts:directive>nestedtest</ompts:directive>
<ompts:dependences>omp critical</ompts:dependences>
<ompts:testcode>
      INTEGER FUNCTION <ompts:testcode:functionname>omp_nested</ompts:testcode:functionname>()
        IMPLICIT NONE
        INCLUDE "omp_testsuite.f"
<ompts:orphan:vars>
        INTEGER counter
        COMMON /orphvars/ counter
</ompts:orphan:vars>

        counter =0
        
        <ompts:check>
!$      CALL OMP_SET_NESTED(.TRUE.)
!#ifdef _OPENMP
!       CALL OMP_SET_NESTED(.TRUE.) 
!#endif
        </ompts:check>
        <ompts:crosscheck>
!$      CALL OMP_SET_NESTED(.FALSE.)
!#ifdef _OPENMP
!       CALL OMP_SET_NESTED(.FALSE.)
!#endif
        </ompts:crosscheck>

!$omp parallel
        <ompts:orphan>
!$omp critical
          counter = counter + 1
!$omp end critical

!$omp parallel
!$omp critical
          counter = counter - 1
!$omp end critical
!$omp end parallel
        </ompts:orphan>
!$omp end parallel
        
        IF (counter .EQ. 0 ) THEN
           WRITE (1,*) "Counter was 0"
           <testfunctionname></testfunctionname> = 0
        ELSE
           WRITE (1,*) "Counter was", counter
           <testfunctionname></testfunctionname> = 1
        END IF 
      END FUNCTION
</ompts:testcode>
</ompts:test>
OpenPOWER on IntegriCloud