Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
9 Views

Const correctness

Hello,

This previous question http://software.intel.com/en-us/forums/topic/297849 didn't get any answer. Could someone please tell me why the Sparse BLAS has no const modifiers, whereas the CBLAS is the way it should be (with const modifiers !). It is really "painful" to have to const_cast the parameters at each call to the Sparse BLAS interface.

Thank you.

0 Kudos
11 Replies
Highlighted
Black Belt
9 Views

Much of the BLAS, LAPACK and other parts of MKL are based on Fortran sources. A clue to this is the passing of arguments by address instead of value when MKL routines are called from C/C++.  In Fortran 77 and earlier, there was no distinction between input and output arguments of subprograms as far as the language syntax rules were concerned. It was up to the programmer to preserve the contents of input arrays and document such usage.

LAPACKE, on the other hand, provides native C interfaces, and helps with matrix arguments by enabling them to be passed in row-major order.

0 Kudos
Highlighted
Valued Contributor II
9 Views

I checked a thread you've mentioned. >>...Debugging or proving correctness of code could be more easier... I don't think that debugging really matters here but I agree that correctness of code could look better. A const is recommended to be used when some variable should not be modified. Why MKL doesn't use const in declarations of some functions? I think this is a legacy issue.
0 Kudos
Highlighted
Beginner
9 Views

Do you think there is a change that it will be changed someday, so that CBLAS and Sparse BLAS interfaces match ? (I don't see how you can bring regression by changing const qualifiers, except if you are doing shady things under the hood but I doubt that).

0 Kudos
Highlighted
Valued Contributor II
9 Views

>>...Do you think there is a change that it will be changed someday, so that CBLAS and Sparse BLAS interfaces match? I think it is possible and you need to make a Feature Request with as better as posiible explanation and example(s).
0 Kudos
Highlighted
Moderator
9 Views

qweasd q. wrote:

Do you think there is a change that it will be changed someday, so that CBLAS and Sparse BLAS interfaces match ? (I don't see how you can bring regression by changing const qualifiers, except if you are doing shady things under the hood but I doubt that).

yes, we have such Feature Request submitted and we will modify these interfaces in the one of the future releases.j

0 Kudos
Highlighted
Moderator
9 Views

here is the #issue for your reference - DPD200346477

0 Kudos
Highlighted
Beginner
9 Views

Sergey Kostrov wrote:

>>...Do you think there is a change that it will be changed someday, so that CBLAS and Sparse BLAS interfaces match?

I think it is possible and you need to make a Feature Request with as better as posiible explanation and example(s).

Here is one of the simplest example one could think of:

[cpp]#include "mkl.h" int main () { MKL_INT* _I; MKL_INT* _J; double* _C; double one = 1; double zero = 0; const MKL_INT n = 50, k = 50; double x; double rhs; char matdescra[6] = { 'G', '0', '0', 'C', '0', '0' }; char transa = 'N'; mkl_dcsrmv(&transa, &n, &k, &one, matdescra, _C, _J, _I, _I + 1, rhs, &one, x); // mkl_dcsrmv(&transa, const_cast< int* >(&n), const_cast< int* >(&k), &one, matdescra, _C, _J, _I, _I + 1, rhs, &one, x); }[/cpp]

Gennady Fedorov (Intel) wrote:

here is the #issue for your reference - DPD200346477

Great, thanks.

0 Kudos
Highlighted
Beginner
9 Views

Still not fixed in latest update. What is the holdup please ?

0 Kudos
Highlighted
Moderator
9 Views

unfortunatelly , the issue has not been fixed in this update.

0 Kudos
Highlighted
Beginner
9 Views

Hello,

Is it still planned to fix this (trivial) issue ? Thanks.

0 Kudos
Highlighted
Beginner
9 Views

Thank you for the last update. My code is much cleaner now ! The reference manual has not been updated accordingly though.

0 Kudos