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

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