summaryrefslogtreecommitdiffstats
path: root/openmp/testsuite/fortran/do_collapse.f
blob: 1817250c1bc0cbbd2f86d7bc460a3c77be82d596 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<ompts:test>
<ompts:testdescription>Test with omp for collapse clause. Bind with two loops. Without the collapse clause, the first loop will not be ordered</ompts:testdescription>
<ompts:ompversion>3.0</ompts:ompversion>
<ompts:directive>omp do collapse</ompts:directive>
<ompts:dependences>omp critical,omp do schedule</ompts:dependences>
<ompts:testcode>
      LOGICAL FUNCTION check_is_larger(i)
        implicit none
        INTEGER :: i
        INTEGER, save :: last_i
        LOGICAL :: is_larger

        if (i .eq. 1) last_i = 0

        is_larger = (i .ge. last_i) .and. ((i-last_i) .le. 1)
        last_i = i

        check_is_larger = is_larger

      END FUNCTION check_is_larger

      INTEGER FUNCTION <ompts:testcode:functionname>do_collapse</ompts:testcode:functionname>()
        IMPLICIT NONE
        INTEGER i, j
<ompts:orphan:vars>
        LOGICAL check_is_larger
        LOGICAL my_is_larger
        LOGICAL is_larger
        COMMON /orphvars/ is_larger
</ompts:orphan:vars>

        INCLUDE "omp_testsuite.f"

        is_larger = .true.

!$omp parallel private(my_is_larger)
<ompts:orphan>
        my_is_larger = .true.
!$omp do private(i,j) schedule(static,1) <ompts:check>collapse(2)</ompts:check>
!$omp+   ordered
        DO i=1,100
          <ompts:crosscheck>
          my_is_larger = check_is_larger(i) .and. my_is_larger
          </ompts:crosscheck>
          DO j=1,00
          <ompts:check>
!$omp ordered
            my_is_larger = check_is_larger(i) .and. my_is_larger
!$omp end ordered
          </ompts:check>
          END DO
        END DO
!$omp end do
!$omp critical
        is_larger = is_larger .and. my_is_larger
!$omp end critical
</ompts:orphan>
!$omp end parallel

      if (is_larger) then
        <testfunctionname></testfunctionname> = 1
      else
        <testfunctionname></testfunctionname> = 0
      end if
      END FUNCTION
</ompts:testcode>
</ompts:test>
OpenPOWER on IntegriCloud