how to link with pgCC to fortran that is using openACC

I’m trying to link my program with pgCC. The program has fortran code that uses OpenACC. I get unresolved symbols like:

undefined reference to `__pgi_cu_close’

I found libacc1.a and libacc1cu.a contain some of the missing symbols, but if I link with both of those I get multiply defined symbols. Can you tell me which libraries I should link to?

PGI 12.9.0

Thanks

Hi John,

Until 13.0 is out next week and we have OpenACC support in C++, the easiest thing to do would be to use the Fortran driver, pgfortran, to link. You can then just add the flag “-acc” to link OpneACC, “-pgcpplibs” to get the C++ libraries, and “-Mnomain”.

“pgfortran -acc -Mnomain -pgcpplibs …object files…”.

Hope this helps,
Mat

When mixing C++ and fortran CMake chooses the C++ compiler for the linker. I’d prefer to stick with it’s choice. But this does result in some head standing, including manually specifying the f90main.o file in the link line, and the manual addition of the accelerator libraries. I found by trial and error that if I link
-lacc1cump -lacc1mp -lacc1
then the symbols all get resolved.

So my link line looks something like:
/projects/opt/pgi/linux86-64/12.9/bin/pgCC -mp -g -O0 /projects/opt/pgi/linux86-64/12.9/lib/f90main.o ${OBJECTS} -o ${EXE} -lacc1cump -lacc1mp -lacc1 /projects/opt/cuda/cuda-5.0/lib64/libcudart.so -lcuda /home/mpi/openmpi/1.5.3-gcc-4.5.1-mar.16.11/lib/libmpi_cxx.so /home/mpi/openmpi/1.5.3-gcc-4.5.1-mar.16.11/lib/libmpi.so -ldl -lnsl -lutil -lm -ldl -lnsl -lutil -lm -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lrt -Wl,-rpath,/projects/opt/cuda/cuda-5.0/lib64:/home/mpi/openmpi/1.5.3-gcc-4.5.1-mar.16.11/lib

I’d prefer to stick with it’s choice.

That’s fine. You can simplify things a bit by using “-pgf90libs” instead of listing out " -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl"

  • Mat

CMake picks up all of those libraries. I’m not sure about the mechanics of it, but the fewer things like that I have to maintain the better.