[Instrumentation] Fix a warning
[llvm-project.git] / openmp / runtime / test / parallel / omp_parallel_shared.c
blob3146ca68efe68c6785fb49f376737224f9d3b132
1 // RUN: %libomp-compile-and-run
2 #include <stdio.h>
3 #include "omp_testsuite.h"
5 int test_omp_parallel_shared()
7 int i;
8 int sum;
9 int known_sum;
11 sum = 0;
12 known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2 ;
14 #pragma omp parallel private(i) shared(sum)
17 int mysum = 0;
18 #pragma omp for
19 for (i = 1; i <= LOOPCOUNT; i++) {
20 mysum = mysum + i;
22 #pragma omp critical
24 sum = sum + mysum;
29 if (known_sum != sum) {
30 fprintf(stderr, "KNOWN_SUM = %d; SUM = %d\n", known_sum, sum);
32 return (known_sum == sum);
35 int main()
37 int i;
38 int num_failed=0;
40 for(i = 0; i < REPETITIONS; i++) {
41 if(!test_omp_parallel_shared()) {
42 num_failed++;
45 return num_failed;