expr.c (expand_expr_real_1): Just use do_store_flag.
[official-gcc.git] / libgomp / testsuite / libgomp.c / omp_reduction.c
blob5c9c41ec7491cad9cd9adf6219e54883e0282e4b
1 /******************************************************************************
2 * FILE: omp_reduction.c
3 * DESCRIPTION:
4 * OpenMP Example - Combined Parallel Loop Reduction - C/C++ Version
5 * This example demonstrates a sum reduction within a combined parallel loop
6 * construct. Notice that default data element scoping is assumed - there
7 * are no clauses specifying shared or private variables. OpenMP will
8 * automatically make loop index variables private within team threads, and
9 * global variables shared.
10 * AUTHOR: Blaise Barney 5/99
11 * LAST REVISED: 04/06/05
12 ******************************************************************************/
13 #include <omp.h>
14 #include <stdio.h>
15 #include <stdlib.h>
17 int main (int argc, char *argv[]) {
19 int i, n;
20 float a[100], b[100], sum;
22 /* Some initializations */
23 n = 100;
24 for (i=0; i < n; i++)
25 a[i] = b[i] = i * 1.0;
26 sum = 0.0;
28 #pragma omp parallel for reduction(+:sum)
29 for (i=0; i < n; i++)
30 sum = sum + (a[i] * b[i]);
32 printf(" Sum = %f\n",sum);
34 return 0;