FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
row_norm2_csr.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, const IT_* const row_ptr, const Index rows, const bool squared);
19
20 template <typename DT_, typename IT_>
21 static void exec_generic(Memory::Arbiter& row_norms, const Memory::Arbiter& a, const Memory::Arbiter& col_idx, const Memory::Arbiter& row_ptr, const Index rows, const bool squared)
22 {
27 exec_generic_impl(r_view.get_w(), a_view.get_r(), ci_view.get_r(), rp_view.get_r(), rows, squared);
28 }
29
30 template <typename DT_, typename IT_>
31 static void exec_cuda_impl(DT_ * row_norms, const DT_ * const a, const IT_ * const col_idx, const IT_ * const row_ptr, const Index rows, const bool squared);
32
33 template <typename DT_, typename IT_>
34 static void exec_cuda(Memory::Arbiter& row_norms, const Memory::Arbiter& a, const Memory::Arbiter& col_idx, const Memory::Arbiter& row_ptr, const Index rows, const bool squared)
35 {
40 exec_cuda_impl(r_view.get_w(), a_view.get_r(), ci_view.get_r(), rp_view.get_r(), rows, squared);
41 }
42
43 template <typename DT_, typename IT_>
44 static void exec(Memory::Arbiter& row_norms, const Memory::Arbiter& a, const Memory::Arbiter& col_idx, const Memory::Arbiter& row_ptr, const Index rows, const bool squared)
45 {
47 {
49 exec_generic<DT_, IT_>(row_norms, a, col_idx, row_ptr, rows, squared);
50 break;
51
53#ifdef FEAT_HAVE_MKL
54 Backend::warn_missing("LAFEM::Arch::RowNorm2CSR::exec");
55 exec_generic<DT_, IT_>(row_norms, a, col_idx, row_ptr, rows, squared);
56#else
57 XABORTM("LAFEM::Arch::RowNorm2CSR::exec: MKL backend not available!");
58#endif
59 break;
60
62#ifdef FEAT_HAVE_CUDA
63 exec_cuda<DT_, IT_>(row_norms, a, col_idx, row_ptr, rows, squared);
64#else
65 XABORTM("LAFEM::Arch::RowNorm2CSR::exec: CUDA backend not available!");
66#endif
67 break;
68
69 default:
70 XABORTM("LAFEM::Arch::RowNorm2CSR::exec: unknown backend!");
71 break;
72 }
73 }
74 };
75
76#ifdef FEAT_EICKT
77 extern template void RowNorm2CSR::exec_generic_impl(float*, const float* const, const Index* const, const Index * const, const Index, const bool);
78 extern template void RowNorm2CSR::exec_generic_impl(double*, const double* const, const Index* const, const Index* const, const Index, const bool);
79#endif
80} // namespace FEAT::LAFEM::Arch
81
82#ifndef __CUDACC__
83#define KERNEL_LAFEM_ARCH_ROW_NORM2_CSR_HPP 1
84#include <kernel/lafem/arch/row_norm2_csr_generic.hpp>
85#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.