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