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; }