[llvm] Stop including unordered_map (NFC)
[llvm-project.git] / openmp / runtime / test / tasking / omp_task_firstprivate.c
blobd1f7c353161f013af938e7373ddb1fcfd95d81cc
1 // RUN: %libomp-compile-and-run
2 #include <stdio.h>
3 #include <math.h>
4 #include "omp_testsuite.h"
6 int test_omp_task_firstprivate()
8 int i;
9 int sum = 1234;
10 int known_sum;
11 int result = 0; /* counts the wrong sums from tasks */
13 known_sum = 1234 + (LOOPCOUNT * (LOOPCOUNT + 1)) / 2;
15 #pragma omp parallel
17 #pragma omp single
19 for (i = 0; i < NUM_TASKS; i++) {
20 #pragma omp task firstprivate(sum)
22 int j;
23 for (j = 0; j <= LOOPCOUNT; j++) {
24 #pragma omp flush
25 sum += j;
28 /* check if calculated sum was right */
29 if (sum != known_sum) {
30 #pragma omp critical
31 { result++; }
33 } /* omp task */
34 } /* for loop */
35 } /* omp single */
36 } /* omp parallel */
37 return (result == 0);
40 int main()
42 int i;
43 int num_failed=0;
45 for(i = 0; i < REPETITIONS; i++) {
46 if(!test_omp_task_firstprivate()) {
47 num_failed++;
50 return num_failed;