10#include <kernel/backend.hpp>
11#include <kernel/util/memory_arbiter.hpp>
14namespace FEAT::LAFEM::Arch
16 struct UnitFilterDenseWeakCSR
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);
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);
24 template<
typename DT_,
typename IT_>
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)
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);
35 template<
typename DT_,
typename IT_>
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)
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);
46 template<
typename DT_,
typename IT_>
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)
49 switch(Backend::get_preferred_backend())
51 case PreferredBackend::generic:
52 exec_generic<DT_, IT_>(mat_a, mat_m, row_ptr, f_val, f_idx, f_nzes);
55 case PreferredBackend::mkl:
57 Backend::warn_missing(
"LAFEM::Arch::UnitFilterDenseWeakCSR::exec");
58 exec_generic<DT_, IT_>(mat_a, mat_m, row_ptr, f_val, f_idx, f_nzes);
60 XABORTM(
"LAFEM::Arch::UnitFilterDenseWeakCSR::exec: MKL backend not available!");
64 case PreferredBackend::cuda:
66 exec_cuda<DT_, IT_>(mat_a, mat_m, row_ptr, f_val, f_idx, f_nzes);
68 XABORTM(
"LAFEM::Arch::UnitFilterDenseWeakCSR::exec: CUDA backend not available!");
73 XABORTM(
"LAFEM::Arch::UnitFilterDenseWeakCSR::exec: unknown backend!");
80 extern template void UnitFilterDenseWeakCSR::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);
81 extern template void UnitFilterDenseWeakCSR::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);
82 extern template void UnitFilterDenseWeakCSR::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);
83 extern template void UnitFilterDenseWeakCSR::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);
89#define KERNEL_LAFEM_ARCH_UNIT_FILTER_DENSE_WEAK_CSR_HPP 1
90#include <kernel/lafem/arch/unit_filter_dense_weak_csr_generic.hpp>
#define XABORTM(msg)
Abortion macro definition with custom message.
std::uint64_t Index
Index data type.