1#ifndef included_AMP_CSRVisit
2#define included_AMP_CSRVisit
4#include "AMP/IO/RestartManager.h"
5#include "AMP/matrices/CSRConfig.h"
6#include "AMP/matrices/CSRMatrix.h"
13template<
class Head,
class... Rest>
22 std::shared_ptr<LinearAlgebra::Matrix>
mat;
27 using ret_t = std::invoke_result_t<std::decay_t<F>, std::shared_ptr<CSRMatrix<first_config>>>;
33 return check_lidx<alloc::host>();
35 return check_lidx<alloc::device>();
37 return check_lidx<alloc::managed>();
39 AMP_ERROR(
"csr_visitor: mode not found!" );
43 template<alloc a, index l, index g, scalar s>
47 if constexpr ( is_config_built<config_t> ) {
49 auto ptr = std::dynamic_pointer_cast<CSRMatrix<config_t>>(
mat );
51 return std::forward<F>(
f )( ptr );
53 AMP_ERROR(
"csr_visitor: mode not found!" );
55 template<alloc a, index l, index g>
60 return visit<a, l, g, scalar::f32>();
62 return visit<a, l, g, scalar::f64>();
64 return visit<a, l, g, scalar::fld>();
66 AMP_ERROR(
"csr_visitor: mode not found!" );
68 template<alloc a, index l>
73 return check_scalar<a, l, index::i32>();
75 return check_scalar<a, l, index::i64>();
77 return check_scalar<a, l, index::ill>();
79 AMP_ERROR(
"csr_visitor: mode not found!" );
86 return check_gidx<a, index::i32>();
88 return check_gidx<a, index::i64>();
90 return check_gidx<a, index::ill>();
92 AMP_ERROR(
"csr_visitor: mode not found!" );
108 auto mode =
static_cast<csr_mode>( mat->mode() );
109 csr_visitor visit{ mode, mat, std::forward<F>( f ) };
#define AMP_DEBUG_ASSERT(EXP)
Assert error (debug only)
#define AMP_ERROR(MSG)
Throw error.
auto csrVisit(std::shared_ptr< Matrix > mat, F &&f)
auto get_gidx(csr_mode mode)
auto get_lidx(csr_mode mode)
auto get_alloc(csr_mode mode)
auto get_scalar(csr_mode mode)
std::shared_ptr< LinearAlgebra::Matrix > mat
std::invoke_result_t< std::decay_t< F >, std::shared_ptr< CSRMatrix< first_config > > > ret_t
typename detail::list_begin< built_configs >::type first_config