1// RUN: %libomp-compile-and-run
2#include <stdio.h>
3#include "omp_testsuite.h"
4
5int test_omp_parallel_default()
6{
7 int i;
8 int sum;
9 int mysum;
10 int known_sum;
11 sum =0;
12 known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2 ;
13
14 #pragma omp parallel default(shared) private(i) private(mysum)
15 {
16 mysum = 0;
17 #pragma omp for
18 for (i = 1; i <= LOOPCOUNT; i++) {
19 mysum = mysum + i;
20 }
21 #pragma omp critical
22 {
23 sum = sum + mysum;
24 } /* end of critical */
25 } /* end of parallel */
26 if (known_sum != sum) {
27 fprintf(stderr, format: "KNOWN_SUM = %d; SUM = %d\n", known_sum, sum);
28 }
29 return (known_sum == sum);
30}
31
32int main()
33{
34 int i;
35 int num_failed=0;
36
37 for(i = 0; i < REPETITIONS; i++) {
38 if(!test_omp_parallel_default()) {
39 num_failed++;
40 }
41 }
42 return num_failed;
43}
44

source code of openmp/runtime/test/parallel/omp_parallel_default.c