Jim Cownie | 18d8473 | 2014-05-10 17:02:09 +0000 | [diff] [blame] | 1 | <ompts:test> |
| 2 | <ompts:testdescription>Test which checks the omp do lastprivate clause by counting up a variable in a parallelized loop. Each thread saves the next summand in a lastprivate variable i0. At the end i0 is compared to the value of the expected last summand.</ompts:testdescription> |
| 3 | <ompts:version>2.0</ompts:version> |
| 4 | <ompts:directive>omp do private</ompts:directive> |
| 5 | <ompts:dependences>omp parallel firstprivate, omp critical</ompts:dependences> |
| 6 | <ompts:testcode> |
| 7 | INTEGER FUNCTION <ompts:testcode:functionname>do_lastprivate</ompts:testcode:functionname>() |
| 8 | IMPLICIT NONE |
| 9 | INTEGER sum,known_sum |
| 10 | <ompts:orphan:vars> |
| 11 | INTEGER sum0,i0,i |
| 12 | COMMON /orphvars/ sum0,i0,i |
| 13 | </ompts:orphan:vars> |
| 14 | INCLUDE "omp_testsuite.f" |
| 15 | sum = 0 |
| 16 | sum0 = 0 |
| 17 | i0 = -1 |
| 18 | !$omp parallel firstprivate(sum0) |
| 19 | <ompts:orphan> |
| 20 | !$omp do schedule(static,7) <ompts:check>lastprivate(i0)</ompts:check> |
| 21 | DO i=1, LOOPCOUNT |
| 22 | sum0 = sum0 + i |
| 23 | i0 = i |
| 24 | END DO |
| 25 | <ompts:check>!$omp end do</ompts:check> |
| 26 | </ompts:orphan> |
| 27 | !$omp critical |
| 28 | sum = sum + sum0 |
| 29 | !$omp end critical |
| 30 | !$omp end parallel |
| 31 | known_sum = (LOOPCOUNT*(LOOPCOUNT+1))/2 |
| 32 | IF ( known_sum .EQ. sum .AND. i0 .EQ. LOOPCOUNT ) THEN |
| 33 | <testfunctionname></testfunctionname> = 1 |
| 34 | ELSE |
| 35 | <testfunctionname></testfunctionname> = 0 |
| 36 | END IF |
| 37 | END FUNCTION |
| 38 | </ompts:testcode> |
| 39 | </ompts:test> |