FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
component_invert_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_>
19 static void exec_generic_impl(DT_* r, const DT_* const x, const DT_ alpha, const Index size);
20
21 template<typename DT_>
22 static void exec_cuda_impl(DT_* r, const DT_* const x, const DT_ alpha, const Index size);
23
24 template <typename DT_>
25 static void exec_generic(Memory::Arbiter& r, const Memory::Arbiter& x, const DT_ alpha, const Index size)
26 {
29 exec_generic_impl(r_view.get_w(), x_view.get_r(), alpha, size);
30 }
31
32 template <typename DT_>
33 static void exec_cuda(Memory::Arbiter& r, const Memory::Arbiter& x, const DT_ alpha, const Index size)
34 {
37 exec_cuda_impl(r_view.get_w(), x_view.get_r(), alpha, size);
38 }
39
40 template <typename DT_>
41 static void exec(Memory::Arbiter& r, const Memory::Arbiter& x, const DT_ alpha, const Index size)
42 {
44 {
46 exec_generic<DT_>(r, x, alpha, size);
47 break;
48
50#ifdef FEAT_HAVE_MKL
51 Backend::warn_missing("LAFEM::Arch::ComponentInvertDense::exec");
52 exec_generic<DT_>(r, x, alpha, size);
53#else
54 XABORTM("LAFEM::Arch::ComponentInvertDense::exec: MKL backend not available!");
55#endif
56 break;
57
59#ifdef FEAT_HAVE_CUDA
60 exec_cuda<DT_>(r, x, alpha, size);
61#else
62 XABORTM("LAFEM::Arch::ComponentInvertDense::exec: CUDA backend not available!");
63#endif
64 break;
65
66 default:
67 XABORTM("LAFEM::Arch::ComponentInvertDense::exec: unknown backend!");
68 break;
69 }
70 }
71 };
72
73#ifdef FEAT_EICKT
74 extern template void ComponentInvertDense::exec_generic_impl(float*, const float* const, const float, const Index);
75 extern template void ComponentInvertDense::exec_generic_impl(double*, const double* const, const double, const Index);
76#endif
77} // namespace FEAT
78
79#ifndef __CUDACC__
80#define KERNEL_LAFEM_ARCH_COMPONENT_INVERT_DENSE_HPP 1
81#include <kernel/lafem/arch/component_invert_dense_generic.hpp>
82#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.
for 0 <= i < n: r[i] <- alpha / x[i]