[memprof] Upgrade a unit test to MemProf Version 3 (#117063)
[llvm-project.git] / openmp / runtime / test / worksharing / sections / omp_section_firstprivate.c
blob5526475a20c43b5e1bf6b69ef0f734bc5e4b26f1
1 // RUN: %libomp-compile-and-run
2 #include <stdio.h>
3 #include "omp_testsuite.h"
5 int test_omp_section_firstprivate()
7 int sum;
8 int sum0;
9 int known_sum;
11 sum0 = 11;
12 sum = 7;
13 #pragma omp parallel
15 #pragma omp sections firstprivate(sum0)
17 #pragma omp section
19 #pragma omp critical
21 sum = sum + sum0;
24 #pragma omp section
26 #pragma omp critical
28 sum = sum + sum0;
31 #pragma omp section
33 #pragma omp critical
35 sum = sum + sum0;
40 known_sum = 11 * 3 + 7;
41 return (known_sum == sum);
42 } /* end of check_section_firstprivate*/
44 int main()
46 int i;
47 int num_failed=0;
49 for(i = 0; i < REPETITIONS; i++) {
50 if(!test_omp_section_firstprivate()) {
51 num_failed++;
54 return num_failed;