24#ifndef MORPHEUS_DIA_KOKKOS_MULTIPLY_IMPL_HPP
25#define MORPHEUS_DIA_KOKKOS_MULTIPLY_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 Matrix,
typename Vector>
37 const Matrix& A,
const Vector& x, Vector& y,
const bool init,
38 typename std::enable_if_t<
39 Morpheus::is_dia_matrix_format_container_v<Matrix> &&
40 Morpheus::is_dense_vector_format_container_v<Vector> &&
41 Morpheus::has_generic_backend_v<ExecSpace> &&
42 Morpheus::has_access_v<ExecSpace, Matrix, Vector>>* =
nullptr) {
43 using execution_space =
typename ExecSpace::execution_space;
44 using value_array_type =
typename Matrix::value_array_type::value_array_type;
45 using index_array_type =
typename Matrix::index_array_type::value_array_type;
46 using size_type =
typename Matrix::size_type;
47 using index_type =
typename Matrix::index_type;
48 using value_type =
typename Matrix::value_type;
49 using member_type =
typename Kokkos::TeamPolicy<execution_space>::member_type;
51 const value_array_type values = A.cvalues().const_view();
52 const typename Vector::value_array_type x_view = x.const_view();
53 const index_array_type diagonal_offsets = A.cdiagonal_offsets().const_view();
54 typename Vector::value_array_type y_view = y.view();
55 size_type ndiag = A.cdiagonal_offsets().size(), ncols = A.ncols();
57 const Kokkos::TeamPolicy<execution_space> policy(A.nrows(), Kokkos::AUTO,
61 policy, KOKKOS_LAMBDA(
const member_type& team_member) {
62 const index_type row = team_member.league_rank();
64 value_type sum = init ? value_type(0) : y_view[row];
65 Kokkos::parallel_reduce(
66 Kokkos::TeamThreadRange(team_member, ndiag),
67 [=](
const size_type& n, value_type& lsum) {
68 const index_type col = row + diagonal_offsets[n];
70 if (col >= 0 && col < (index_type)ncols) {
71 lsum += values(row, n) * x_view[col];
75 y_view[row] = init ? sum : sum + y_view[row];
Generic Morpheus interfaces.
Definition: dummy.cpp:24