OpenMP-Examples/sources/Example_SIMD.3.c
2020-06-26 07:54:45 -07:00

21 lines
347 B
C

/*
* @@name: SIMD.3c
* @@type: C
* @@compilable: yes
* @@linkable: no
* @@expect: success
* @@version: omp_4.0
*/
double work( double *a, double *b, int n )
{
int i;
double tmp, sum;
sum = 0.0;
#pragma omp simd private(tmp) reduction(+:sum)
for (i = 0; i < n; i++) {
tmp = a[i] + b[i];
sum += tmp;
}
return sum;
}