Jim Cownie | 18d8473 | 2014-05-10 17:02:09 +0000 | [diff] [blame] | 1 | <ompts:test> |
Alp Toker | c2d5e61 | 2014-06-01 18:28:36 +0000 | [diff] [blame] | 2 | <ompts:testdescription>Test which checks the omp barrier directive. The test creates several threads and sends one of them sleeping before setting a flag. After the barrier the other ones do some little work depending on the flag.</ompts:testdescription> |
Jim Cownie | 18d8473 | 2014-05-10 17:02:09 +0000 | [diff] [blame] | 3 | <ompts:ompversion>2.0</ompts:ompversion> |
| 4 | <ompts:directive>omp barrier</ompts:directive> |
| 5 | <ompts:testcode> |
| 6 | #include <stdio.h> |
| 7 | #include <unistd.h> |
| 8 | |
| 9 | #include "omp_testsuite.h" |
| 10 | #include "omp_my_sleep.h" |
| 11 | |
| 12 | int <ompts:testcode:functionname>omp_barrier</ompts:testcode:functionname> (FILE * logFile) |
| 13 | { |
| 14 | <ompts:orphan:vars> |
| 15 | int result1; |
| 16 | int result2; |
| 17 | </ompts:orphan:vars> |
| 18 | |
| 19 | result1 = 0; |
| 20 | result2 = 0; |
| 21 | |
| 22 | #pragma omp parallel |
| 23 | { |
| 24 | <ompts:orphan> |
| 25 | int rank; |
| 26 | rank = omp_get_thread_num (); |
| 27 | if (rank ==1) { |
| 28 | my_sleep(SLEEPTIME_LONG); |
| 29 | result2 = 3; |
| 30 | } |
| 31 | <ompts:check>#pragma omp barrier</ompts:check> |
| 32 | if (rank == 2) { |
| 33 | result1 = result2; |
| 34 | } |
| 35 | </ompts:orphan> |
| 36 | } |
| 37 | printf("result1=%d\n",result1); |
| 38 | return (result1 == 3); |
| 39 | } |
| 40 | </ompts:testcode> |
| 41 | </ompts:test> |