Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / openmp / runtime / test / critical / omp_critical.c
blobe07dbcb7442dbea418071078810fe3c850a9f46d
1 // RUN: %libomp-compile-and-run
2 #include <stdio.h>
3 #include "omp_testsuite.h"
5 int test_omp_critical()
7 int sum;
8 int known_sum;
10 sum=0;
11 #pragma omp parallel
13 int mysum=0;
14 int i;
15 #pragma omp for
16 for (i = 0; i < 1000; i++)
17 mysum = mysum + i;
19 #pragma omp critical
20 sum = mysum +sum;
22 known_sum = 999 * 1000 / 2;
23 return (known_sum == sum);
26 int main()
28 int i;
29 int num_failed=0;
31 for(i = 0; i < REPETITIONS; i++) {
32 if(!test_omp_critical()) {
33 num_failed++;
36 return num_failed;