[Instrumentation] Fix a warning
[llvm-project.git] / openmp / runtime / test / parallel / omp_parallel_copyin.c
blob600f9b72c20875b4e2bf548516cc238a27ce5c17
1 // RUN: %libomp-compile-and-run
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include "omp_testsuite.h"
6 static int sum1 = 789;
7 #pragma omp threadprivate(sum1)
9 int test_omp_parallel_copyin()
11 int sum, num_threads;
12 int known_sum;
14 sum = 0;
15 sum1 = 7;
16 num_threads = 0;
18 #pragma omp parallel copyin(sum1)
20 /*printf("sum1=%d\n",sum1);*/
21 int i;
22 #pragma omp for
23 for (i = 1; i < 1000; i++) {
24 sum1 = sum1 + i;
25 } /*end of for*/
26 #pragma omp critical
28 sum = sum + sum1;
29 num_threads++;
30 } /*end of critical*/
31 } /* end of parallel*/
32 known_sum = (999 * 1000) / 2 + 7 * num_threads;
33 return (known_sum == sum);
36 int main()
38 int i;
39 int num_failed=0;
41 for(i = 0; i < REPETITIONS; i++) {
42 if(!test_omp_parallel_copyin()) {
43 num_failed++;
46 return num_failed;