Hello.
Some quantum chemistry programs I use (e.g. NWChem) rely on lapack and/or blas routines in which all fortran integers are promoted to long ints. Vendor libraries are usually available in such a flavour (i.e. acml and mkl are). This is necessary to be able to support large indices for some arrays. While it's trivial to obtain this for the fortran interfaces of magma (e.g. by setting the gfortran flag -i8 or the equivalent with other compilers) and for C/C++ code meant for the CPU, it's not apparent (to a CUDA newbie as me) if this can be achieved as easily for the code to be executed on the gpu and, in case, what should be the appropriate nvcc flags.
Could you magma developers please either provide an example of make.inc file to obtain this or explain if/how this can be achieved? What I need is just blas (and possibly lapack) fortran interfaces in which all integers are 64 bits.
Thanks in advance
Giacomo Mulas
magma library with long ints?
-
Stan Tomov
- Posts: 283
- Joined: Fri Aug 21, 2009 10:39 pm
Re: magma library with long ints?
Hi,
The integers used in MAGMA are defined by magma_int_t. By default this is set to int - in file include/magmablas.h there is a definition:
The reason for using this to handle cases like yours. You can redefine it to 64 bit integer and recompile the library.
Stan
The integers used in MAGMA are defined by magma_int_t. By default this is set to int - in file include/magmablas.h there is a definition:
Code: Select all
typedef int magma_int_t;
Stan
Re: magma library with long ints?
Thanks for your prompt reply, Stan.
Would you please explain how this magma_int_t is mapped to cudablas function? As far as I can understand, cudablas functions do not accept long ints as arguments, so you would have to cast them to ints. This is not a limitation of cuda per se, perhaps, but it is a limitation of using cudablas. If a number is too large to fit in an int, how is this handled? truncation? it is checked and an error is issued? In those codes, long ints are used exactly to be able to handle array indices which will not fit into an int, so it should either fall back on the cpu implementation or fail gracefully.
Thanks again
Giacomo
Would you please explain how this magma_int_t is mapped to cudablas function? As far as I can understand, cudablas functions do not accept long ints as arguments, so you would have to cast them to ints. This is not a limitation of cuda per se, perhaps, but it is a limitation of using cudablas. If a number is too large to fit in an int, how is this handled? truncation? it is checked and an error is issued? In those codes, long ints are used exactly to be able to handle array indices which will not fit into an int, so it should either fall back on the cpu implementation or fail gracefully.
Thanks again
Giacomo
-
Stan Tomov
- Posts: 283
- Joined: Fri Aug 21, 2009 10:39 pm
Re: magma library with long ints?
Hi Giacomo,
I think the compiler will let you pass (by value) any integer type to cublas and the values will be cast. I am not sure what truncation will happen if they exceed the range. In the case of cublas though there is no need of concern for now. The smallest type in cublas is float and int can address a little more than 8 GB of floats which exceeds the memory sizes of the current GPUs.
Stan
I think the compiler will let you pass (by value) any integer type to cublas and the values will be cast. I am not sure what truncation will happen if they exceed the range. In the case of cublas though there is no need of concern for now. The smallest type in cublas is float and int can address a little more than 8 GB of floats which exceeds the memory sizes of the current GPUs.
Stan