multiple module management with cuda fortran?

As far as I can tell, in order for a module meant to be a cuda kernel to compile properly, it has to be included in a program initially and it can’t be compiled on its own in a separate *.f because it will give an error such as:

[leiderml@ebwilson-mpi ~]$ pgfortran -Mcuda=cc20 cudaCase8.f
/shared/pgi/linux86-64/11.5/lib/f90main.o: In function main': f90main.c:(.text+0x3c): undefined reference to MAIN_’

But after the module has been compiled it appears you can remove the module code from the same *.f file that contains your main program as long as you don’t need to change the module.

Is there a way to keep my cuda modules in entirely separate *.f files from the main program but still have them compile properly? I’m at the point where I’m going to have my main program calling into 9 different cuda modules depending on which code path is taken, and I’d really like to break up the extra 10,000 lines of code into different files to keep it more manageable while I’m doing my testing and debugging.


Thanks!
Morgan

Hi Morgan,

leiderml@ebwilson-mpi ~]$ pgfortran -Mcuda=cc20 cudaCase8.f
/shared/pgi/linux86-64/11.5/lib/f90main.o: In function main': f90main.c:(.text+0x3c): undefined reference to MAIN_’

You just need to add the “-c” flag to tell the compiler to stop after compilation. This error just means that it tried to link your program but couldn’t find the main entry point.

Is there a way to keep my cuda modules in entirely separate *.f files from the main program but still have them compile properly?

Sure. Compile the files with “-c” and then add the resulting object file (.o) to the final link line.

Hope this helps,
Mat