- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am performing a simple test of a sparse matrix stores in CRS3 format with sparse_matrix_checker(). When I perform this test in the matrix_check.c MKL example code, it passes as expected. Also, I compiled the examples with GCC.
However, when I perform an identical check in a Matlab C++ MEX function (also compiled with GCC), I get a strange error that doesn't make sense. The matrix is identical to the one given in the MKL documentation at https://software.intel.com/en-us/node/471374. I am using zero-based indexing. Therefore, my row, column and value arrays are:
/* Matrix data. */ MKL_INT n = 5; MKL_INT ia[6] = {0,3,5,8,11,13}; MKL_INT ja[13] = {0,1,3,0,1,2,3,4,0,2,3,1,4}; double a[13] = {1,-1,-3,-2,5,4,6,4,-4,2,7,8,-5};
The parameters of my matrix check are:
pt.n = n; pt.csr_ia = ia; pt.csr_ja = ja; pt.indexing = MKL_ZERO_BASED; pt.matrix_structure = MKL_GENERAL_STRUCTURE; pt.print_style = MKL_C_STYLE; pt.message_level = MKL_PRINT;
Again, when I run this check in matrix_check.c compiled from the examples, it passes. But when I compile this in a Matlab MEX, I get the error:
Matrix check result code: 21 (MKL_SPARSE_CHECKER_NON_MONOTONIC)
Matrix check details: (1, 0, 0)
However, this error doesn't make sense because ia[1] and ia[2] are not zero. Instead, they are 3 and 5. Thus, it seems there is some memory read error by the MKL library.
Note, I am compiling the MEX file with the following compiler options using G++ 4.9.2:
LDFLAGS=-m64 -I/opt/intel/compilers_and_libraries_2016.0.109/linux/mkl/include -L/opt/intel/mkl/lib/intel64 -lmkl_core -lmkl_intel_ilp64 -lmkl_gnu_thread myTest.cpp
Also, I verified that the matrix is in fact stored correctly by reading it out in the Matlab MEX file:
0: val: 1 cols: 0 rows: 0 1: val: -1 cols: 1 rows: 3 2: val: -3 cols: 3 rows: 5 3: val: -2 cols: 0 rows: 8 4: val: 5 cols: 1 rows: 11 5: rows: 13 5: val: 4 cols: 2 6: val: 6 cols: 3 7: val: 4 cols: 4 8: val: -4 cols: 0 9: val: 2 cols: 2 10: val: 7 cols: 3 11: val: 8 cols: 1 12: val: -5 cols: 4
It seems to me that there is some issue caused by the way I am compiling this test that causes the MKL library to access memory differently than how it is being allocated. Does this make sense? Any thoughts or ideas for me to check?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jonathen,
I haven't test. But a tiny issue about mkl_intel_lp64 and mkl_intel_ilp64. Do you know the int type in mex are 64bit or 32bit?
Anyway, you may try -L/opt/intel/mkl/lib/intel64 -lmkl_core -lmkl_intel_lp64 and see if it works?
or add -DMKL_ILP64 with mkl_intel_ilp64 in compile command line
Best Regards,
Ying
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
From what you have posted I cannot gather what the mex-function arguments are. In particular, are you defining the sparse matrix in Matlab and passing the matrix (and other arguments) to the mex-function? If so, where do you convert from the COO representation used in Matlab to the CSR representation used in MKL/Pardiso?
Can we see the source code for the mex-function? Which version of Matlab do you use?

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page