FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
matvecmult_csr_block_generic.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#ifndef KERNEL_LAFEM_ARCH_MATVECMULT_CSR_BLOCK_HPP
9#error "Do not include this implementation-only header file directly!"
10#endif
11
12namespace FEAT::LAFEM::Arch
13{
14 template <typename DT_, typename IT_, int block_size_>
15 void MatVecMultCSRBlock::exec_generic_impl(Tiny::Vector<DT_,block_size_> * r, const DT_ alpha, const Tiny::Vector<DT_,block_size_> * const x, const Tiny::Vector<DT_,block_size_> * const y, const DT_ * const val,
16 const IT_ * const col_idx, const IT_ * const row_ptr, const Index rows, const Index /*cols*/, const Index /*nonzeros*/, const bool transposed)
17 {
18 XASSERTM(!transposed, "transposed mat-vec-mult not implemented yet");
19
20 FEAT_PRAGMA_OMP(parallel for schedule(static, 2000))
21 for (Index row = 0 ; row < rows ; ++row)
22 {
23 Tiny::Vector<DT_, block_size_> bsum(0);
24 const IT_ end(row_ptr[row + 1]);
25 for (IT_ i(row_ptr[row]) ; i < end ; ++i)
26 {
27 bsum.axpy(val[i], x[col_idx[i]]);
28 }
29 if(y)
30 r[row] = y[row];
31 else
32 r[row] = DT_(0);
33 r[row].axpy(alpha, bsum);
34 }
35 }
36} // namespace FEAT::LAFEM::Arch
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Definition: assertion.hpp:263
std::uint64_t Index
Index data type.