From 3f7da964ee025f6c4838d190997442cf30a1a797 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Mon, 26 Oct 2020 11:40:44 +0100 Subject: [PATCH] Add adaptor --- src/numpy_adaptors.hpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/numpy_adaptors.hpp diff --git a/src/numpy_adaptors.hpp b/src/numpy_adaptors.hpp new file mode 100644 index 0000000..fe3962c --- /dev/null +++ b/src/numpy_adaptors.hpp @@ -0,0 +1,30 @@ +#ifndef __COSMOTOOL_NUMPY_ADAPTOR_HPP +#define __COSMOTOOL_NUMPY_ADAPTOR_HPP + +namespace CosmoTool { + + template + void parallel_ufunc_dd_d(char **args, IT* dimensions, IT* steps, void *func) { + IT i; + IT n = dimensions[0]; + char *in = args[0], *in2 = args[1], *out = args[2]; + IT in_step = steps[0], in2_step = args[1], out_step = steps[2]; + + double tmp; + typedef double (*F_t)(double,double); + + F_t f = (F_t)func; + +#pragma omp parallel for schedule(static) + for (i = 0; i < n; i++) { + T *out_t = (T *)(out + i * out_step); + T *in_t = (T *)(in + i * in_step); + T *in2_t = (T *)(in2 + i * in2_step); + *out_t = f(*in_t, *in2_t); + } + } + + +} + +#endif