calling cusparseinit and cublasinit from fortran

Hi

I hope you are doing good. i am trying to make a function inside a fortran code from which i wish to call the cusparse and cublas initialization functions.

This is because i notice that initialising these libraries everytime requires quite some time (around 1-2 secs) when my entire application runs in 0.25 secs. Also since i am doing this inside a time loop i want to avoid doing initialisation every timestep as otherwise i have to count this time in my timing results.

I have read about the fortran wrappers that are provided in cusparse_fortran.c and fortran.c but i cannot seem to be able to compile them since i use ifort 13.1.1 20130313 and i get an error when i include the fortran.c in my makefile

In file included from fortran.c:67:
fortran_common.h:405:2: error: #error unsupported Fortran compiler

I know how to make a wrapper in C which can be called from fortran but now i wish to move a cusparse call into fortran code and i do not know how can the handles (which are structures in C) be declared in fortran then passed to a subroutine in fortran where the handles are instantiated and later pointers to these handles are passed to a wrapper routine which uses these handles to do some blas and cusparse operations.

///////////general structure of what i want to do

Fortran code

! declare cusparseHandle_t cuprshndl and cublasHandle_t cublshndl
! call initiate_handles (cuprshndl, cublshndl)

! call c_wrapper(…, …, …, ccuprshndl, cublshndl)

C code

c_wrapper(…, …, …, *ccuprshndl, *cublshndl)
{
// calls different cublas functions and cusparse functions using these handles passed from the fortran code.

}
}

Just change the line in host_config.h:
#if __ICC != 1110 || !defined(GNUC) || !defined(LP64)

to
#if __ICC < 1110 || !defined(GNUC) || !defined(LP64)

It is a stupid check.

[s]The above test for the Intel compiler version number checks whether the code is being compiled with the particular version of the Intel compiler that is officially supported by CUDA (compare the CUDA 5.0 release notes). Only supported versions are tested as part of the release process.

Changing the code as suggested by mfatica will allow the code to compile with all previous versions of the Intel compiler. Any issues triggered by the use of an unsupported version of the compiler are the sole responsibility of the programmer making this change.[/s]

Strike that. The CUDA 5.0 release notes state that the supported version of ICC is 12.x, and I do not see how the version check for ICC version 11.1 in the above code relates to that.

Hi njuffa, mfatica

i tried using version 12.1 it didn’t work with that too. i still get the unsupported compiler error. i forgot to mention this is a 64 bit edition of the compiler that i am using. Also my code uses MPI so i basically call mpif90.

rohit

Hi

I was able to make it work with a suggestion mentioned here

http://stackoverflow.com/questions/14378868/cant-compile-magma-1-3-on-ubuntu-10-04-cuda-5-0

if you just comment out those lines it seems to compile with the following toolchain

intel compiler 13.1.1 20130313
intel mkl 11.0/2013_3.163
openmpi 1.4.4 (for intel)
cuda 5.0

this configuration wqs run on a cluster with dual quad core processors from intel and GTX480 cards.

rohit