FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
scale_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{
16 {
17 template <typename DT_>
18 static void exec_generic_impl(DT_ * r, const DT_ * const x, const DT_ alpha, const Index size);
19
20 static void exec_mkl_impl(float * r, const float * const x, const float, const Index size);
21 static void exec_mkl_impl(double * r, const double * const x, const double, const Index size);
22
23 template <typename DT_>
24 static void exec_mkl_impl(DT_ *, const DT_ * const, const DT_, const Index)
25 {
26 XABORTM("LAFEM::Arch::ScaleDense::exec_mkl_impl: MKL backend not available!");
27 }
28
29 template <typename DT_>
30 static void exec_cuda_impl(DT_ * r, const DT_ * const x, const DT_ alpha, const Index size);
31
32 template<typename DT_>
33 static void exec_generic(Memory::Arbiter& r, const Memory::Arbiter& x, const DT_ alpha, const Index size)
34 {
37 exec_generic_impl(r_view.get_w(), x_view.get_r(), alpha, size);
38 }
39
40 template<typename DT_>
41 static void exec_mkl(Memory::Arbiter& r, const Memory::Arbiter& x, const DT_ alpha, const Index size)
42 {
45 exec_mkl_impl(r_view.get_w(), x_view.get_r(), alpha, size);
46 }
47
48 template<typename DT_>
49 static void exec_cuda(Memory::Arbiter& r, const Memory::Arbiter& x, const DT_ alpha, const Index size)
50 {
53 exec_cuda_impl(r_view.get_w(), x_view.get_r(), alpha, size);
54 }
55
56 template<typename DT_>
57 static void exec(Memory::Arbiter& r, const Memory::Arbiter& x, const DT_ alpha, const Index size)
58 {
60 {
62 exec_generic<DT_>(r, x, alpha, size);
63 break;
64
66#ifdef FEAT_HAVE_MKL
67 exec_mkl<DT_>(r, x, alpha, size);
68#else
69 XABORTM("LAFEM::Arch::ScaleDense::exec: MKL backend not available!");
70#endif
71 break;
72
74#ifdef FEAT_HAVE_CUDA
75 exec_cuda<DT_>(r, x, alpha, size);
76#else
77 XABORTM("LAFEM::Arch::ScaleDense::exec: CUDA backend not available!");
78#endif
79 break;
80
81 default:
82 XABORTM("LAFEM::Arch::ScaleDense::exec: unknown backend!");
83 break;
84 }
85 }
86 };
87
88#ifdef FEAT_EICKT
89 extern template void ScaleDense::exec_generic_impl(float *, const float * const, const float, const Index);
90 extern template void ScaleDense::exec_generic_impl(double *, const double * const, const double, const Index);
91#endif
92
93} // namespace FEAT::LAFEM::Arch
94
95#ifndef __CUDACC__
96#define KERNEL_LAFEM_ARCH_SCALE_DENSE_HPP 1
97#include <kernel/lafem/arch/scale_dense_generic.hpp>
98#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
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.