FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
transpose_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 Index rows_x, const Index cols_x);
19
20 static void exec_mkl_impl(float * r, const float * const x, const Index rows_x, const Index cols_x);
21 static void exec_mkl_impl(double * r, const double * const x, const Index rows_x, const Index cols_x);
22
23 template <typename DT_>
24 static void exec_mkl_impl(DT_ *, const DT_ * const, const Index, const Index)
25 {
26 XABORTM("LAFEM::Arch::TransposeDense::exec_mkl_impl: MKL backend not available!");
27 }
28
29 static void exec_cuda_impl(float * r, const float * const x, const Index rows_x, const Index cols_x);
30 static void exec_cuda_impl(double * r, const double * const x, const Index rows_x, const Index cols_x);
31
32 template <typename DT_>
33 static void exec_cuda_impl(DT_ *, const DT_ * const, const Index, const Index)
34 {
35 XABORTM("LAFEM::Arch::TransposeDense::exec_cuda_impl: CUDA backend not available!");
36 }
37
38 template <typename DT_>
39 static void exec_generic(Memory::Arbiter& r, const Memory::Arbiter& x, const Index rows_x, const Index cols_x)
40 {
43 exec_generic_impl(r_view.get_w(), x_view.get_r(), rows_x, cols_x);
44 }
45
46 template <typename DT_>
47 static void exec_mkl(Memory::Arbiter& r, const Memory::Arbiter& x, const Index rows_x, const Index cols_x)
48 {
51 exec_mkl_impl(r_view.get_w(), x_view.get_r(), rows_x, cols_x);
52 }
53
54 template <typename DT_>
55 static void exec_cuda(Memory::Arbiter& r, const Memory::Arbiter& x, const Index rows_x, const Index cols_x)
56 {
59 exec_cuda_impl(r_view.get_w(), x_view.get_r(), rows_x, cols_x);
60 }
61
62 template <typename DT_>
63 static void exec(Memory::Arbiter& r, const Memory::Arbiter& x, const Index rows_x, const Index cols_x)
64 {
65 XASSERT(r != x);
66
68 {
70 exec_generic<DT_>(r, x, rows_x, cols_x);
71 break;
72
74#ifdef FEAT_HAVE_MKL
75 exec_mkl<DT_>(r, x, rows_x, cols_x);
76#else
77 XABORTM("LAFEM::Arch::TransposeDense::exec: MKL backend not available!");
78#endif
79 break;
80
82#ifdef FEAT_HAVE_CUDA
83 exec_cuda<DT_>(r, x, rows_x, cols_x);
84#else
85 XABORTM("LAFEM::Arch::TransposeDense::exec: CUDA backend not available!");
86#endif
87 break;
88
89 default:
90 XABORTM("LAFEM::Arch::TransposeDense::exec: unknown backend!");
91 break;
92 }
93 }
94 }; // struct TransposeDense
95
96#ifdef FEAT_EICKT
97 extern template void TransposeDense::exec_generic_impl(float *, const float * const, const Index, const Index);
98 extern template void TransposeDense::exec_generic_impl(double *, const double * const, const Index, const Index);
99#endif
100
101} // namespace FEAT::LAFEM::Arch
102
103#ifndef __CUDACC__
104#define KERNEL_LAFEM_ARCH_TRANSPOSE_DENSE_HPP 1
105#include <kernel/lafem/arch/transpose_dense_generic.hpp>
106#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
read-only access
@ write
write-only access (see attention note above)
std::uint64_t Index
Index data type.
static void exec_generic_impl(DT_ *r, const DT_ *const x, const Index rows_x, const Index cols_x)