FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
unit_filter_block_weak_bcsr.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
8// includes, FEAT
10#include <kernel/backend.hpp>
11#include <kernel/util/memory_arbiter.hpp>
12
14namespace FEAT::LAFEM::Arch
15{
16 struct UnitFilterBlockWeakBCSR
17 {
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);
20
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);
23
24 template<typename DT_, typename IT_, int block_height_, int block_width_>
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)
26 {
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_);
33 }
34
35 template<typename DT_, typename IT_, int block_height_, int block_width_>
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)
37 {
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_);
44 }
45
46 template<typename DT_, typename IT_, int block_height_, int block_width_>
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)
48 {
49 switch(Backend::get_preferred_backend())
50 {
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);
53 break;
54
55 case PreferredBackend::mkl:
56#ifdef FEAT_HAVE_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);
59#else
60 XABORTM("LAFEM::Arch::UnitFilterBlockWeakBCSR::exec: MKL backend not available!");
61#endif
62 break;
63
64 case PreferredBackend::cuda:
65#ifdef FEAT_HAVE_CUDA
66 exec_cuda<DT_, IT_, block_height_, block_width_>(mat_a, mat_m, row_ptr, f_val, f_idx, f_nzes, ign_nans);
67#else
68 XABORTM("LAFEM::Arch::UnitFilterBlockWeakBCSR::exec: CUDA backend not available!");
69#endif
70 break;
71
72 default:
73 XABORTM("LAFEM::Arch::UnitFilterBlockWeakBCSR::exec: unknown backend!");
74 break;
75 }
76 }
77 }; // struct UnitFilterBlockWeakBCSR
78
79#ifdef FEAT_EICKT
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);
84#endif
85} // namespace FEAT::LAFEM::Arch
87
88#ifndef __CUDACC__
89#define KERNEL_LAFEM_ARCH_UNIT_FILTER_BLOCK_WEAK_BCSR_HPP 1
90#include <kernel/lafem/arch/unit_filter_block_weak_bcsr_generic.hpp>
91#endif
#define XABORTM(msg)
Abortion macro definition with custom message.
Definition: assertion.hpp:192
FEAT Kernel base header.
std::uint64_t Index
Index data type.