24#ifndef MORPHEUS_DENSEVECTOR_KOKKOS_DOT_IMPL_HPP
25#define MORPHEUS_DENSEVECTOR_KOKKOS_DOT_IMPL_HPP
27#include <Morpheus_SpaceTraits.hpp>
28#include <Morpheus_FormatTraits.hpp>
29#include <Morpheus_FormatTags.hpp>
30#include <Morpheus_Spaces.hpp>
35template <
typename ExecSpace,
typename Vector1,
typename Vector2>
36inline typename Vector2::value_type dot(
37 typename Vector1::size_type n,
const Vector1& x,
const Vector2& y,
38 typename std::enable_if_t<
39 Morpheus::is_dense_vector_format_container_v<Vector1> &&
40 Morpheus::is_dense_vector_format_container_v<Vector2> &&
41 Morpheus::has_generic_backend_v<ExecSpace> &&
42 Morpheus::has_access_v<ExecSpace, Vector1, Vector2>>* =
nullptr) {
43 using execution_space =
typename ExecSpace::execution_space;
44 using IndexType = Kokkos::IndexType<typename Vector1::size_type>;
45 using range_policy = Kokkos::RangePolicy<IndexType, execution_space>;
46 using ValueArray =
typename Vector1::value_array_type;
47 using value_type =
typename Vector2::non_const_value_type;
48 using size_type =
typename Vector1::size_type;
50 const ValueArray x_view = x.const_view(), y_view = y.const_view();
51 range_policy policy(0, n);
53 value_type result = value_type(0);
55 if (y.data() == x.data()) {
56 Kokkos::parallel_reduce(
57 "dot_same_data", policy,
58 KOKKOS_LAMBDA(
const size_type& i, value_type& lsum) {
59 lsum += x_view[i] * x_view[i];
63 Kokkos::parallel_reduce(
65 KOKKOS_LAMBDA(
const size_type& i, value_type& lsum) {
66 lsum += x_view[i] * y_view[i];
Generic Morpheus interfaces.
Definition: dummy.cpp:24