[llvm] Stop including unordered_map (NFC)
[llvm-project.git] / openmp / runtime / test / worksharing / for / omp_for_lastprivate.c
blob88694b816b1a68db5378497853fb3a0d4318f644
1 // RUN: %libomp-compile-and-run
2 #include <stdio.h>
3 #include <math.h>
4 #include "omp_testsuite.h"
6 int sum0;
7 #pragma omp threadprivate(sum0)
9 int test_omp_for_lastprivate()
11 int sum = 0;
12 int known_sum;
13 int i0;
15 i0 = -1;
17 #pragma omp parallel
19 sum0 = 0;
20 { /* Begin of orphaned block */
21 int i;
22 #pragma omp for schedule(static,7) lastprivate(i0)
23 for (i = 1; i <= LOOPCOUNT; i++) {
24 sum0 = sum0 + i;
25 i0 = i;
26 } /* end of for */
27 } /* end of orphaned block */
29 #pragma omp critical
31 sum = sum + sum0;
32 } /* end of critical */
33 } /* end of parallel */
35 known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2;
36 fprintf(stderr, "known_sum = %d , sum = %d\n",known_sum,sum);
37 fprintf(stderr, "LOOPCOUNT = %d , i0 = %d\n",LOOPCOUNT,i0);
38 return ((known_sum == sum) && (i0 == LOOPCOUNT));
41 int main()
43 int i;
44 int num_failed=0;
46 for (i = 0; i < REPETITIONS; i++) {
47 if(!test_omp_for_lastprivate()) {
48 num_failed++;
51 return num_failed;