24#ifndef MORPHEUS_DENSEVECTOR_OPENMP_REDUCTION_IMPL_HPP
25#define MORPHEUS_DENSEVECTOR_OPENMP_REDUCTION_IMPL_HPP
27#if defined(MORPHEUS_ENABLE_OPENMP)
29#include <Morpheus_SpaceTraits.hpp>
30#include <Morpheus_FormatTraits.hpp>
31#include <Morpheus_FormatTags.hpp>
32#include <Morpheus_Spaces.hpp>
37template <
typename ExecSpace,
typename Vector>
38typename Vector::value_type reduce(
39 const Vector& in,
typename Vector::size_type size,
40 typename std::enable_if_t<
41 Morpheus::is_dense_vector_format_container_v<Vector> &&
42 Morpheus::has_custom_backend_v<ExecSpace> &&
43 Morpheus::has_openmp_execution_space_v<ExecSpace> &&
44 Morpheus::has_access_v<ExecSpace, Vector>>* =
nullptr) {
45 using value_type =
typename Vector::value_type;
46 using size_type =
typename Vector::size_type;
48 value_type sum = value_type(0);
50#pragma omp parallel for reduction(+ : sum)
51 for (size_type i = 0; i < size; i++) sum += in[i];
Generic Morpheus interfaces.
Definition: dummy.cpp:24