FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
slip_filter_block.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 SlipFilterBlock
17 {
18 template <typename DT_, typename IT_>
19 static void exec_generic_impl(DT_ * v, const DT_ * const f_nu, const IT_ * const f_idx, const Index f_nzes, const int bs);
20
21 template <typename DT_, typename IT_>
22 static void exec_cuda_impl(DT_ * v, const DT_ * const f_nu, const IT_ * const f_idx, const Index f_nzes, const int bs);
23
24 template <typename DT_, typename IT_, int block_size_>
25 static void exec_generic(Memory::Arbiter& v, const Memory::Arbiter& f_nu, const Memory::Arbiter& f_idx, const Index f_nzes)
26 {
27 Memory::TypedView<DT_> v_view(v.view(Memory::Location::main, Memory::Access::read_write));
28 Memory::TypedView<DT_> n_view(f_nu.view(Memory::Location::main, Memory::Access::read));
29 Memory::TypedView<IT_> i_view(f_idx.view(Memory::Location::main, Memory::Access::read));
30 exec_generic_impl(v_view.get_w(), n_view.get_r(), i_view.get_r(), f_nzes, block_size_);
31 }
32
33 template <typename DT_, typename IT_, int block_size_>
34 static void exec_cuda(Memory::Arbiter& v, const Memory::Arbiter& f_nu, const Memory::Arbiter& f_idx, const Index f_nzes)
35 {
36 Memory::TypedView<DT_> v_view(v.view(Memory::Location::cuda, Memory::Access::read_write));
37 Memory::TypedView<DT_> n_view(f_nu.view(Memory::Location::cuda, Memory::Access::read));
38 Memory::TypedView<IT_> i_view(f_idx.view(Memory::Location::cuda, Memory::Access::read));
39 exec_cuda_impl(v_view.get_w(), n_view.get_r(), i_view.get_r(), f_nzes, block_size_);
40 }
41
42 template <typename DT_, typename IT_, int block_size_>
43 static void exec(Memory::Arbiter& v, const Memory::Arbiter& f_nu, const Memory::Arbiter& f_idx, const Index f_nzes)
44 {
45 switch(Backend::get_preferred_backend())
46 {
47 case PreferredBackend::generic:
48 exec_generic<DT_, IT_, block_size_>(v, f_nu, f_idx, f_nzes);
49 break;
50
51 case PreferredBackend::mkl:
52#ifdef FEAT_HAVE_MKL
53 Backend::warn_missing("LAFEM::Arch::SlipFilterBlock::exec");
54 exec_generic<DT_, IT_, block_size_>(v, f_nu, f_idx, f_nzes);
55#else
56 XABORTM("LAFEM::Arch::SlipFilterBlock::exec: MKL backend not available!");
57#endif
58 break;
59
60 case PreferredBackend::cuda:
61#ifdef FEAT_HAVE_CUDA
62 exec_cuda<DT_, IT_, block_size_>(v, f_nu, f_idx, f_nzes);
63#else
64 XABORTM("LAFEM::Arch::SlipFilterBlock::exec: CUDA backend not available!");
65#endif
66 break;
67
68 default:
69 XABORTM("LAFEM::Arch::SlipFilterBlock::exec: unknown backend!");
70 break;
71 }
72 }
73 }; // SlipFilterBlock
74
75#ifdef FEAT_EICKT
76 extern template void SlipFilterBlock::exec_generic_impl<float, std::uint64_t>(float * v, const float * const f_nu, const std::uint64_t * const f_idx, const Index f_nzes, const int bs);
77 extern template void SlipFilterBlock::exec_generic_impl<double, std::uint64_t>(double * v, const double * const f_nu, const std::uint64_t * const f_idx, const Index f_nzes, const int bs);
78 extern template void SlipFilterBlock::exec_generic_impl<float, std::uint32_t>(float * v, const float * const f_nu, const std::uint32_t * const f_idx, const Index f_nzes, const int bs);
79 extern template void SlipFilterBlock::exec_generic_impl<double, std::uint32_t>(double * v, const double * const f_nu, const std::uint32_t * const f_idx, const Index f_nzes, const int bs);
80#endif
81} // namespace FEAT::LAFEM::Arch
82
84#ifndef __CUDACC__
85#define KERNEL_LAFEM_ARCH_SLIP_FILTER_BLOCK_HPP 1
86#include <kernel/lafem/arch/slip_filter_block_generic.hpp>
87#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.