|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include <cstdint> |
| 4 | +#include "mkl.h" |
| 5 | + |
| 6 | +// |
| 7 | +// Add several templated functions for mapping from data_type to C style IE Sparse BLAS APIs |
| 8 | +// |
| 9 | + |
| 10 | + |
| 11 | +namespace spblas { |
| 12 | +namespace __mkl_iespblas { |
| 13 | + |
| 14 | +// |
| 15 | +// mkl_sparse_create_csr |
| 16 | +// |
| 17 | +template<class T> |
| 18 | +inline sparse_status_t mkl_sparse_create_csr( sparse_matrix_t *csrA, const sparse_index_base_t indexing, |
| 19 | + const MKL_INT nrows, const MKL_INT ncols, MKL_INT *rowptr_st, |
| 20 | + MKL_INT *rowptr_en, MKL_INT *colind, T *values) |
| 21 | +{ |
| 22 | + std::cout << "mkl_sparse_create_csr data types are not supported" << std::endl; |
| 23 | + return SPARSE_STATUS_NOT_SUPPORTED; |
| 24 | +} |
| 25 | + |
| 26 | +template<> |
| 27 | +inline sparse_status_t mkl_sparse_create_csr<float>( sparse_matrix_t *csrA, const sparse_index_base_t indexing, |
| 28 | + const MKL_INT nrows, const MKL_INT ncols, MKL_INT *rowptr_st, |
| 29 | + MKL_INT *rowptr_en, MKL_INT *colind, float *values) |
| 30 | +{ |
| 31 | + return mkl_sparse_s_create_csr(csrA, indexing, nrows, ncols, rowptr_st, rowptr_en, colind, values); |
| 32 | +} |
| 33 | + |
| 34 | +template<> |
| 35 | +inline sparse_status_t mkl_sparse_create_csr<double>( sparse_matrix_t *csrA, const sparse_index_base_t indexing, |
| 36 | + const MKL_INT nrows, const MKL_INT ncols, MKL_INT *rowptr_st, |
| 37 | + MKL_INT *rowptr_en, MKL_INT *colind, double *values) |
| 38 | +{ |
| 39 | + return mkl_sparse_d_create_csr(csrA, indexing, nrows, ncols, rowptr_st, rowptr_en, colind, values); |
| 40 | +} |
| 41 | + |
| 42 | + |
| 43 | +// |
| 44 | +// mkl_sparse_export_csr |
| 45 | +// |
| 46 | + |
| 47 | +template<class T> |
| 48 | +inline sparse_status_t mkl_sparse_export_csr( const sparse_matrix_t csrA, sparse_index_base_t *indexing, |
| 49 | + MKL_INT *nrows, MKL_INT *ncols, MKL_INT **rowptr_st, |
| 50 | + MKL_INT **rowptr_en, MKL_INT **colind, T **values) |
| 51 | +{ |
| 52 | + std::cout << "mkl_sparse_export_csr data types are not supported" << std::endl; |
| 53 | + return SPARSE_STATUS_NOT_SUPPORTED; |
| 54 | +} |
| 55 | + |
| 56 | +template<> |
| 57 | +inline sparse_status_t mkl_sparse_export_csr<float>( const sparse_matrix_t csrA, sparse_index_base_t *indexing, |
| 58 | + MKL_INT *nrows, MKL_INT *ncols, MKL_INT **rowptr_st, |
| 59 | + MKL_INT **rowptr_en, MKL_INT **colind, float **values) |
| 60 | +{ |
| 61 | + return mkl_sparse_s_export_csr(csrA, indexing, nrows, ncols, rowptr_st, rowptr_en, colind, values); |
| 62 | +} |
| 63 | + |
| 64 | +template<> |
| 65 | +inline sparse_status_t mkl_sparse_export_csr<double>( const sparse_matrix_t csrA, sparse_index_base_t *indexing, |
| 66 | + MKL_INT *nrows, MKL_INT *ncols, MKL_INT **rowptr_st, |
| 67 | + MKL_INT **rowptr_en, MKL_INT **colind, double **values) |
| 68 | +{ |
| 69 | + return mkl_sparse_d_export_csr(csrA, indexing, nrows, ncols, rowptr_st, rowptr_en, colind, values); |
| 70 | +} |
| 71 | + |
| 72 | + |
| 73 | +// |
| 74 | +// mkl_sparse_mv |
| 75 | +// |
| 76 | +template<class T> |
| 77 | +inline sparse_status_t mkl_sparse_mv( const sparse_operation_t op, const T alpha, const sparse_matrix_t csrA, |
| 78 | + const struct matrix_descr descr, const T* x, const T beta, T* y) |
| 79 | +{ |
| 80 | + std::cout << "mkl_sparse_mv data types are not supported" << std::endl; |
| 81 | + return SPARSE_STATUS_NOT_SUPPORTED; |
| 82 | +} |
| 83 | + |
| 84 | +template<> |
| 85 | +inline sparse_status_t mkl_sparse_mv<float>( const sparse_operation_t op, const float alpha, const sparse_matrix_t csrA, |
| 86 | + const struct matrix_descr descr, const float* x, const float beta, float* y) |
| 87 | +{ |
| 88 | + return mkl_sparse_s_mv(op, alpha, csrA, descr, x, beta, y); |
| 89 | +} |
| 90 | + |
| 91 | +template<> |
| 92 | +inline sparse_status_t mkl_sparse_mv<double>( const sparse_operation_t op, const double alpha, const sparse_matrix_t csrA, |
| 93 | + const struct matrix_descr descr, const double* x, const double beta, double* y) |
| 94 | +{ |
| 95 | + return mkl_sparse_d_mv(op, alpha, csrA, descr, x, beta, y); |
| 96 | +} |
| 97 | + |
| 98 | + |
| 99 | +// |
| 100 | +// mkl_sparse_mm |
| 101 | +// |
| 102 | +template<class T> |
| 103 | +inline sparse_status_t mkl_sparse_mm( const sparse_operation_t op, const T alpha, const sparse_matrix_t csrA, |
| 104 | + const struct matrix_descr descr, const sparse_layout_t layout, |
| 105 | + const T* x, const index_t nrhs, const index_t ldx, const T beta, T* y, const index_t ldy) |
| 106 | +{ |
| 107 | + std::cout << "mkl_sparse_mm data types are not supported" << std::endl; |
| 108 | + return SPARSE_STATUS_NOT_SUPPORTED; |
| 109 | +} |
| 110 | + |
| 111 | +template<> |
| 112 | +inline sparse_status_t mkl_sparse_mm<float>( const sparse_operation_t op, const float alpha, const sparse_matrix_t csrA, |
| 113 | + const struct matrix_descr descr, const sparse_layout_t layout, |
| 114 | + const float* x, const index_t nrhs, const index_t ldx, const float beta, float* y, const index_t ldy) |
| 115 | +{ |
| 116 | + return mkl_sparse_s_mm(op, alpha, csrA, descr, layout, x, nrhs, ldx, beta, y, ldy); |
| 117 | +} |
| 118 | + |
| 119 | +template<> |
| 120 | +inline sparse_status_t mkl_sparse_mm<double>( const sparse_operation_t op, const double alpha, const sparse_matrix_t csrA, |
| 121 | + const struct matrix_descr descr, const sparse_layout_t layout, |
| 122 | + const double* x, const index_t nrhs, const index_t ldx, const double beta, double* y, const index_t ldy) |
| 123 | +{ |
| 124 | + return mkl_sparse_d_mm(op, alpha, csrA, descr, layout, x, nrhs, ldx, beta, y, ldy); |
| 125 | +} |
| 126 | + |
| 127 | + |
| 128 | + |
| 129 | +} // namespace __mkl_iespblas |
| 130 | +} // namespace spblas |
| 131 | + |
| 132 | + |
| 133 | + |
| 134 | + |
0 commit comments