/******************************************************************************
* FILE: omp_reduction.c
* DESCRIPTION:
*   OpenMP Example - Combined Parallel Loop Reduction - C/C++ Version
*   This example demonstrates a sum reduction within a combined parallel loop
*   construct.  Notice that default data element scoping is assumed - there
*   are no clauses specifying shared or private variables.  OpenMP will 
*   automatically make loop index variables private within team threads, and
*   global variables shared.
******************************************************************************/
#include <omp.h>
#include <stdio.h>
#include <stdlib.h>
#define n 5

int main (int argc, char *argv[]) 
{
int   i;
float a[n], b[n];
float sum = 0.0;

/* Some initializations */
for (i=0; i < n; i++)
  a[i] = b[i] = i * 1.0;
	
//modele PRAM CRCW avec le Mode fusion
#pragma omp parallel 
  #pragma omp for reduction(+:sum)
      for (i=0; i < n; i++)
         sum = sum + (a[i] * b[i]);

printf("   Sum = %f\n",sum);
}
