9#include <kernel/util/memory_arbiter.hpp>
10#include <kernel/util/omp_util.hpp>
11#include <kernel/backend.hpp>
15namespace FEAT::LAFEM::Arch
30 template<
typename DT_,
typename DTT_>
35 DT_* dots_ptr = dots_view.
get_w();
37 const DTT_* target_ptr = target_view.
get_r();
39 for(
Index l = 0; l < num_dots; ++l)
42 const DTT_* other_ptr = other_view.
get_r();
44 FEAT_PRAGMA_OMP(parallel
for reduction(+:loc_v))
45 for(
Index k = 0; k < dot_size; ++k)
47 loc_v += DT_(target_ptr[k] * other_ptr[k]);
53 template<
typename DT_,
typename DTT_>
56 template<
typename DT_,
typename DTT_>
63 exec_cuda<DT_, DTT_>(local_dots, target, dot_size, others, num_dots);
65 XABORTM(
"LAFEM::ARCH::BatchedDotProduct::exec: CUDA backend not available");
69 exec_generic<DT_, DTT_>(local_dots, target, dot_size, others, num_dots);
80 template<
typename DT_,
typename DTT_>
85 DT_* dots_ptr = dots_view.
get_w();
87 const DTT_* target_ptr = target_view.
get_r();
89 const DTT_* freqs_ptr = freqs_view.
get_r();
91 for(
Index l = 0; l < num_dots; ++l)
94 const DTT_* other_ptr = other_view.
get_r();
96 FEAT_PRAGMA_OMP(parallel
for reduction(+:loc_v))
97 for(
Index k = 0; k < dot_size; ++k)
99 loc_v += DT_(target_ptr[k] * freqs_ptr[k] * other_ptr[k]);
101 dots_ptr[l] += loc_v;
105 template<
typename DT_,
typename DTT_>
108 template<
typename DT_,
typename DTT_>
114 #ifdef FEAT_HAVE_CUDA
115 exec_cuda<DT_, DTT_>(local_dots, target, dot_size, others, freqs, num_dots);
117 XABORTM(
"LAFEM::ARCH::BatchedTripleDotProduct::exec: CUDA backend not available");
121 exec_generic<DT_, DTT_>(local_dots, target, dot_size, others, freqs, num_dots);
131 template<
typename DT_>
136 DT_* target_ptr = target_view.
get_w();
138 for(
Index l = 0; l < num_axpy; ++l)
141 const DT_* other_ptr = other_view.
get_r();
142 FEAT_PRAGMA_OMP(parallel
for)
143 for(
Index k = 0; k < vec_size; ++k)
145 target_ptr[k] += DT_(alpha * local_scales[l]) * other_ptr[k];
150 template<
typename DT_>
153 template<
typename DT_>
159 #ifdef FEAT_HAVE_CUDA
160 exec_cuda<DT_>(target, vec_size, others, local_scales, num_axpy, alpha);
162 XABORTM(
"LAFEM::ARCH::CumulativeAxpy::exec: CUDA backend not available");
166 exec_generic<DT_>(target, vec_size, others, local_scales, num_axpy, alpha);
#define XABORTM(msg)
Abortion macro definition with custom message.
static PreferredBackend get_preferred_backend()
get current preferred backend
View view(Location mem_loc, Access access)
Maps a raw view to a memory block.
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
std::uint64_t Index
Index data type.