8#include <kernel/lafem/arch/matvecmult_csr_dense.hpp>
9#include <kernel/util/memory_aux.hpp>
14#include <mkl_spblas.h>
17namespace FEAT::LAFEM::Arch
20 static_assert(
sizeof(
Index) ==
sizeof(MKL_INT),
"size mismatch between MKL_INT and FEAT::Index");
22 void MatVecMultCSRDense::exec_mkl_impl(
float * r,
const float alpha,
const float *
const x,
const float *
const y,
const float *
const val,
const Index *
const col_idx,
const Index *
const row_ptr,
const Index rows,
const Index cols,
const Index,
const bool transposed)
24 MKL_INT mrows = (MKL_INT)rows;
25 MKL_INT mcolumns = (MKL_INT)cols;
32 MKL_INT n = transposed ? mcolumns : mrows;
33 scopy(&n, y, &one, r, &one);
38 #ifndef FEAT_USE_MKL_LEGACY_SPMV
40 sparse_operation_t opt = (transposed ? SPARSE_OPERATION_TRANSPOSE : SPARSE_OPERATION_NON_TRANSPOSE);
44 sparse_status_t status = mkl_sparse_s_create_csr(&A, SPARSE_INDEX_BASE_ZERO, mrows, mcolumns, (MKL_INT*)row_ptr, (MKL_INT*)(row_ptr + 1), (MKL_INT*)col_idx, (
float*) val);
46 if (status != SPARSE_STATUS_SUCCESS)
47 XABORTM(
"MKL Sparse Error occurred in execution!\n");
49 md.type = SPARSE_MATRIX_TYPE_GENERAL;
50 status = mkl_sparse_s_mv(opt, alpha, A, md, x, beta, r);
51 if (status != SPARSE_STATUS_SUCCESS)
52 XABORTM(
"MKL Sparse Error occurred in execution!\n");
53 mkl_sparse_destroy(A);
63 char trans = (transposed ?
'T' :
'N');
66 mkl_scsrmv(&trans, &mrows, &mcolumns, (
const float*)&alpha, matdescra, (
const float*) val, (
const MKL_INT*)col_idx, (
const MKL_INT*)row_ptr, (
const MKL_INT*)(row_ptr) + 1, (
const float*)x, (
const float*)&beta, r);
72 void MatVecMultCSRDense::exec_mkl_impl(
double * r,
const double alpha,
const double *
const x,
const double *
const y,
const double *
const val,
const Index *
const col_idx,
const Index *
const row_ptr,
const Index rows,
const Index cols,
const Index,
const bool transposed)
74 MKL_INT mrows = (MKL_INT)rows;
75 MKL_INT mcolumns = (MKL_INT)cols;
82 MKL_INT n = transposed ? mcolumns : mrows;
83 dcopy(&n, y, &one, r, &one);
88 #ifndef FEAT_USE_MKL_LEGACY_SPMV
90 sparse_operation_t opt = (transposed ? SPARSE_OPERATION_TRANSPOSE : SPARSE_OPERATION_NON_TRANSPOSE);
94 sparse_status_t status = mkl_sparse_d_create_csr(&A, SPARSE_INDEX_BASE_ZERO, mrows, mcolumns, (MKL_INT*)row_ptr, (MKL_INT*)(row_ptr + 1), (MKL_INT*)col_idx, (
double*) val);
96 if (status != SPARSE_STATUS_SUCCESS)
97 XABORTM(
"MKL Sparse Error occurred in execution!\n");
99 md.type = SPARSE_MATRIX_TYPE_GENERAL;
100 status = mkl_sparse_d_mv(opt, alpha, A, md, x, beta, r);
101 if (status != SPARSE_STATUS_SUCCESS)
102 XABORTM(
"MKL Sparse Error occurred in execution!\n");
103 mkl_sparse_destroy(A);
113 char trans = (transposed ?
'T' :
'N');
115 FEAT_DISABLE_WARNINGS
116 mkl_dcsrmv(&trans, &mrows, &mcolumns, (
const double*)&alpha, matdescra, (
const double*) val, (
const MKL_INT*)col_idx, (
const MKL_INT*)row_ptr, (
const MKL_INT*)(row_ptr) + 1, (
const double*)x, (
const double*)&beta, r);
117 FEAT_RESTORE_WARNINGS
#define XABORTM(msg)
Abortion macro definition with custom message.
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.