Compiling CUDA with gfortran on Windows

Hi,

I have a working makefile to compile Fortran with CUDA on Linux. After changing all the environmental variables and makefile’s paths for Windows, same makefile seems like it works on Windows too. I don’t get any errors while compiling. But while running the executable, any kernel (even with a one line code) throws an “invalid device function” error. I have to compile the same program to work on Windows, so it’s a little bit crucial.

I really couldn’t understand “invalid device function” error. But according to this thread [topic=“0”]Invalid Device Function[/topic], it looks like I have some compiling or linking problems.

My makefile is simply like below;

[codebox]gcc -D_UF -O3 -c *.c

gfortran -c *.f

nvcc -c -arch sm_13 cuda.cu

gfortran -o program *.o cuda.obj -LC:/CUDA/lib/ -lcudart[/codebox]

  • I use MSYS so, -L option’s path slashes are different but it works that way.

  • FYI, I use double variables and I have a GTX 280. Even though while working with a one line kernel, my 8800 gives the same error.

Have you declared things with extern “C”?

Yes, the code works just fine on Linux. On Windows it compiles perfectly but kernels don’t launch, even the simplest ones. I started to think maybe I’m missing some options for the compiler but nvcc doesn’t seems like it supports linking with any other compiler than cl.exe (on Windows). But why isn’t there a compile error instead of meaningless “invalid device function” error…

That error drove me to suspect that have I done something wrong? I really appreciate if someone assures it’s a compatibility error or not…

Thanks…

Note: I tried fortran-cuda example on Cuda website. I changed its makefile, it also compiles without problem but kernels don’t launch. Anybody can try and regenerate the problem I think also if needed I can attach the edited makefile for it.