FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
row_norm2_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
13namespace FEAT::LAFEM::Arch
14{
16 {
17 template <typename DT_, typename IT_>
18 static void exec_generic_impl(DT_* row_norms, const DT_* const a, const IT_* const col_idx,
19 const IT_ * const row_ptr, const Index rows, const int bh, const int bw, const bool squared);
20
21 template <typename DT_, typename IT_>
22 static void exec_generic(Memory::Arbiter& row_norms, const Memory::Arbiter& a, const Memory::Arbiter& col_idx,
23 const Memory::Arbiter&row_ptr, const Index rows, const int bh, const int bw, const bool squared)
24 {
29 exec_generic_impl(r_view.get_w(), a_view.get_r(), ci_view.get_r(), rp_view.get_r(), rows, bh, bw, squared);
30 }
31
32 template <typename DT_, typename IT_>
33 static void exec_cuda_impl(DT_* row_norms, const DT_* const a, const IT_* const col_idx,
34 const IT_* const row_ptr, const Index rows, const int bh, const int bw, const bool squared);
35
36 template <typename DT_, typename IT_>
37 static void exec_cuda(Memory::Arbiter& row_norms, const Memory::Arbiter& a, const Memory::Arbiter& col_idx,
38 const Memory::Arbiter&row_ptr, const Index rows, const int bh, const int bw, const bool squared)
39 {
44 exec_cuda_impl(r_view.get_w(), a_view.get_r(), ci_view.get_r(), rp_view.get_r(), rows, bh, bw, squared);
45 }
46
47 template <typename DT_, typename IT_>
48 static void exec(Memory::Arbiter& row_norms, const Memory::Arbiter& a, const Memory::Arbiter& col_idx,
49 const Memory::Arbiter& row_ptr, const Index rows, const int bh, const int bw, const bool squared)
50 {
52 {
54 exec_generic<DT_, IT_>(row_norms, a, col_idx, row_ptr, rows, bh, bw, squared);
55 break;
56
58#ifdef FEAT_HAVE_MKL
59 Backend::warn_missing("LAFEM::Arch::RowNorm2BCSR::exec");
60 exec_generic<DT_, IT_>(row_norms, a, col_idx, row_ptr, rows, bh, bw, squared);
61#else
62 XABORTM("LAFEM::Arch::RowNorm2BCSR::exec: MKL backend not available!");
63#endif
64 break;
65
67#ifdef FEAT_HAVE_CUDA
68 exec_cuda<DT_, IT_>(row_norms, a, col_idx, row_ptr, rows, bh, bw, squared);
69#else
70 XABORTM("LAFEM::Arch::RowNorm2BCSR::exec: CUDA backend not available!");
71#endif
72 break;
73
74 default:
75 XABORTM("LAFEM::Arch::RowNorm2BCSR::exec: unknown backend!");
76 break;
77 }
78 }
79 }; // struct RowNorm2BCSR
80
81#ifdef FEAT_EICKT
82 extern template void RowNorm2BCSR::exec_generic_impl(float*, const float* const, const Index* const, const Index * const, const Index, const int, const int, const bool);
83 extern template void RowNorm2BCSR::exec_generic_impl(double*, const double* const, const Index* const, const Index* const, const Index, const int, const int, const bool);
84#endif
85} // namespace FEAT::LAFEM::Arch
86
87#ifndef __CUDACC__
88#define KERNEL_LAFEM_ARCH_ROW_NORM2_BCSR_HPP 1
89#include <kernel/lafem/arch/row_norm2_bcsr_generic.hpp>
90#endif
#define XABORTM(msg)
Abortion macro definition with custom message.
Definition: assertion.hpp:192
FEAT Kernel base header.
static PreferredBackend get_preferred_backend()
get current preferred backend
Definition: backend.cpp:32
static void warn_missing(const char *operation, PreferredBackend preferred_backend, PreferredBackend fallback_backend=PreferredBackend::generic)
issues a warning about unsupported backend usage
Definition: backend.cpp:77
Memory arbiter class.
Typed memory view class.
const T_ * get_r() const
Returns a const typed pointer to the array that grants read access.
T_ * get_w()
Returns a typed pointer to the array that grants write (and read) access.
@ read
read-only access
@ write
write-only access (see attention note above)
std::uint64_t Index
Index data type.