FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
copy_stride.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 int stride_r, const int comp_r, const int stride_x, const int comp_x, const Index count);
20
21 static void exec_mkl_impl(float * r, const float * const x, const int stride_r, const int comp_r, const int stride_x, const int comp_x, const Index count);
22 static void exec_mkl_impl(double * r, const double * const x, const int stride_r, const int comp_r, const int stride_x, const int comp_x, const Index count);
23
24 template <typename DT_>
25 static void exec_mkl_impl(DT_ *, const DT_ * const, const int, const int, const int, const int, const Index)
26 {
27 XABORTM("LAFEM::Arch::CopyStride::exec_mkl_impl: MKL backend not available!");
28 }
29
30 template <typename DT_>
31 static void exec_cuda_impl(DT_ * r, const DT_ * const x, const int stride_r, const int comp_r, const int stride_x, const int comp_x, const Index count);
32
33 template <typename DT_>
34 static void exec_generic(Memory::Arbiter& r, const Memory::Arbiter& x, const int stride_r, const int comp_r, const int stride_x, const int comp_x, const Index count)
35 {
38 exec_generic_impl(r_view.get_w(), x_view.get_r(), stride_r, comp_r, stride_x, comp_x, count);
39 }
40
41 template <typename DT_>
42 static void exec_mkl(Memory::Arbiter& r, const Memory::Arbiter& x, const int stride_r, const int comp_r, const int stride_x, const int comp_x, const Index count)
43 {
46 exec_mkl_impl(r_view.get_w(), x_view.get_r(), stride_r, comp_r, stride_x, comp_x, count);
47 }
48
49 template <typename DT_>
50 static void exec_cuda(Memory::Arbiter& r, const Memory::Arbiter& x, const int stride_r, const int comp_r, const int stride_x, const int comp_x, const Index count)
51 {
54 exec_cuda_impl(r_view.get_w(), x_view.get_r(), stride_r, comp_r, stride_x, comp_x, count);
55 }
56
57 template <typename DT_>
58 static void exec(Memory::Arbiter& r, const Memory::Arbiter& x, const int stride_r, const int comp_r, const int stride_x, const int comp_x, const Index count)
59 {
60 XASSERT(r != x);
61 XASSERT(comp_r < stride_r);
62 XASSERT(comp_x < stride_x);
63
65 {
67 exec_generic<DT_>(r, x, stride_r, comp_r, stride_x, comp_x, count);
68 break;
69
71#ifdef FEAT_HAVE_MKL
72 exec_mkl<DT_>(r, x, stride_r, comp_r, stride_x, comp_x, count);
73#else
74 XABORTM("LAFEM::Arch::CopyStride::exec: MKL backend not available!");
75#endif
76 break;
77
79#ifdef FEAT_HAVE_CUDA
80 exec_cuda<DT_>(r, x, stride_r, comp_r, stride_x, comp_x, count);
81#else
82 XABORTM("LAFEM::Arch::CopyStride::exec: CUDA backend not available!");
83#endif
84 break;
85
86 default:
87 XABORTM("LAFEM::Arch::CopyStride::exec: unknown backend!");
88 break;
89 }
90 }
91 };
92
93#ifdef FEAT_EICKT
94 extern template void CopyStride::exec_generic_impl(float *, const float * const, const int, const int, const int, const int, const Index);
95 extern template void CopyStride::exec_generic_impl(double *, const double * const, const int, const int, const int, const int, const Index);
96#endif
97} // namespace FEAT::LAFEM::Arch
98
99#ifndef __CUDACC__
100#define KERNEL_LAFEM_ARCH_COPY_STRIDE_HPP 1
101#include <kernel/lafem/arch/copy_stride_generic.hpp>
102#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
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
@ 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*stride_r + comp_r] <- x[i*stride_x + comp_x]
Definition: copy_stride.hpp:17