FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
matmatmult_dense_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_ alpha, const DT_ * const x, const DT_ * const y, const DT_ * const z, const Index rows, const Index cols, const Index inner);
19
20 static void exec_mkl_impl(float * r, const float alpha, const float * const x, const float * const y, const float * const z, const Index rows, const Index cols, const Index inner);
21 static void exec_mkl_impl(double * r, const double alpha, const double * const x, const double * const y, const double * const z, const Index rows, const Index cols, const Index inner);
22
23 template <typename DT_>
24 static void exec_mkl_impl(DT_ *, const DT_, const DT_ * const, const DT_ * const, const DT_ * const, const Index, const Index, const Index)
25 {
26 XABORTM("LAFEM::Arch::MatMatMultDenseDense::exec_mkl_impl: MKL backend not available!");
27 }
28
29 template <typename DT_>
30 static void exec_cuda_impl(DT_ * r, const DT_ alpha, const DT_ * const x, const DT_ * const y, const DT_ * const z, const Index rows, const Index cols, const Index inner);
31
32 template <typename DT_>
33 static void exec_generic(Memory::Arbiter& r, const DT_ alpha, const Memory::Arbiter& x, const Memory::Arbiter& y, const Memory::Arbiter& z, const Index rows, const Index cols, const Index inner)
34 {
38 if(z)
39 {
41 exec_generic_impl(r_view.get_w(), alpha, x_view.get_r(), y_view.get_r(), z_view.get_r(), rows, cols, inner);
42 }
43 else
44 exec_generic_impl(r_view.get_w(), alpha, x_view.get_r(), y_view.get_r(), (DT_*)nullptr, rows, cols, inner);
45 }
46
47 template <typename DT_>
48 static void exec_mkl(Memory::Arbiter& r, const DT_ alpha, const Memory::Arbiter& x, const Memory::Arbiter& y, const Memory::Arbiter& z, const Index rows, const Index cols, const Index inner)
49 {
53 if(z)
54 {
56 exec_mkl_impl(r_view.get_w(), alpha, x_view.get_r(), y_view.get_r(), z_view.get_r(), rows, cols, inner);
57 }
58 else
59 exec_mkl_impl(r_view.get_w(), alpha, x_view.get_r(), y_view.get_r(), (DT_*)nullptr, rows, cols, inner);
60 }
61
62 template <typename DT_>
63 static void exec_cuda(Memory::Arbiter& r, const DT_ alpha, const Memory::Arbiter& x, const Memory::Arbiter& y, const Memory::Arbiter& z, const Index rows, const Index cols, const Index inner)
64 {
68 if(z)
69 {
71 exec_cuda_impl(r_view.get_w(), alpha, x_view.get_r(), y_view.get_r(), z_view.get_r(), rows, cols, inner);
72 }
73 else
74 exec_cuda_impl(r_view.get_w(), alpha, x_view.get_r(), y_view.get_r(), (DT_*)nullptr, rows, cols, inner);
75 }
76
77 template <typename DT_>
78 static void exec(Memory::Arbiter& r, const DT_ alpha, const Memory::Arbiter& x, const Memory::Arbiter& y, const Memory::Arbiter& z, const Index rows, const Index cols, const Index inner)
79 {
80 XASSERT(r != x);
81 XASSERT(r != y);
82
84 {
86 exec_generic<DT_>(r, alpha, x, y, z, rows, cols, inner);
87 break;
88
90#ifdef FEAT_HAVE_MKL
91 exec_mkl<DT_>(r, alpha, x, y, z, rows, cols, inner);
92#else
93 XABORTM("LAFEM::Arch::MatMatMultDenseDense::exec: MKL backend not available!");
94#endif
95 break;
96
98#ifdef FEAT_HAVE_CUDA
99 exec_cuda<DT_>(r, alpha, x, y, z, rows, cols, inner);
100#else
101 XABORTM("LAFEM::Arch::MatMatMultDenseDense::exec: CUDA backend not available!");
102#endif
103 break;
104 }
105 }
106 }; // struct MatMatMultDenseDense
107
108#ifdef FEAT_EICKT
109 extern template void MatMatMultDenseDense::exec_generic_impl(float *, const float, const float * const, const float * const, const float * const, const Index, const Index, const Index);
110 extern template void MatMatMultDenseDense::exec_generic_impl(double *, const double, const double * const, const double * const, const double * const, const Index, const Index, const Index);
111#endif
112} // namespace FEAT::LAFEM::Arch
113
114#ifndef __CUDACC__
115#define KERNEL_LAFEM_ARCH_MATMATMULT_DENSE_DENSE_HPP 1
116#include <kernel/lafem/arch/matmatmult_dense_dense_generic.hpp>
117#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.
@ 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.