Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

Sparse BLAS mkl_sparse_sypr valgrind memcheck error

Mazur__Luke
Beginner
930 Views

Hello,

I ran the attached code and receive:

➜ valgrind --tool=memcheck --leak-check=full --track-origins=yes ./lukeSparseBLAStest > temp.txt
==22146== Memcheck, a memory error detector
==22146== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==22146== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==22146== Command: ./lukeSparseBLAStest
==22146== 
==22146== Conditional jump or move depends on uninitialised value(s)
==22146==    at 0xEBB8501: mkl_sparse_sypr_i4_avx2 (in /opt/intel/compilers_and_libraries_2020.0.166/linux/mkl/lib/intel64_lin/libmkl_avx2.so)
==22146==    by 0x1096F8: main (lukeSparseBLAStest.cpp:95)
==22146==  Uninitialised value was created by a heap allocation
==22146==    at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22146==    by 0x10927B: main (lukeSparseBLAStest.cpp:58)
==22146== 
==22146== 
==22146== HEAP SUMMARY:
==22146==     in use at exit: 3,238 bytes in 10 blocks
==22146==   total heap usage: 70 allocs, 60 frees, 306,317 bytes allocated
==22146== 
==22146== LEAK SUMMARY:
==22146==    definitely lost: 0 bytes in 0 blocks
==22146==    indirectly lost: 0 bytes in 0 blocks
==22146==      possibly lost: 0 bytes in 0 blocks
==22146==    still reachable: 3,238 bytes in 10 blocks
==22146==         suppressed: 0 bytes in 0 blocks
==22146== Reachable blocks (those to which a pointer was found) are not shown.
==22146== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==22146== 
==22146== For counts of detected and suppressed errors, rerun with: -v
==22146== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
 

 

This is line 95
 

  mklinfo = mkl_sparse_sypr(SPARSE_OPERATION_NON_TRANSPOSE,EHandle,symmHandle,spsyprdescr,spsyprResultHandlePointer,SPARSE_STAGE_FULL_MULT);
 

I know the issue has to do with the variable spsyprResultHandlePointer because if I replace that with the commented out line 96 I get 

Uninitialised value was created by a stack allocation

So it has to be this variable. This variable is uninitialized, but I expect it should be, as it only gathers the output from mkl_sparse_sypr. 

I am using /opt/intel/compilers_and_libraries_2020.0.166/linux/mkl/include

 

My compilation line:

g++ -g lukeSparseBLAStest.cpp -I /opt/intel/compilers_and_libraries/linux/mkl/include -L/opt/intel/compilers_and_libraries/linux/mkl/lib/intel64 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -o lukeSparseBLAStest
 

I was able to reproduce this on two different linux machines, so I don't think specific details of these are relevant. If you can't reproduce this on your machine then I can provide more specific information regarding this.

 

My question is why am I getting this error? Have I done something wrong in the code? Or is there something wrong with the intel sparse BLAS? Or is it spurious valgrind output?

 

Regards, Luke Mazur

0 Kudos
3 Replies
Jonghak_K_Intel
Employee
930 Views

Hi Luke, 

 

I see you used a deprecated function 'mkl_ddnscsr()'. Could you try to use mkl_sparse_convert_csr and see ? 

Please refer : https://software.intel.com/en-us/mkl-developer-reference-c-mkl-dnscsr and https://software.intel.com/en-us/mkl-developer-reference-c-matrix-manipulation-routines 

0 Kudos
Mazur__Luke
Beginner
930 Views

Hello Jon,

It is not clear to me how I can use mkl_sparse_convert_csr to do the job of ddnscsr in this case. I am starting with a dense matrix, rather than a handle in a sparse format. Could you please elaborate on how to do that? Is there an alternative to ddnscsr that does this job?

0 Kudos
Kirill_V_Intel
Employee
929 Views

Hello Luke,

I'm afraid it is a consequence of the IE SpBLAS API (for destroy functionality). Essentially, it is a minor issue and should be fixed if you set all variables corresponding to sparse handles to NULL after calling mkl_sparse_destroy (please verify it and let me know if I am wrong).

Best,
Kirill

0 Kudos
Reply