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