10#include <kernel/backend.hpp>
11#include <kernel/util/memory_arbiter.hpp>
14namespace FEAT::LAFEM::Arch
16 struct UnitFilterBlockWeakBCSR
18 template<
typename DT_,
typename IT_>
19 static void exec_generic_impl(DT_* mat_a,
const DT_*
const mat_m,
const IT_*
const row_ptr,
const DT_ *
const f_val,
const IT_ *
const f_idx,
const Index f_nzes,
const bool ign_nans,
const int block_height,
const int block_width);
21 template<
typename DT_,
typename IT_>
22 static void exec_cuda_impl(DT_* mat_a,
const DT_*
const mat_m,
const IT_*
const row_ptr,
const DT_ *
const f_val,
const IT_ *
const f_idx,
const Index f_nzes,
const bool ign_nans,
const int block_height,
const int block_width);
24 template<
typename DT_,
typename IT_,
int block_height_,
int block_w
idth_>
25 static void exec_generic(Memory::Arbiter& mat_a,
const Memory::Arbiter& mat_m,
const Memory::Arbiter& row_ptr,
const Memory::Arbiter& f_val,
const Memory::Arbiter& f_idx,
const Index f_nzes,
const bool ign_nans)
27 Memory::TypedView<DT_> a_view(mat_a.view(Memory::Location::main, Memory::Access::read_write));
28 Memory::TypedView<DT_> m_view(mat_m.view(Memory::Location::main, Memory::Access::read));
29 Memory::TypedView<DT_> f_view(f_val.view(Memory::Location::main, Memory::Access::read));
30 Memory::TypedView<IT_> rp_view(row_ptr.view(Memory::Location::main, Memory::Access::read));
31 Memory::TypedView<IT_> fi_view(f_idx.view(Memory::Location::main, Memory::Access::read));
32 exec_generic_impl(a_view.get_w(), m_view.get_r(), rp_view.get_r(), f_view.get_r(), fi_view.get_r(), f_nzes, ign_nans, block_height_, block_width_);
35 template<
typename DT_,
typename IT_,
int block_height_,
int block_w
idth_>
36 static void exec_cuda(Memory::Arbiter& mat_a,
const Memory::Arbiter& mat_m,
const Memory::Arbiter& row_ptr,
const Memory::Arbiter& f_val,
const Memory::Arbiter& f_idx,
const Index f_nzes,
const bool ign_nans)
38 Memory::TypedView<DT_> a_view(mat_a.view(Memory::Location::cuda, Memory::Access::read_write));
39 Memory::TypedView<DT_> m_view(mat_m.view(Memory::Location::cuda, Memory::Access::read));
40 Memory::TypedView<DT_> f_view(f_val.view(Memory::Location::cuda, Memory::Access::read));
41 Memory::TypedView<IT_> rp_view(row_ptr.view(Memory::Location::cuda, Memory::Access::read));
42 Memory::TypedView<IT_> fi_view(f_idx.view(Memory::Location::cuda, Memory::Access::read));
43 exec_cuda_impl(a_view.get_w(), m_view.get_r(), rp_view.get_r(), f_view.get_r(), fi_view.get_r(), f_nzes, ign_nans, block_height_, block_width_);
46 template<
typename DT_,
typename IT_,
int block_height_,
int block_w
idth_>
47 static void exec(Memory::Arbiter& mat_a,
const Memory::Arbiter& mat_m,
const Memory::Arbiter& row_ptr,
const Memory::Arbiter& f_val,
const Memory::Arbiter& f_idx,
const Index f_nzes,
const bool ign_nans)
49 switch(Backend::get_preferred_backend())
51 case PreferredBackend::generic:
52 exec_generic<DT_, IT_, block_height_, block_width_>(mat_a, mat_m, row_ptr, f_val, f_idx, f_nzes, ign_nans);
55 case PreferredBackend::mkl:
57 Backend::warn_missing(
"LAFEM::Arch::UnitFilterBlockWeakBCSR::exec");
58 exec_generic<DT_, IT_, block_height_, block_width_>(mat_a, mat_m, row_ptr, f_val, f_idx, f_nzes, ign_nans);
60 XABORTM(
"LAFEM::Arch::UnitFilterBlockWeakBCSR::exec: MKL backend not available!");
64 case PreferredBackend::cuda:
66 exec_cuda<DT_, IT_, block_height_, block_width_>(mat_a, mat_m, row_ptr, f_val, f_idx, f_nzes, ign_nans);
68 XABORTM(
"LAFEM::Arch::UnitFilterBlockWeakBCSR::exec: CUDA backend not available!");
73 XABORTM(
"LAFEM::Arch::UnitFilterBlockWeakBCSR::exec: unknown backend!");
80 extern template void UnitFilterBlockWeakBCSR::exec_generic_impl(
float* mat_a,
const float* mat_m,
const std::uint32_t*
const row_ptr,
const float *
const f_val,
const std::uint32_t *
const f_idx,
const Index f_nzes,
const bool,
const int,
const int);
81 extern template void UnitFilterBlockWeakBCSR::exec_generic_impl(
float* mat_a,
const float* mat_m,
const std::uint64_t*
const row_ptr,
const float *
const f_val,
const std::uint64_t *
const f_idx,
const Index f_nzes,
const bool,
const int,
const int);
82 extern template void UnitFilterBlockWeakBCSR::exec_generic_impl(
double* mat_a,
const double* mat_m,
const std::uint32_t*
const row_ptr,
const double *
const f_val,
const std::uint32_t *
const f_idx,
const Index f_nzes,
const bool,
const int,
const int);
83 extern template void UnitFilterBlockWeakBCSR::exec_generic_impl(
double* mat_a,
const double* mat_m,
const std::uint64_t*
const row_ptr,
const double *
const f_val,
const std::uint64_t *
const f_idx,
const Index f_nzes,
const bool,
const int,
const int);
89#define KERNEL_LAFEM_ARCH_UNIT_FILTER_BLOCK_WEAK_BCSR_HPP 1
90#include <kernel/lafem/arch/unit_filter_block_weak_bcsr_generic.hpp>
#define XABORTM(msg)
Abortion macro definition with custom message.
std::uint64_t Index
Index data type.