PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

how to link with pgCC to fortran that is using openACC

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
John Wohlbier



Joined: 28 Nov 2012
Posts: 5

PostPosted: Wed Nov 28, 2012 4:19 pm    Post subject: how to link with pgCC to fortran that is using openACC Reply with quote

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
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 5952
Location: The Portland Group Inc.

PostPosted: Wed Nov 28, 2012 4:50 pm    Post subject: Reply with quote

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
Back to top
View user's profile
John Wohlbier



Joined: 28 Nov 2012
Posts: 5

PostPosted: Thu Nov 29, 2012 11:19 am    Post subject: Reply with quote

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
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 5952
Location: The Portland Group Inc.

PostPosted: Thu Nov 29, 2012 11:39 am    Post subject: Reply with quote

Quote:
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
Back to top
View user's profile
John Wohlbier



Joined: 28 Nov 2012
Posts: 5

PostPosted: Thu Nov 29, 2012 2:18 pm    Post subject: Reply with quote

mkcolg wrote:
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.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group