summaryrefslogtreecommitdiffstats
path: root/Tests/FindOpenMP/Test/scalprod.c
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/FindOpenMP/Test/scalprod.c')
-rw-r--r--Tests/FindOpenMP/Test/scalprod.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/Tests/FindOpenMP/Test/scalprod.c b/Tests/FindOpenMP/Test/scalprod.c
new file mode 100644
index 0000000..24c4587
--- /dev/null
+++ b/Tests/FindOpenMP/Test/scalprod.c
@@ -0,0 +1,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;
+}