24#ifndef MORPHEUS_DIA_HIP_MATRIXOPERATIONS_IMPL_HPP
25#define MORPHEUS_DIA_HIP_MATRIXOPERATIONS_IMPL_HPP
27#include <Morpheus_Macros.hpp>
28#if defined(MORPHEUS_ENABLE_HIP)
30#include <Morpheus_Exceptions.hpp>
31#include <Morpheus_SpaceTraits.hpp>
32#include <Morpheus_FormatTraits.hpp>
33#include <Morpheus_FormatTags.hpp>
34#include <Morpheus_Spaces.hpp>
36#include <impl/Morpheus_HIPUtils.hpp>
37#include <impl/Dia/Kernels/Morpheus_MatrixOperations_Impl.hpp>
42template <
typename ExecSpace,
typename Matrix,
typename Vector>
44 Matrix& A,
const Vector& diagonal,
45 typename std::enable_if_t<
46 Morpheus::is_dia_matrix_format_container_v<Matrix> &&
47 Morpheus::is_dense_vector_format_container_v<Vector> &&
48 Morpheus::has_custom_backend_v<ExecSpace> &&
49 Morpheus::has_hip_execution_space_v<ExecSpace> &&
50 Morpheus::has_access_v<ExecSpace, Matrix, Vector>>* =
nullptr) {
51 using size_type =
typename Matrix::size_type;
52 using index_type =
typename Matrix::index_type;
53 using value_type =
typename Matrix::value_type;
55 const size_type BLOCK_SIZE = 256;
56 const size_type MAX_BLOCKS = max_active_blocks(
57 Kernels::update_dia_diagonal_kernel<value_type, index_type, size_type>,
59 const size_type NUM_BLOCKS =
60 std::min<size_type>(MAX_BLOCKS, DIVIDE_INTO(A.nrows(), BLOCK_SIZE));
62 const size_type num_diagonals = A.cvalues().ncols();
63 const size_type pitch = A.cvalues().nrows();
65 Kernels::update_dia_diagonal_kernel<value_type, index_type, size_type>
66 <<<NUM_BLOCKS, BLOCK_SIZE, 0>>>(A.nrows(), A.ncols(), num_diagonals,
67 pitch, A.diagonal_offsets().data(),
68 A.values().data(), diagonal.data());
69#if defined(DEBUG) || defined(MORPHEUS_DEBUG)
70 getLastHIPError(
"update_dia_diagonal_kernel: Kernel execution failed");
74template <
typename ExecSpace,
typename Matrix,
typename Vector>
76 Matrix&,
const Vector&,
77 typename std::enable_if_t<
78 Morpheus::is_dia_matrix_format_container_v<Matrix> &&
79 Morpheus::is_dense_vector_format_container_v<Vector> &&
80 Morpheus::has_custom_backend_v<ExecSpace> &&
81 Morpheus::has_hip_execution_space_v<ExecSpace> &&
82 Morpheus::has_access_v<ExecSpace, Matrix, Vector>>* =
nullptr) {
86template <
typename ExecSpace,
typename Matrix,
typename SizeType,
88void set_value(Matrix&, SizeType, SizeType, ValueType,
89 typename std::enable_if_t<
90 Morpheus::is_dia_matrix_format_container_v<Matrix> &&
91 Morpheus::has_custom_backend_v<ExecSpace> &&
92 Morpheus::has_hip_execution_space_v<ExecSpace> &&
93 Morpheus::has_access_v<ExecSpace, Matrix>>* =
nullptr) {
97template <
typename ExecSpace,
typename Matrix,
typename IndexVector,
100 Matrix&,
typename IndexVector::value_type,
const IndexVector,
101 typename IndexVector::value_type,
const IndexVector,
const ValueVector,
102 typename std::enable_if_t<
103 Morpheus::is_dia_matrix_format_container_v<Matrix> &&
104 Morpheus::is_dense_vector_format_container_v<IndexVector> &&
105 Morpheus::is_dense_vector_format_container_v<ValueVector> &&
106 Morpheus::has_custom_backend_v<ExecSpace> &&
107 Morpheus::has_hip_execution_space_v<ExecSpace> &&
108 Morpheus::has_access_v<ExecSpace, Matrix, IndexVector, ValueVector>>* =
113template <
typename ExecSpace,
typename Matrix,
typename TransposeMatrix>
115 const Matrix&, TransposeMatrix&,
116 typename std::enable_if_t<
117 Morpheus::is_dia_matrix_format_container_v<Matrix> &&
118 Morpheus::is_dia_matrix_format_container_v<TransposeMatrix> &&
119 Morpheus::has_custom_backend_v<ExecSpace> &&
120 Morpheus::has_hip_execution_space_v<ExecSpace> &&
121 Morpheus::has_access_v<ExecSpace, Matrix, TransposeMatrix>>* =
Definition: Morpheus_Exceptions.hpp:43
Generic Morpheus interfaces.
Definition: dummy.cpp:24