I have one question regarding the output however. One of the result matrix items from the mkl_sparse_d_create_csr, mkl_sparse_spmm, and mkl_sparse_d_export_csr calls is coming out to a value of 0, and I would expect it NOT to be included in the result matrix in csr format, but it is.
I am developing a program, making heavy use of Armadillo library. I have the 10.8.2 version, linked against Intel oneAPI MKL 2022.0.2. At some point, I need to perform manysparse matrix times dense vector multiplications, both of which are defined using Armadillo structures. I have found this point to be a probable bottleneck, and was being curious if replacing the Armadillo multiplication with "bare bones" sparse CBLAS routines from MKL (mkl_sparse_d_mv) would speed things up. But in order to do so, I need to convert from Armadillo's SpMat to something that MKL understands. As per Armadillo docs, sparse matrices are stored in CSC format, so I have triedmkl_sparse_d_create_csc. My attempt at this is below:
intel math kernel library sparse matrix
Intel oneAPI Math Kernel Library (Intel oneMKL; formerly Intel Math Kernel Library or Intel MKL) is a library of optimized math routines for science, engineering, and financial applications. Core math functions include BLAS, LAPACK, ScaLAPACK, sparse solvers, fast Fourier transforms, and vector math.[5][6]
MKL and other programs generated by the Intel C++ Compiler and the Intel DPC++ Compiler improve performance with a technique called function multi-versioning: a function is compiled or written for many of the x86 instruction set extensions, and at run-time a "master function" uses the CPUID instruction to select a version most appropriate for the current CPU. However, as long as the master function detects a non-Intel CPU, it almost always chooses the most basic (and slowest) function to use, regardless of what instruction sets the CPU claims to support. This has netted the system a nickname of "cripple AMD" routine since 2009.[11] As of 2020[update], Intel's MKL remains the numeric library installed by default along with many pre-compiled mathematical applications on Windows (such as NumPy, SymPy).[12][13] Although relying on the MKL, MATLAB implemented a workaround starting with Release 2020a which ensures full support for AVX2 by the MKL also for non Intel (AMD) CPUs.[14]
In older versions, setting the undocumented environment variable MKL_DEBUG_CPU_TYPE=5 could be used to override the vendor string dependent codepath choice and activate supported instructions up to AVX2 on AMD processor based systems resulting in equal or even better performance when compared to Intel CPUs.[15][16][17] Since Update 1 2020, the environment variable does not work anymore, but Intel introduced custom kernels for Zen 2 for dgemm (but not for sgemm), which is still worse than when using mkl_serv_intel_cpu_true hack.[12][13][18]
For technical information about Intel MKL, including FAQ's, tips and tricks, and other support information, please visit the Intel MKL forum: -us/forums/intel-math-kernel-library/ and browse the Intel MKL knowledge base: -us/articles/intel-mkl-kb/all/.
The Intel oneAPI Math Kernel Library (MKL) is the fastest and most widely used math library for all intel based systems. It helps you reach high performance with its enhanced library of optimized math routines. It allows for faster math processing times, increased performance and shorter development times. The MKL supports seven main features; Linear Algebra, Sparse Linear Algebra, Data Fitting, Fast Fourier Transformations, Random Number Generation, Summary Statistics and Vector Math. These features will allow you to optimize applications for all current and future intel CPUs and GPUs.
A sparse matrix is matrix that is mostly empty, these are common in machine learning applications. Using standard linear algebra functions would lead to poor performance and would require greater amounts of storage. Specially written sparse linear algebra functions have better performance and can better compress matrices to save space.
Intel Math Kernel Library (Intel MKL) is a computing math library of highly optimized, extensively threaded routines for applications that require maximum performance. The library provides Fortran and C programming language interfaces. Intel MKL C language interfaces can be called from applications written in either C or C++, as well as in any other language that can reference a C interface.
Forward Blocking Method: This example shows the concept of the FBM for the calculation of with sparse matrix M (left), the dense source vector / (most left vector) and a block size of . The following vectors are the destination vectors of the successive SpMv operations needed to calculate . The numbers inside the blocks of the destination vectors denote the order in which they are calculated by the FBM. The arrows indicate the dependencies between the vector blocks as encoded by the MaxBlockColInd array.
Backward Blocking Method: This example shows the concept of the BBM for the calculation of with sparse matrix M (left), the dense source vector / (most left vector) and a block size of . The following vectors are the destination vectors of the successive SpMv operations needed to calculate . The numbers inside the blocks of these destination vectors denote the order in which they are calculated by the BBM. The arrows indicate the dependencies between the vector blocks as encoded by the arrays blockRowPtr and blockColInd. The BBM computes a block of by recursively computing all the (not already computed) blocks of the previous vectors it depends on, e.g., to calculate the first block of ([0]) the order of calculated blocks is [0], [2], [0], [4], [2], [0].
By the term Math library in this document we consider a software package that includes functions that perform certain mathematical operations. This is a very wide term and as such the list below is not exhaustive, but, it represents the most commonly used math functions in scientific and engineering computations.Math libraries can be roughly divided into general libraries, which provide multitude of functionality, and specialized libraries that provide specific functionality. Among the general libraries we include Intel Math Kernel Library (MKL) library, or GNU Scientific Library (GSL). The pecialized libraries include BLAS and LAPACK linear algebra libraries, FFTW Fast Fourier Transform library, etc. The general libraries often provide optimized functionality of the specialized libraries, or use them underneath.The below listed libraries are the most common libraries that we provide, if you don't see the one you need on the list, please, contact us.
MKL contains highly optimized math routines. It includes full optimized BLAS, LAPACK, sparse solvers, vector math library, random number generators and and fast Fourier transform routines (including FFTW wrappers). For more information, consult the Intel Math Kernel Library Documentation.
For distributed (MPI) parallel linear algebra routines, ScaLAPACK is also fully implemented inside MKL and recommended to use instead of the reference ScaLAPACK distribution. From release 11.2 (2015), MKL also includes cluster sparse matrix solvers based on PARDISO. Large sparse eigenproblems can be solved, to certain tolerance, using PRIMME, which can be linked to MKL for LAPACK/BLAS.
GSL is a numerical library for C/C++ provides a wide range of mathematical routines such as random number generators, special functions and least-squares fitting. There are over 1000 functions in total with an extensive test suite. While GSL is not parallel, it is reasonably thread safe and its routines should be callable from parallel code sections. One can also link a parallel BLAS library such as MKL or ACML and utilize the shared memory parallelism they provide.
The MKL library is composed of highly optimized mathematical routines.It contains, among others, LAPACK, the Basic Linear Algebra Subprograms(BLAS) and the extended BLAS. For parallel computing it providesScaLAPACK, the Basic Linear Algebra Communications Subprograms (BLACS)and the Parallel Basic Linear Algebra Subprograms (PBLAS).
The NAG libraryis a collection of mathematical and statistical routines developed bytheThe Numerical Algorithms Group Ltd.,Wilkinson House, Jordan Hill Road, Oxford, OX2 8DR, UK. 2ff7e9595c
Comments