FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
matvecmult_dense_dense_mkl.cpp
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// includes, FEAT
8#include <kernel/lafem/arch/matvecmult_dense_dense.hpp>
10
11FEAT_DISABLE_WARNINGS
12#include <mkl.h>
13#include <mkl_spblas.h>
14FEAT_RESTORE_WARNINGS
15
16namespace FEAT::LAFEM::Arch
17{
18 void MatVecMultDenseDense::exec_mkl_impl(float * r, const float alpha, const float * const y, const float * const val, const float * const x, const Index rows, const Index cols, bool transposed)
19 {
20 MKL_INT mrows = static_cast<MKL_INT>(rows);
21 MKL_INT mcolumns = static_cast<MKL_INT>(cols);
22
23 if(y == nullptr)
24 Memory::memset_main(r, 0, sizeof(float) * (transposed ? cols : rows));
25 else if(r != y)
26 {
27 MKL_INT one = 1;
28 MKL_INT n = transposed ? mcolumns : mrows;
29 scopy(&n, y, &one, r, &one);
30 }
31
32 float beta(1);
33 cblas_sgemv(CblasRowMajor, transposed ? CblasTrans : CblasNoTrans, mrows, mcolumns, alpha, val, mcolumns, x, 1, beta, r, 1);
34 }
35
36 void MatVecMultDenseDense::exec_mkl_impl(double * r, const double alpha, const double * const y, const double * const val, const double * const x, const Index rows, const Index cols, bool transposed)
37 {
38 MKL_INT mrows = static_cast<MKL_INT>(rows);
39 MKL_INT mcolumns = static_cast<MKL_INT>(cols);
40
41 if(y == nullptr)
42 Memory::memset_main(r, 0, sizeof(double) * (transposed ? cols : rows));
43 else if(r != y)
44 {
45 MKL_INT one = 1;
46 MKL_INT n = transposed ? mcolumns : mrows;
47 dcopy(&n, y, &one, r, &one);
48 }
49
50 double beta(1);
51 cblas_dgemv(CblasRowMajor, transposed ? CblasTrans : CblasNoTrans, mrows, mcolumns, alpha, val, mcolumns, x, 1, beta, r, 1);
52 }
53} // namespace FEAT::LAFEM::Arch
FEAT Kernel base header.
void memset_main(void *ptr, int value, std::size_t bytes)
Formats all bytes of a memory block in main memory to a given value.
std::uint64_t Index
Index data type.