Jim Cownie | 18d8473 | 2014-05-10 17:02:09 +0000 | [diff] [blame] | 1 | <ompts:test> |
| 2 | <ompts:testdescription>Test which checks the omp section firstprivate directive by adding a variable which is defined before the parallel region.</ompts:testdescription> |
| 3 | <ompts:ompversion>2.0</ompts:ompversion> |
| 4 | <ompts:directive>omp firstprivate</ompts:directive> |
| 5 | <ompts:testcode> |
| 6 | #include <stdio.h> |
| 7 | #include "omp_testsuite.h" |
| 8 | |
| 9 | |
| 10 | int <ompts:testcode:functionname>omp_section_firstprivate</ompts:testcode:functionname>(FILE * logFile){ |
| 11 | <ompts:orphan:vars> |
| 12 | int sum; |
| 13 | int sum0; |
| 14 | </ompts:orphan:vars> |
| 15 | int known_sum; |
| 16 | |
| 17 | sum0 = 11; |
| 18 | sum = 7; |
| 19 | #pragma omp parallel |
| 20 | { |
| 21 | <ompts:orphan> |
| 22 | #pragma omp sections <ompts:check>firstprivate(sum0)</ompts:check><ompts:crosscheck>private(sum0)</ompts:crosscheck> |
| 23 | { |
| 24 | #pragma omp section |
| 25 | { |
| 26 | #pragma omp critical |
| 27 | { |
| 28 | sum = sum + sum0; |
| 29 | } /*end of critical */ |
| 30 | } |
| 31 | #pragma omp section |
| 32 | { |
| 33 | #pragma omp critical |
| 34 | { |
| 35 | sum = sum + sum0; |
| 36 | } /*end of critical */ |
| 37 | } |
| 38 | #pragma omp section |
| 39 | { |
| 40 | #pragma omp critical |
| 41 | { |
| 42 | sum = sum + sum0; |
| 43 | } /*end of critical */ |
| 44 | } |
| 45 | } /*end of sections*/ |
| 46 | </ompts:orphan> |
| 47 | } /* end of parallel */ |
| 48 | known_sum = 11 * 3 + 7; |
| 49 | return (known_sum == sum); |
| 50 | } /* end of check_section_firstprivate*/ |
| 51 | </ompts:testcode> |
| 52 | </ompts:test> |