Jim Cownie | 18d8473 | 2014-05-10 17:02:09 +0000 | [diff] [blame] | 1 | <ompts:test> |
| 2 | <ompts:description>Test which checks the omp parallel for nowait directive. It fills an array with values and operates on these in the following.</ompts:description> |
| 3 | <ompts:directive>omp parallel sections nowait</ompts:directive> |
| 4 | <ompts:version>1.0</ompts:version> |
| 5 | <ompts:dependences>omp parallel sections, omp flush</ompts:dependences> |
| 6 | <ompts:testcode> |
| 7 | #include <stdio.h> |
| 8 | |
| 9 | #include "omp_testsuite.h" |
| 10 | #include "omp_my_sleep.h" |
| 11 | |
| 12 | int <ompts:testcode:functionname>omp_sections_nowait</ompts:testcode:functionname> (FILE * logFile) |
| 13 | { |
| 14 | <ompts:orphan:vars> |
| 15 | int result; |
| 16 | int count; |
| 17 | </ompts:orphan:vars> |
| 18 | int j; |
| 19 | |
| 20 | result = 0; |
| 21 | count = 0; |
| 22 | |
| 23 | #pragma omp parallel |
| 24 | { |
| 25 | <ompts:orphan> |
| 26 | int rank; |
| 27 | |
| 28 | rank = omp_get_thread_num (); |
| 29 | |
| 30 | #pragma omp sections <ompts:check>nowait</ompts:check> |
| 31 | { |
| 32 | #pragma omp section |
| 33 | { |
| 34 | fprintf (logFile, "Thread nr %d enters first section and gets sleeping.\n", rank); |
| 35 | my_sleep(SLEEPTIME); |
| 36 | count = 1; |
| 37 | fprintf (logFile, "Thread nr %d woke up an set count to 1.\n", rank); |
| 38 | #pragma omp flush(count) |
| 39 | } |
| 40 | #pragma omp section |
| 41 | { |
| 42 | fprintf (logFile, "Thread nr %d executed work in the first section.\n", rank); |
| 43 | } |
| 44 | } |
| 45 | /* Begin of second sections environment */ |
| 46 | #pragma omp sections |
| 47 | { |
| 48 | #pragma omp section |
| 49 | { |
| 50 | fprintf (logFile, "Thread nr %d executed work in the second section.\n", rank); |
| 51 | } |
| 52 | #pragma omp section |
| 53 | { |
| 54 | fprintf (logFile, "Thread nr %d executed work in the second section and controls the value of count\n", rank); |
| 55 | if (count == 0) |
| 56 | result = 1; |
| 57 | fprintf (logFile, "cout was %d", count); |
| 58 | } |
| 59 | } |
| 60 | </ompts:orphan> |
| 61 | } |
| 62 | |
| 63 | return result; |
| 64 | } |
| 65 | </ompts:testcode> |
| 66 | </ompts:test> |