summaryrefslogtreecommitdiffstats
path: root/Tests/FindOpenMP/Test/scalprod.c
blob: 24c4587af3e62d06f342a6a0fed1c694e7ca2dbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <omp.h>

#ifdef __cplusplus
extern "C"
#endif
  void
  scalprod(int n, double* x, double* y, double* res)
{
  int i;
  double res_v = 0.;
#pragma omp parallel for reduction(+ : res_v)
  for (i = 0; i < n; ++i) {
    res_v += x[i] * y[i];
  }
  *res = res_v;
}