[llvm] Stop including unordered_map (NFC)
[llvm-project.git] / openmp / runtime / test / worksharing / for / omp_for_firstprivate.c
blob6c4121cce233962434b8220801099bedc4db4732
1 // RUN: %libomp-compile-and-run
2 #include <stdio.h>
3 #include <math.h>
4 #include "omp_testsuite.h"
6 int sum1;
7 #pragma omp threadprivate(sum1)
9 int test_omp_for_firstprivate()
11 int sum;
12 int sum0;
13 int known_sum;
14 int threadsnum;
16 sum = 0;
17 sum0 = 12345;
18 sum1 = 0;
20 #pragma omp parallel
22 #pragma omp single
24 threadsnum=omp_get_num_threads();
26 /* sum0 = 0; */
28 int i;
29 #pragma omp for firstprivate(sum0)
30 for (i = 1; i <= LOOPCOUNT; i++) {
31 sum0 = sum0 + i;
32 sum1 = sum0;
33 } /* end of for */
35 #pragma omp critical
37 sum = sum + sum1;
38 } /* end of critical */
39 } /* end of parallel */
40 known_sum = 12345* threadsnum+ (LOOPCOUNT * (LOOPCOUNT + 1)) / 2;
41 return (known_sum == sum);
44 int main()
46 int i;
47 int num_failed=0;
49 for(i = 0; i < REPETITIONS; i++) {
50 if(!test_omp_for_firstprivate()) {
51 num_failed++;
54 return num_failed;