24#ifndef MORPHEUS_DENSEVECTOR_OPENMP_SCAN_IMPL_HPP
25#define MORPHEUS_DENSEVECTOR_OPENMP_SCAN_IMPL_HPP
27#include <Morpheus_Macros.hpp>
28#if defined(MORPHEUS_ENABLE_OPENMP)
30#include <Morpheus_SpaceTraits.hpp>
31#include <Morpheus_FormatTraits.hpp>
32#include <Morpheus_FormatTags.hpp>
33#include <Morpheus_Spaces.hpp>
38template <
typename ExecSpace,
typename Vector>
39void inclusive_scan(
const Vector& in, Vector& out,
40 typename Vector::index_type size,
41 typename Vector::index_type start,
42 typename std::enable_if_t<
43 Morpheus::is_dense_vector_format_container_v<Vector> &&
44 Morpheus::has_custom_backend_v<ExecSpace> &&
45 Morpheus::has_openmp_space_v<ExecSpace> &&
46 Morpheus::has_access_v<ExecSpace, Vector>>* =
nullptr) {
47 using index_type =
typename Vector::index_type;
48 using value_type =
typename Vector::value_type;
51 value_type initial = 0;
53#pragma omp simd reduction(inscan, + : initial)
54 for (index_type i = start; i < size; i++) {
56#pragma omp scan inclusive(initial)
60 static_assert(
"Requires OpenMP4.5 and above");
64template <
typename ExecSpace,
typename Vector>
65void exclusive_scan(
const Vector& in, Vector& out,
66 typename Vector::index_type size,
67 typename Vector::index_type start,
68 typename std::enable_if_t<
69 Morpheus::is_dense_vector_format_container_v<Vector> &&
70 Morpheus::has_custom_backend_v<ExecSpace> &&
71 Morpheus::has_openmp_space_v<ExecSpace> &&
72 Morpheus::has_access_v<ExecSpace, Vector>>* =
nullptr) {
73 using index_type =
typename Vector::index_type;
74 using value_type =
typename Vector::value_type;
78 value_type initial = 0;
80#pragma omp simd reduction(inscan, + : initial)
81 for (index_type i = start; i < size - 1; i++) {
83#pragma omp scan exclusive(initial)
86 out[size - 1] = initial;
89 static_assert(
"Requires OpenMP4.5 and above");
Generic Morpheus interfaces.
Definition: dummy.cpp:24