Jim Cownie | 18d8473 | 2014-05-10 17:02:09 +0000 | [diff] [blame] | 1 | <ompts:test> |
| 2 | <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> |
| 3 | <ompts:ompversion>3.0</ompts:ompversion> |
| 4 | <ompts:directive>omp do collapse</ompts:directive> |
| 5 | <ompts:dependences>omp critical,omp do schedule</ompts:dependences> |
| 6 | <ompts:testcode> |
| 7 | LOGICAL FUNCTION check_is_larger(i) |
| 8 | implicit none |
| 9 | INTEGER :: i |
| 10 | INTEGER, save :: last_i |
| 11 | LOGICAL :: is_larger |
| 12 | |
| 13 | if (i .eq. 1) last_i = 0 |
| 14 | |
| 15 | is_larger = (i .ge. last_i) .and. ((i-last_i) .le. 1) |
| 16 | last_i = i |
| 17 | |
| 18 | check_is_larger = is_larger |
| 19 | |
| 20 | END FUNCTION check_is_larger |
| 21 | |
| 22 | INTEGER FUNCTION <ompts:testcode:functionname>do_collapse</ompts:testcode:functionname>() |
| 23 | IMPLICIT NONE |
| 24 | INTEGER i, j |
| 25 | <ompts:orphan:vars> |
| 26 | LOGICAL check_is_larger |
| 27 | LOGICAL my_is_larger |
| 28 | LOGICAL is_larger |
| 29 | COMMON /orphvars/ is_larger |
| 30 | </ompts:orphan:vars> |
| 31 | |
| 32 | INCLUDE "omp_testsuite.f" |
| 33 | |
| 34 | is_larger = .true. |
| 35 | |
| 36 | !$omp parallel private(my_is_larger) |
| 37 | <ompts:orphan> |
| 38 | my_is_larger = .true. |
| 39 | !$omp do private(i,j) schedule(static,1) <ompts:check>collapse(2)</ompts:check> |
| 40 | !$omp+ ordered |
| 41 | DO i=1,100 |
| 42 | <ompts:crosscheck> |
| 43 | my_is_larger = check_is_larger(i) .and. my_is_larger |
| 44 | </ompts:crosscheck> |
| 45 | DO j=1,00 |
| 46 | <ompts:check> |
| 47 | !$omp ordered |
| 48 | my_is_larger = check_is_larger(i) .and. my_is_larger |
| 49 | !$omp end ordered |
| 50 | </ompts:check> |
| 51 | END DO |
| 52 | END DO |
| 53 | !$omp end do |
| 54 | !$omp critical |
| 55 | is_larger = is_larger .and. my_is_larger |
| 56 | !$omp end critical |
| 57 | </ompts:orphan> |
| 58 | !$omp end parallel |
| 59 | |
| 60 | if (is_larger) then |
| 61 | <testfunctionname></testfunctionname> = 1 |
| 62 | else |
| 63 | <testfunctionname></testfunctionname> = 0 |
| 64 | end if |
| 65 | END FUNCTION |
| 66 | </ompts:testcode> |
| 67 | </ompts:test> |