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

LAPACK LOGICAL arguments on 32- or 64-bit platforms

johnwavemetrics_com
488 Views
Please pardon me if this is elementary...

I'm trying to figure out what C/C++ type to use for LAPACK arguments that are billed as "LOGICAL". These are mostly bwork arrays, but also include selector arguments. I need to know this for building both 32-bit and 64-bit versions of our application.

The old f2c definition is as a long, but that isn't consistent on 64-bit platforms. Apple defines these arguments as long for 32-bit platforms and int on 64-bit.

The mkl_lapack.h header file has void * for those arguments, so it provides no guidance.
0 Kudos
4 Replies
TimP
Honored Contributor III
488 Views
I'm trying to figure out what C/C++ type to use for LAPACK arguments that are billed as "LOGICAL". These are mostly bwork arrays, but also include selector arguments. I need to know this for building both 32-bit and 64-bit versions of our application.

The old f2c definition is as a long, but that isn't consistent on 64-bit platforms. Apple defines these arguments as long for 32-bit platforms and int on 64-bit.

The mkl_lapack.h header file has void * for those arguments, so it provides no guidance.
int * does make more sense than void *, so I agree we should have an explanation from the maintainers.
On the 32-bit platforms, int * and long * are of course the same, and Fortran default logical is a 32-bit type for 64-bit also. For completeness, it would be good to confirm whether it becomes a 64-bit type in the ilp64 library.
0 Kudos
johnwavemetrics_com
488 Views
Quoting - tim18
int * does make more sense than void *, so I agree we should have an explanation from the maintainers.
On the 32-bit platforms, int * and long * are of course the same, and Fortran default logical is a 32-bit type for 64-bit also. For completeness, it would be good to confirm whether it becomes a 64-bit type in the ilp64 library.

Yes, that is the, er, 64-dollar question.
0 Kudos
Michael_C_Intel4
Employee
488 Views
Please pardon me if this is elementary...

I'm trying to figure out what C/C++ type to use for LAPACK arguments that are billed as "LOGICAL". These are mostly bwork arrays, but also include selector arguments. I need to know this for building both 32-bit and 64-bit versions of our application.

The old f2c definition is as a long, but that isn't consistent on 64-bit platforms. Apple defines these arguments as long for 32-bit platforms and int on 64-bit.

The mkl_lapack.h header file has void * for those arguments, so it provides no guidance.

The type LOGICAL for LAPACK arguments is equivalent to the type INTEGER by size. INTEGER typeis mapped onto C types this way: for 32-bitplatform it's 'int' or 'long' - doesn't matter(32-bit long), for 64-bit platform it's either 'int' (32-bit long) in case of LP64 model, which you apparently use, or 64-bit integer type - 'long' in Linux/MacOS, 'long long' in Windows (they treat 'long' as 32-bit by some reason) or substitutes- in case of ILP64 model.

Using void* for logical arguments is inapropriate indeed, please indicate which function and argument has the wrong prototype.

Thanks, Michael.
0 Kudos
johnwavemetrics_com
488 Views

The type LOGICAL for LAPACK arguments is equivalent to the type INTEGER by size. INTEGER typeis mapped onto C types this way: for 32-bitplatform it's 'int' or 'long' - doesn't matter(32-bit long), for 64-bit platform it's either 'int' (32-bit long) in case of LP64 model, which you apparently use, or 64-bit integer type - 'long' in Linux/MacOS, 'long long' in Windows (they treat 'long' as 32-bit by some reason) or substitutes- in case of ILP64 model.

Using void* for logical arguments is inapropriate indeed, please indicate which function and argument has the wrong prototype.

Thanks, Michael.

Um, all of them?

Truly, I looked through mkl_lapack.h and find void * for LOGICAL everywhere I looked. Search for either "select" or "bwork" and you will find void *.
0 Kudos
Reply