- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I encounters with some problems that have to use sparse matrix to solve, so I start to learn MKL Sparse BLAS. However, I cannot get right result when calling mkl_sparse_z_mv. I still cannot find the solution after reading the MKL reference manual and casting several demos.
So, how can I get a correct sparse matrix - vector multiplication? Any help is appreciated.
Many thanks,
Bingqi
PS: The demo is attached to this post with source code and results, along with MKL version & platform information.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Supplement: What I want to calculate is the following matrix - vector multiplication:
A = {
{ 0, 0.5i, -0.5i, 0},
{0.5i, -i, 0, -0.5i},
{-0.5i, 0, i, 0.5i},
{0, -0.5i, 0.5i, 0}
}
and
x = { 0.3799605, -0.1200395, -0.1200395, 0.6200395}
The result, Ax, should be a zero vector. But I cannot get the correct result.
I am not sure if I have missed someting in the documentation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bingqi!
I've found the issue in your code. You're redefining MKL_INT to be long int. This is an incorrect way of using MKL with 64-bit integers. Essentially, size of integers passed via pointers to MKL is defined by the interface layer, LP64 or ILP64 (and if you are using MKL_INT in your example code, on the definition of MKL_INT as well).
Essentially, what happened in your case is that you passed 64-bit integer arrays to mkl_sparse_z_mv routine but since you didn't do it properly, routine treated them as pointers to 32-bit integer arrays, hence incorrect result.
The correct way is:
Change your compilation and link line according to MKL link line advisor for 64-bit integers (i.e. choose ("C API with 64-bit integers" option). You would need to add -DMKL_ILP64 to your compilation line and also link against mkl_intel_ilp64 instead of mkl_intel_lp64 interface library.
Then you would get correct results (all zeros) for the output vector.
I hope this helps.
Best,
Kirill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Can you please let us know if your issue has been resolved or not?
Regards
Rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
We have not heard back from you, so we will close this inquiry now. If you need further assistance, please post a new question.
Regards
Rajesh.

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