Compiling Fortran CUBLAS example

Hello,

First of all, I would like to highlight the fact that I am a total newby in the CUDA area…:)
I am currently struggling a lot trying to compile the Fortran CUBLAS example (Fortran_Cuda_Blas.tgz) under Windows XP with Microsoft Visual Studio 2005 (using Intel Fortran Compiler).
I have linked my code with the library “cublas.lib” but I still obtain this :

"
1>Compiling with Intel® Fortran Compiler 10.1.011 [IA-32]…
1>sgemm_speed.f90
1>D:\Projects\CUDA\ICUBLAS\sgemm_speed.f90(37) : Warning: Bad # preprocessor line
1>D:\Projects\CUDA\ICUBLAS\sgemm_speed.f90(39) : Warning: Bad # preprocessor line
1>D:\Projects\CUDA\ICUBLAS\sgemm_speed.f90(41) : Warning: Bad # preprocessor line
1>Linking…
1>sgemm_speed.obj : error LNK2019: unresolved external symbol CUBLAS_SGEMM referenced in function MAIN
1>sgemm_speed.obj : error LNK2019: unresolved external symbol SGEMM referenced in function MAIN
1>Debug\icublas.exe : fatal error LNK1120: 2 unresolved externals
"

I am quit sure it s because I don t manage to link with the fortran.o (*) needed :rolleyes: …

I would be very grateful if someone could have the start of the beginning of a solution for me… thanks

(*): this should be the object file result of the utility code “fortran.c” which takes care of the name mangling and decoration of different Fortran compilers.

Maybe you can try to change in your code CUBLAS_SGEMM with cublasSgemm. The function defintions appears to be different than the fortran sample code.

I had a similar problem. i was trying to call a cublas function (say sgemm for now) from fortran.

[codebox]SUBROUTINE DGEMM ( TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB,

 $                   BETA, C, LDC )

  external CUBLAS_DGEMM 

  CALL CUBLAS_DGEMM( TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB,

 $                   BETA, C, LDC )

  END[/codebox]

because fortran is case INsensitive it automatically converts it to _cublas_dgemm before calling the fortran.c function. Note there is underscore BEFORE the function. this is something that fortran always does when calling functions.

Now if this doesnt fix the problem (which i dont think did for me). the dodgy way of fixing it is get rid of all the defenitions for the different compilers (comment them out) and add

define CUBLAS_FORTRAN_COMPILER CUBLAS_G77

at the end of the commented out block

let me know if this helps