FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
axpy_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 struct AxpyDense
17 {
18 template <typename DT_>
19 static void exec_generic_impl(DT_ * r, const DT_ alpha, const DT_ * const x, const Index size);
20
21 static void exec_mkl_impl(float * r, const float alpha, const float * const x, const Index size);
22 static void exec_mkl_impl(double * r, const double alpha, const double * const x, const Index size);
23
24 template <typename DT_>
25 static void exec_mkl_impl(DT_ *, const DT_, const DT_ * const, const Index)
26 {
27 XABORTM("LAFEM::Arch::AxpyDense::exec_mkl_impl: MKL backend not available!");
28 }
29
30 template <typename DT_>
31 static void exec_cuda_impl(DT_ * r, const DT_ alpha, const DT_ * const x, const Index size);
32
33 template<typename DT_>
34 static void exec_generic(Memory::Arbiter& r, const DT_ alpha, const Memory::Arbiter& x, const Index size)
35 {
38 exec_generic_impl(r_view.get_w(), alpha, x_view.get_r(), size);
39 }
40
41 template<typename DT_>
42 static void exec_mkl(Memory::Arbiter& r, const DT_ alpha, const Memory::Arbiter& x, const Index size)
43 {
46 exec_mkl_impl(r_view.get_w(), alpha, x_view.get_r(), size);
47 }
48
49 template<typename DT_>
50 static void exec_cuda(Memory::Arbiter& r, const DT_ alpha, const Memory::Arbiter& x, const Index size)
51 {
54 exec_cuda_impl(r_view.get_w(), alpha, x_view.get_r(), size);
55 }
56
57 template<typename DT_>
58 static void exec(Memory::Arbiter& r, const DT_ alpha, const Memory::Arbiter& x, const Index size)
59 {
61 {
63 exec_generic<DT_>(r, alpha, x, size);
64 break;
65
67#ifdef FEAT_HAVE_MKL
68 exec_mkl<DT_>(r, alpha, x, size);
69#else
70 XABORTM("LAFEM::Arch::AxpyDense::exec: MKL backend not available!");
71#endif
72 break;
73
75#ifdef FEAT_HAVE_CUDA
76 exec_cuda<DT_>(r, alpha, x, size);
77#else
78 XABORTM("LAFEM::Arch::AxpyDense::exec: CUDA backend not available!");
79#endif
80 break;
81
82 default:
83 XABORTM("LAFEM::Arch::AxpyDense::exec: unknown backend!");
84 break;
85 }
86 }
87 }; // struct AxpyDense
88
89#ifdef FEAT_EICKT
90 extern template void AxpyDense::exec_generic_impl(float *, const float, const float * const, const Index);
91 extern template void AxpyDense::exec_generic_impl(double *, const double, const double * const, const Index);
92#endif
93} // namespace FEAT::LAFEM::Arch
94
95#ifndef __CUDACC__
96#define KERNEL_LAFEM_ARCH_AXPY_DENSE_HPP 1
97#include <kernel/lafem/arch/axpy_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.
@ read_write
read-write access
@ overlap
explicitly allow overlapping writes (see Overlapping Memory Views)
@ read
read-only access
std::uint64_t Index
Index data type.
for 0 <= i < n: r[i] <- r[i] + alpha*x[i]
Definition: axpy_dense.hpp:17