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