Does anyone know how to call the cusparse library using FORTRAN? I can do this in C but I have a large FORTRAN application that I would like to integrate to the GPU via CUDA. As you can guess, calling a sparse matrix-vector operation from FORTRAN using an external C-Function can be problematic generally due to the indexing differences (C base-0, and FORTRAN base-1 and column-major).
Especially helpful would be some simple sparse matrix-vector using CSR via cusparse library with pure FORTAN - if possible. If not, how do most people deal with external calls to cusparse library in CUDA from FORTRAN with the indexing/order differences between FORTRAN and C?
Storage layouts and Fortran bindings are described in the CUSPARSE documentation. Dense matrices are stored in column-major format, just like in CUBLAS and in Fortran. Sparse matrices are stored in CSR storage format with matrix indices first sorted by row and then within every row by column. The CUSPARSE documentation is available online here:
Thank you for the response. You are correct, the documentation for CUSPARSE using FORTRAN is very clear about how to interface.
I should have spent more time to read the literature on the subject first, my bad.
However, I cannot use CUSPARSE due to the needed compute ability of at least 1.1 - the device I use is Quadro FX 5600 with a compute ability of 1.0. Thus I must figure out another way to do the CSR storage format with FORTRAN-90 bindings. Is this already written in CUDA somewhere? If so, can you point me in the right direction?
I had thought about that but I think I will try and take it slow and see instead what kind of Fortran bindings there are for cuBLAS. I found the fortran.cu file and have been looking it over - I hope to use some of the Fortran bindings in this file. In particular the cublas_sdot call.