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

Inconsistent C definition of ?gelsd function prototypes?

Zheng__Minjie
Beginner
1,134 Views

Recently started using MKL alongside other wrapper libraries like Armadillo and ran into some LAPACK function definition conflicts. Upon closer inspection, it appears that the MKL definitions of ?gelsd functions are inconsistent in mkl_lapack.h, and are incorrect for sgelsd, dgelsd, zgelsd.

For sgelsd, dgelsd, and zgelsd, the parameter for matrix "a" is defined as "const type*". This should not be the case as matrix "a" is overwritten as an output so it should not be defined with a "const" qualifier in the function parameters.

cgelsd correctly defines "a" without the "const" qualifier. This should be an easy fix but I'm unsure as how to contribute to the MKL code base since it's not open source.

MKL Version: 2019.4

0 Kudos
6 Replies
Gennady_F_Intel
Moderator
1,134 Views

yes, we definitely will fix this problem. You may also edit the mkl_lapack.h file and remove const MKL_Complex16* a or etc...

0 Kudos
Zheng__Minjie
Beginner
1,134 Views

Thank you! It's not feasible for us to manually remove the const qualifiers since we automatically obtain the headers from Anaconda packages in our build system and there isn't an easy way to patch the files. Great to hear that it'll be fixed in the next version though.

0 Kudos
Gennady_F_Intel
Moderator
1,134 Views

yes, that's the real problem in such environment. In any case, we will update this thread when the fix of the problem will be available into the official version of MKL.

0 Kudos
Zheng__Minjie
Beginner
1,134 Views

Also, along the lines of function prototype definitions, it appears that MKL does not define the hidden arguments required for calling Fortran functions in its C prototypes. This is recently discovered to be wrong and can cause unintended stack corruptions during the calls. Is this something on your radar to be fixed?

Please see the linked threads for more information on this:

https://lwn.net/Articles/791393/

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90329

https://bugzilla.redhat.com/show_bug.cgi?id=1709538

https://developer.r-project.org/Blog/public/2019/05/15/gfortran-issues-with-lapack/

0 Kudos
Gennady_F_Intel
Moderator
1,134 Views

not yet, but we will look at these cases, thanks

0 Kudos
Gennady_F_Intel
Moderator
1,134 Views

const qualifiers were removed from the declaration of these functions in MKL v2020 which has been released on Dec 12'19. 

0 Kudos
Reply