FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
matvecmult_banded_dense.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{
17 {
18 template <typename DT_, typename IT_>
19 static void exec_generic_impl(DT_ * r, const DT_ alpha, const DT_ * const x, const DT_ * const y, const DT_ * const val,
20 const IT_ * const offsets, const Index bands, const Index rows, const Index cols);
21
22 template <typename DT_, typename IT_>
23 static void exec_cuda_impl(DT_ * r, const DT_ alpha, const DT_ * const x, const DT_ * const y, const DT_ * const val, const IT_ * const offsets, const Index bands, const Index rows, const Index cols);
24
25 template <typename DT_, typename IT_>
26 static void exec_generic(Memory::Arbiter& r, const DT_ alpha, const Memory::Arbiter& x, const Memory::Arbiter& y, const Memory::Arbiter& a, const Memory::Arbiter& offsets, const Index bands, const Index rows, const Index cols)
27 {
32 if(y)
33 {
35 exec_generic_impl(r_view.get_w(), alpha, x_view.get_r(), y_view.get_r(), a_view.get_r(),
36 o_view.get_r(), bands, rows, cols);
37 }
38 else
39 {
40 exec_generic_impl(r_view.get_w(), alpha, x_view.get_r(), (DT_*)nullptr, a_view.get_r(),
41 o_view.get_r(), bands, rows, cols);
42 }
43 }
44
45 template <typename DT_, typename IT_>
46 static void exec_cuda(Memory::Arbiter& r, const DT_ alpha, const Memory::Arbiter& x, const Memory::Arbiter& y, const Memory::Arbiter& a, const Memory::Arbiter& offsets, const Index bands, const Index rows, const Index cols)
47 {
52 if(y)
53 {
55 exec_cuda_impl(r_view.get_w(), alpha, x_view.get_r(), y_view.get_r(), a_view.get_r(),
56 o_view.get_r(), bands, rows, cols);
57 }
58 else
59 {
60 exec_cuda_impl(r_view.get_w(), alpha, x_view.get_r(), (DT_*)nullptr, a_view.get_r(),
61 o_view.get_r(), bands, rows, cols);
62 }
63 }
64
65 template <typename DT_, typename IT_>
66 static void exec(Memory::Arbiter& r, const DT_ alpha, const Memory::Arbiter& x, const Memory::Arbiter& y, const Memory::Arbiter& a, const Memory::Arbiter& offsets, const Index bands, const Index rows, const Index cols)
67 {
68 XASSERT(r != x);
69
71 {
73 exec_generic<DT_, IT_>(r, alpha, x, y, a, offsets, bands, rows, cols);
74 break;
75
77#ifdef FEAT_HAVE_MKL
78 Backend::warn_missing("LAFEM::Arch::MatVecMultBandedDense::exec");
79 exec_generic<DT_, IT_>(r, alpha, x, y, a, offsets, bands, rows, cols);
80#else
81 XABORTM("LAFEM::Arch::MatVecMultBandedDense::exec: MKL backend not available!");
82#endif
83 break;
84
86#ifdef FEAT_HAVE_CUDA
87 exec_cuda<DT_, IT_>(r, alpha, x, y, a, offsets, bands, rows, cols);
88#else
89 XABORTM("LAFEM::Arch::MatVecMultBandedDense::exec: CUDA backend not available!");
90#endif
91 break;
92
93 default:
94 XABORTM("LAFEM::Arch::MatVecMultBandedDense::exec: unknown backend!");
95 break;
96 }
97 }
98 }; // struct MatVecMultBandedDense
99
100#ifdef FEAT_EICKT
101 extern template void MatVecMultBandedDense::exec_generic_impl(float *, const float, const float * const, const float * const, const float * const, const std::uint64_t * const, const Index, const Index, const Index);
102 extern template void MatVecMultBandedDense::exec_generic_impl(float *, const float, const float * const, const float * const, const float * const, const std::uint32_t * const, const Index, const Index, const Index);
103 extern template void MatVecMultBandedDense::exec_generic_impl(double *, const double, const double * const, const double * const, const double * const, const std::uint64_t * const, const Index, const Index, const Index);
104 extern template void MatVecMultBandedDense::exec_generic_impl(double *, const double, const double * const, const double * const, const double * const, const std::uint32_t * const, const Index, const Index, const Index);
105#endif
106
107} // namespace FEAT::LAFEM::Arch
108
109#ifndef __CUDACC__
110#define KERNEL_LAFEM_ARCH_MATVECMULT_BANDED_DENSE_HPP 1
111#include <kernel/lafem/arch/matvecmult_banded_dense_generic.hpp>
112#endif
#define XABORTM(msg)
Abortion macro definition with custom message.
Definition: assertion.hpp:192
#define XASSERT(expr)
Assertion macro definition.
Definition: assertion.hpp:262
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.
View view(Location mem_loc, Access access)
Maps a raw view to a memory block.
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.
r[i] <- y[i] + alpha * sum_{j=0..n-1} A[i][j] * x[j]