FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
scale_row_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_ * r, const DT_ * const a, const IT_ * const col_idx, const IT_ * const row_ptr, const DT_ * const x, const Index rows, const Index cols, const Index nonzeros);
19
20 template <typename DT_, typename IT_>
21 static void exec_generic(Memory::Arbiter& r, const Memory::Arbiter& a, const Memory::Arbiter& col_idx, const Memory::Arbiter& row_ptr, const Memory::Arbiter& x, const Index rows, const Index cols, const Index nonzeros)
22 {
28 exec_generic_impl(r_view.get_w(), a_view.get_r(), ci_view.get_r(), rp_view.get_r(), x_view.get_r(), rows, cols, nonzeros);
29 }
30
31 template <typename DT_, typename IT_>
32 static void exec_cuda_impl(DT_ * r, const DT_ * const a, const IT_ * const col_idx, const IT_ * const row_ptr, const DT_ * const x, const Index rows, const Index, const Index);
33
34 template <typename DT_, typename IT_>
35 static void exec_cuda(Memory::Arbiter& r, const Memory::Arbiter& a, const Memory::Arbiter& col_idx, const Memory::Arbiter& row_ptr, const Memory::Arbiter& x, const Index rows, const Index cols, const Index nonzeros)
36 {
42 exec_cuda_impl(r_view.get_w(), a_view.get_r(), ci_view.get_r(), rp_view.get_r(), x_view.get_r(), rows, cols, nonzeros);
43 }
44
45 template <typename DT_, typename IT_>
46 static void exec(Memory::Arbiter& r, const Memory::Arbiter& a, const Memory::Arbiter& col_idx, const Memory::Arbiter& row_ptr, const Memory::Arbiter& x, const Index rows, const Index cols, const Index nonzeros)
47 {
49 {
51 exec_generic<DT_, IT_>(r, a, col_idx, row_ptr, x, rows, cols, nonzeros);
52 break;
53
55#ifdef FEAT_HAVE_MKL
56 Backend::warn_missing("LAFEM::Arch::ScaleRowCSR::exec");
57 exec_generic<DT_, IT_>(r, a, col_idx, row_ptr, x, rows, cols, nonzeros);
58#else
59 XABORTM("LAFEM::Arch::ScaleRowCSR::exec: MKL backend not available!");
60#endif
61 break;
62
64#ifdef FEAT_HAVE_CUDA
65 exec_cuda<DT_, IT_>(r, a, col_idx, row_ptr, x, rows, cols, nonzeros);
66#else
67 XABORTM("LAFEM::Arch::ScaleRowCSR::exec: CUDA backend not available!");
68#endif
69 break;
70
71 default:
72 XABORTM("LAFEM::Arch::ScaleRowCSR::exec: unknown backend!");
73 break;
74 }
75 }
76 };
77
78#ifdef FEAT_EICKT
79 extern template void ScaleRowCSR::exec_generic_impl(float *, const float * const, const std::uint64_t * const, const std::uint64_t * const, const float * const, const Index, const Index, const Index);
80 extern template void ScaleRowCSR::exec_generic_impl(double *, const double * const, const std::uint64_t * const, const std::uint64_t * const, const double * const, const Index, const Index, const Index);
81 extern template void ScaleRowCSR::exec_generic_impl(float *, const float * const, const std::uint32_t * const, const std::uint32_t * const, const float * const, const Index, const Index, const Index);
82 extern template void ScaleRowCSR::exec_generic_impl(double *, const double * const, const std::uint32_t * const, const std::uint32_t * const, const double * const, const Index, const Index, const Index);
83#endif
84} // namespace FEAT::LAFEM::Arch
85
86#ifndef __CUDACC__
87#define KERNEL_LAFEM_ARCH_SCALE_ROW_CSR_HPP 1
88#include <kernel/lafem/arch/scale_row_csr_generic.hpp>
89#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.
@ overlap
explicitly allow overlapping writes (see Overlapping Memory Views)
@ read
read-only access
@ write
write-only access (see attention note above)
std::uint64_t Index
Index data type.