Jim Cownie | 18d8473 | 2014-05-10 17:02:09 +0000 | [diff] [blame] | 1 | <ompts:test> |
| 2 | <ompts:testdescription>Test which checks the omp flush directive.</ompts:testdescription> |
| 3 | <ompts:ompversion>2.0</ompts:ompversion> |
| 4 | <ompts:directive>omp flush</ompts:directive> |
| 5 | <ompts:dependences>omp barrier</ompts:dependences> |
| 6 | <ompts:testcode> |
| 7 | #include <stdio.h> |
| 8 | #include <unistd.h> |
| 9 | |
| 10 | #include "omp_testsuite.h" |
| 11 | #include "omp_my_sleep.h" |
| 12 | |
| 13 | int <ompts:testcode:functionname>omp_flush</ompts:testcode:functionname> (FILE * logFile) |
| 14 | { |
| 15 | <ompts:orphan:vars> |
| 16 | int result1; |
| 17 | int result2; |
| 18 | int dummy; |
| 19 | </ompts:orphan:vars> |
| 20 | |
| 21 | result1 = 0; |
| 22 | result2 = 0; |
| 23 | |
| 24 | #pragma omp parallel |
| 25 | { |
| 26 | int rank; |
| 27 | rank = omp_get_thread_num (); |
| 28 | |
| 29 | #pragma omp barrier |
| 30 | if (rank == 1) { |
| 31 | result2 = 3; |
| 32 | <ompts:orphan> |
| 33 | <ompts:check>#pragma omp flush (result2)</ompts:check> |
| 34 | dummy = result2; |
| 35 | </ompts:orphan> |
| 36 | } |
| 37 | |
| 38 | if (rank == 0) { |
| 39 | <ompts:check>my_sleep(SLEEPTIME_LONG);</ompts:check> |
| 40 | <ompts:orphan> |
| 41 | <ompts:check>#pragma omp flush (result2)</ompts:check> |
| 42 | result1 = result2; |
| 43 | </ompts:orphan> |
| 44 | } |
| 45 | } /* end of parallel */ |
| 46 | |
| 47 | return ((result1 == result2) && (result2 == dummy) && (result2 == 3)); |
| 48 | } |
| 49 | </ompts:testcode> |
| 50 | </ompts:test> |