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

Const correctness

asd__asdqwe
初学者
1,744 次查看

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 项奖励
11 回复数
mecej4
名誉分销商 III
1,744 次查看

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 项奖励
SergeyKostrov
重要分销商 II
1,744 次查看
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 项奖励
asd__asdqwe
初学者
1,744 次查看

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 项奖励
SergeyKostrov
重要分销商 II
1,744 次查看
>>...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 项奖励
Gennady_F_Intel
主持人
1,744 次查看

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 项奖励
Gennady_F_Intel
主持人
1,744 次查看

here is the #issue for your reference - DPD200346477

0 项奖励
asd__asdqwe
初学者
1,744 次查看

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 项奖励
asd__asdqwe
初学者
1,744 次查看

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

0 项奖励
Gennady_F_Intel
主持人
1,744 次查看

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

0 项奖励
asd__asdqwe
初学者
1,744 次查看

Hello,

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

0 项奖励
asd__asdqwe
初学者
1,744 次查看

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

0 项奖励
回复