10#include <kernel/backend.hpp>
11#include <kernel/util/memory_arbiter.hpp>
14namespace FEAT::LAFEM::Arch
16 struct UnitFilterBlockVec
18 template <
typename DT_,
typename IT_>
19 static void exec_generic_impl(DT_ * v,
const DT_ *
const f_val,
const IT_ *
const f_idx,
const Index f_nzes,
const bool zero,
const bool ign_nans,
const int block_size);
21 template <
typename DT_,
typename IT_,
int block_size_>
22 static void exec_generic(Memory::Arbiter& v,
const Memory::Arbiter& f_val,
const Memory::Arbiter& f_idx,
const Index f_nzes,
const bool zero,
const bool ign_nans)
24 Memory::TypedView<DT_> v_view(v.view(Memory::Location::main, Memory::Access::read_write));
25 Memory::TypedView<IT_> i_view(f_idx.view(Memory::Location::main, Memory::Access::read));
28 Memory::TypedView<DT_> f_view(f_val.view(Memory::Location::main, Memory::Access::read));
29 exec_generic_impl(v_view.get_w(), f_view.get_r(), i_view.get_r(), f_nzes, zero, ign_nans, block_size_);
34 exec_generic_impl(v_view.get_w(), (DT_*)
nullptr, i_view.get_r(), f_nzes, zero, ign_nans, block_size_);
38 template <
typename DT_,
typename IT_>
39 static void exec_cuda_impl(DT_ * v,
const DT_ *
const f_val,
const IT_ *
const f_idx,
const Index f_nzes,
const bool zero,
const bool ign_nans,
const int block_size);
41 template <
typename DT_,
typename IT_,
int block_size_>
42 static void exec_cuda(Memory::Arbiter& v,
const Memory::Arbiter& f_val,
const Memory::Arbiter& f_idx,
const Index f_nzes,
const bool zero,
const bool ign_nans)
44 Memory::TypedView<DT_> v_view(v.view(Memory::Location::cuda, Memory::Access::read_write));
45 Memory::TypedView<IT_> i_view(f_idx.view(Memory::Location::cuda, Memory::Access::read));
48 Memory::TypedView<DT_> f_view(f_val.view(Memory::Location::cuda, Memory::Access::read));
49 exec_cuda_impl(v_view.get_w(), f_view.get_r(), i_view.get_r(), f_nzes, zero, ign_nans, block_size_);
54 exec_cuda_impl(v_view.get_w(), (DT_*)
nullptr, i_view.get_r(), f_nzes, zero, ign_nans, block_size_);
58 template <
typename DT_,
typename IT_,
int block_size_>
59 static void exec(Memory::Arbiter& v,
const Memory::Arbiter& f_val,
const Memory::Arbiter& f_idx,
const Index f_nzes,
const bool zero,
const bool ign_nans)
61 switch(Backend::get_preferred_backend())
63 case PreferredBackend::generic:
64 exec_generic<DT_, IT_, block_size_>(v, f_val, f_idx, f_nzes, zero, ign_nans);
67 case PreferredBackend::mkl:
69 Backend::warn_missing(
"LAFEM::Arch::UnitFilterBlockVec::exec");
70 exec_generic<DT_, IT_, block_size_>(v, f_val, f_idx, f_nzes, zero, ign_nans);
72 XABORTM(
"LAFEM::Arch::UnitFilterBlockVec::exec: MKL backend not available!");
76 case PreferredBackend::cuda:
78 exec_cuda<DT_, IT_, block_size_>(v, f_val, f_idx, f_nzes, zero, ign_nans);
80 XABORTM(
"LAFEM::Arch::UnitFilterBlockVec::exec: CUDA backend not available!");
85 XABORTM(
"LAFEM::Arch::UnitFilterBlockVec::exec: unknown backend!");
92 extern template void UnitFilterBlockVec::exec_generic_impl(
float *,
const float *
const,
const std::uint64_t *
const,
const Index,
const bool,
const bool,
const int);
93 extern template void UnitFilterBlockVec::exec_generic_impl(
double *,
const double *
const,
const std::uint64_t *
const,
const Index,
const bool,
const bool,
const int);
94 extern template void UnitFilterBlockVec::exec_generic_impl(
float *,
const float *
const,
const std::uint32_t *
const,
const Index,
const bool,
const bool,
const int);
95 extern template void UnitFilterBlockVec::exec_generic_impl(
double *,
const double *
const,
const std::uint32_t *
const,
const Index,
const bool,
const bool,
const int);
101#define KERNEL_LAFEM_ARCH_UNIT_FILTER_BLOCK_VEC_HPP 1
102#include <kernel/lafem/arch/unit_filter_block_vec_generic.hpp>
#define XABORTM(msg)
Abortion macro definition with custom message.
std::uint64_t Index
Index data type.