f2c.h calling in CUDA

i have a c code that often calls clapack function dgesv_(&nneq, &nrhs, aa, &lda, iwork, f, &lda, &info).
please note that it requires both “f2c.h” and “clapack.h”
I have NO problem for the c code under regular c environment using VS2005.

for my CUDA project, I started from files in C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\src\template
that is, I have modified template.cu in the directory to have a hybrid code of c and CUDA.
at this stage, the code is not 100% CUDA yet. therefore, part of job is done on CPU (c part) and part of it is done by GPU (CUDA.)

of course, the c routine calling dgesv_ is in c part.

Since I am using the existing CUDA template in the example directory using VS2005, I added the following lines:

template property>>linker>>input>>additional dependencies:
clapack.lib clapackd.lib blas.lib blasd.lib cudart.lib cutil32.lib cublas.lib cutil32D.lib

my question is this.

previously written c code, as I mentioned, has no error…
but with CUDA, I start to get the followings:

error: argument of type “int *” is incompatible with parameter of type :integer *"
and the line locates where I am calling dgesv_ .

i think it is related to the project properties of template in C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\src\template
but, could not figure out exactly what it is.

any experience on the issue?

please any comments are welcome and THANK YOU in well advance.

It is probably a good idea to separate your Cuda code into an extra file. nvcc uses quite a bit of C++ trickery to turn a normal C++ compiler into what appears as a compiler for Cuda C. Similarly for the f2c headers. So it is probably not worth trying to sort out all their bad interactions. Just make sure that any source file includes only one or the other, which also means not to run any file including f2c.h through nvcc.

Just wrap every Cuda call inside a C function (don’t forget to declare it [font=“Courier New”]extern “C”[/font]) that you call from the f2c-generated code.

many thanks for your advice…

it all came down to this.

i have a cuda code running with no problem.

then i am going to include a c code that calls clapack routine

dgesv_(&nneq, &nrhs, aa, &lda, iwork, f, &lda, &info);

and this c code requires two header files; “f2c.h” and “clapack.h”

the first error i got was

argument of type “int *” is incompatible with parameter of type “interger *”

then i try the following;

dgesv_((integer *)&nneq, (integer *)&nrhs, aa, (integer *)&lda, (integer *)iwork, f, (integer *)&lda, (integer *)&info);

then error

LNK2001: unresolved external symbol "int cdecl dgesv(long *, long *, double *, long *, long *, double *, long *, long *)

the thing is that this conversion is no problem in regular c working environment. this error comes up only with cuda and c environment.

whats why i put up this in this forum. otherwise i should have put it on c forum…

any experience on this issue? again any advice is really appreciated.