diff --git a/docs/internal-api.rst b/docs/internal-api.rst index 5b157004..e542473b 100644 --- a/docs/internal-api.rst +++ b/docs/internal-api.rst @@ -42,10 +42,6 @@ Memory Management Functions and Macros Reductions and Related Functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. doxygengroup:: nomp_reduction_ops - :project: libnomp - :content-only: - .. doxygengroup:: nomp_reduction_utils :project: libnomp :content-only: diff --git a/include/nomp-impl.h b/include/nomp-impl.h index a8845fa4..31370ab6 100644 --- a/include/nomp-impl.h +++ b/include/nomp-impl.h @@ -80,6 +80,22 @@ typedef struct { void *ptr; } nomp_arg_t; +/** + * @defgroup nomp_reduction_utils Reduction utilities + * + * @brief Utilities used to perform reduction operations. + */ + +/** + * @ingroup nomp_reduction_utils + * + * @brief Enum for different reduction operations. + */ +typedef enum { + NOMP_SUM = 0, /*!< Sum reduction. */ + NOMP_PROD = 1 /*!< Multiplication reduction.*/ +} nomp_reduction_op_t; + /** * @ingroup nomp_internal_types * @@ -103,7 +119,11 @@ typedef struct { */ CVecBasic *sym_global, *sym_local; /** - * Map of variable names and their values use to evaluate + * Flag used to determine if the grid size should be evaluated or not. + */ + int eval_grid; + /** + * Map of variable names and their values used to evaluate * the kernel launch parameters. */ CMapBasicBasic *map; @@ -112,12 +132,29 @@ typedef struct { * input changes). */ size_t global[3], local[3], gws[3]; - // Boolean flag to determine if the grid size should be evaluated or not. - int eval_grid; - // Pointer to keep track of backend specific data. + /** + * Pointer to keep track of backend specific data for the active backend. + */ void *bptr; - // Reduction related metadata. - int redn_idx, redn_op, redn_type, redn_size; + /** + * Index of the deduction argument if one exists. + */ + int redn_idx; + /** + * Reduction operation to be performed. + */ + nomp_reduction_op_t redn_op; + /** + * Type of the reduction variable. + */ + nomp_type_t redn_type; + /** + * Size of the reduction variable given by sizeof(). + */ + int redn_size; + /** + * Pointer to the reduction variable. + */ void *redn_ptr; } nomp_prog_t; @@ -234,6 +271,14 @@ int cuda_init(nomp_backend_t *backend, int platform, int device); int hip_init(nomp_backend_t *backend, int platform, int device); +/** + * @ingroup nomp_reduction_utils + * + * @brief Perform residual host side reductions. + */ +int nomp_host_side_reduction(nomp_backend_t *bnd, nomp_prog_t *prg, + nomp_mem_t *m); + #ifdef __cplusplus } #endif diff --git a/include/nomp-reduction.h b/include/nomp-reduction.h deleted file mode 100644 index 85bf0eaf..00000000 --- a/include/nomp-reduction.h +++ /dev/null @@ -1,31 +0,0 @@ -#if !defined(_NOMP_REDUCTION_H_) -#define _NOMP_REDUCTION_H_ - -#include "nomp-impl.h" - -/** - * @defgroup nomp_reduction_ops Reduction operations - * @brief Defines reduction operations allowed in nomp kernels. - */ - -/** - * @ingroup nomp_reduction_ops - * @def NOMP_SUM - * @brief Sum reduction operation. - */ -#define NOMP_SUM 0 -/** - * @ingroup nomp_reduction_ops - * @def NOMP_PROD - * @brief Product reduction operation. - */ -#define NOMP_PROD 1 - -/** - * @defgroup nomp_reduction_utils Reduction utilities - * @brief Perform host side reductions. - */ -int nomp_host_side_reduction(nomp_backend_t *bnd, nomp_prog_t *prg, - nomp_mem_t *m); - -#endif diff --git a/src/nomp.c b/src/nomp.c index 756df5f3..65fae10f 100644 --- a/src/nomp.c +++ b/src/nomp.c @@ -1,7 +1,6 @@ #include "nomp-aux.h" #include "nomp-impl.h" #include "nomp-loopy.h" -#include "nomp-reduction.h" static nomp_backend_t nomp; static int initialized = 0; diff --git a/src/reduction.c b/src/reduction.c index cba87a26..b48e4c3d 100644 --- a/src/reduction.c +++ b/src/reduction.c @@ -1,4 +1,4 @@ -#include "nomp-reduction.h" +#include "nomp-impl.h" #define NOMP_DO_SUM(a, b) (a) += (b) #define NOMP_DO_PROD(a, b) (a) *= (b)