1// RUN: %libomp-compile-and-run
2#include <stdio.h>
3#include "omp_testsuite.h"
4
5int test_omp_parallel_for_firstprivate()
6{
7 int sum ;
8 int i2;
9 int i;
10 int known_sum;
11
12 sum=0;
13 i2=3;
14
15 #pragma omp parallel for reduction(+:sum) private(i) firstprivate(i2)
16 for (i = 1; i <= LOOPCOUNT; i++) {
17 sum = sum + (i + i2);
18 }
19
20 known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2 + i2 * LOOPCOUNT;
21 return (known_sum == sum);
22} /* end of check_parallel_for_fistprivate */
23
24int main()
25{
26 int i;
27 int num_failed=0;
28
29 for(i = 0; i < REPETITIONS; i++) {
30 if(!test_omp_parallel_for_firstprivate()) {
31 num_failed++;
32 }
33 }
34 return num_failed;
35}
36

source code of openmp/runtime/test/worksharing/for/omp_parallel_for_firstprivate.c