Jim Cownie | 18d8473 | 2014-05-10 17:02:09 +0000 | [diff] [blame] | 1 | <ompts:test> |
| 2 | <ompts:testdescription>Test which checks if a variable declared as threadprivate can be used as a loopindex.</ompts:testdescription> |
| 3 | <ompts:ompversion>2.0</ompts:ompversion> |
| 4 | <ompts:directive>omp threadprivate</ompts:directive> |
| 5 | <ompts:dependences>omp critical</ompts:dependences> |
| 6 | <ompts:testcode> |
| 7 | #include "omp_testsuite.h" |
| 8 | #include <stdlib.h> |
| 9 | #include <stdio.h> |
| 10 | |
| 11 | static int i; |
| 12 | <ompts:check>#pragma omp threadprivate(i)</ompts:check> |
| 13 | |
| 14 | int <ompts:testcode:functionname>omp_threadprivate_for</ompts:testcode:functionname>(FILE * logFile) |
| 15 | { |
| 16 | int known_sum; |
| 17 | int sum; |
| 18 | known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2; |
| 19 | sum = 0; |
| 20 | |
| 21 | #pragma omp parallel |
| 22 | { |
| 23 | int sum0 = 0; |
| 24 | #pragma omp for |
| 25 | for (i = 1; i <= LOOPCOUNT; i++) |
| 26 | { |
| 27 | sum0 = sum0 + i; |
| 28 | } /*end of for*/ |
| 29 | #pragma omp critical |
| 30 | { |
| 31 | sum = sum + sum0; |
| 32 | } /*end of critical */ |
| 33 | } /* end of parallel */ |
| 34 | |
| 35 | if (known_sum != sum ) { |
| 36 | fprintf (logFile, " known_sum = %d, sum = %d\n", known_sum, sum); |
| 37 | } |
| 38 | |
| 39 | return (known_sum == sum); |
| 40 | |
| 41 | } /* end of check_threadprivate*/ |
| 42 | </ompts:testcode> |
| 43 | </ompts:test> |
| 44 | |