miscellaneous

Sparse matrix-dense vector products using intel MKL

In Matlab 2013b, dense linear algebra operations have been generally well optimized by using BLAS and LAPACK tuned to the CPU processors in use. On the other hand, we have observed that some sparse linear algebra operations in Matlab 2013b seem to have not been as highly optimized. In particular, when doing multiplications between a sparse matrix and a dense vector or matrix (denoted by ‘‘SpMM’’) the performance of Matlab's own version of SPMM can differ significantly from that of the corresponding routine in Intel's Math Kernel Library (MKL), which is named ‘‘mkl_dcscmm’’.

  • installation in Ubuntu 12.04 with Matlab 2013b

    • configure “mexopts.sh” with link to MKL

    • compile: mex -O -largeArrayDims -output sfmult mkl-sfmult-v1.cpp

  • usage:

    • C = A*B: C = sfmult(A, B, 1)

    • C = A’*B: C = sfmult(A, B, 2)

  • Numerical Results on A*B, where A is 5000 by 2000 and B is 2000 by 1000

seed:  88137586, A*B: err 0.00e+00, matlab-cpu: 0.23, mkl-cpu: 0.10
seed:  87017600, A*B: err 0.00e+00, matlab-cpu: 0.22, mkl-cpu: 0.11
seed:  49049047, A*B: err 0.00e+00, matlab-cpu: 0.23, mkl-cpu: 0.10
  • Thanks Yin Zhang and Xin Liu