PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

Linking CUDA Fortran and gfortran or ifort

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



Joined: 18 Jan 2011
Posts: 4

PostPosted: Mon Jan 23, 2012 9:32 am    Post subject: Linking CUDA Fortran and gfortran or ifort Reply with quote

Hi,

I have a simple program. I don't have idea to link the file.
Please help me.

Here is my program and make file.
main.f
Code:

   program main
   integer*4 i,j,k
   i=10
   j=5
   call pgfor(i,j,k)
   write(*,*) i,j,k
   end

pgfor.cuf
Code:

   subroutine pgfor(a,b,c)
   integer*4 a,b,c
   c=a*b
   end subroutine

makefile
Code:

Test: main.f pgfor.o
   ifort main.f pgfor.o
pgfor.o: pgfor.cuf
   pgfortran -c pgfor.cuf
clean:
   rm a.out pgfor.o pgfor.linkinfo

I am getting the following error in this case of ifort
ifort main.f pgfor.o
pgfor.o:(.data+0x0): undefined reference to `pgf90_compiled'
make: *** [Test] Error 1

in case of gfortran
gfortran main.f pgfor.o
pgfor.o:(.data+0x0): undefined reference to `pgf90_compiled'
collect2: ld returned 1 exit status
make: *** [Test] Error 1

in case of pgfortran there is no error.

How to rectify this error?
Please help me.

I have an existing code in ifort. I want to
include some pgfortran code to make it run faster.

regards
panch
Back to top
View user's profile
Panch



Joined: 18 Jan 2011
Posts: 4

PostPosted: Tue Jan 24, 2012 4:31 am    Post subject: Reply with quote

I have rectified the things using the following make file.
Code:

Test: main.f pgfor.o
   ifort -L /opt/pgi/linux86-64/2011/cuda/4.0/lib64 -lcudart -L /opt/pgi/linux86-64/2011/libso -lcudafor -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl  -lpgc main.f pgfor.o
pgfor.o: pgfor.cuf
   pgfortran -c -O3 pgfor.cuf
clean:
   rm a.out pgfor.o pgfor.linkinfo

But right now I am getting the segmentation fault.
Back to top
View user's profile
mkcolg



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

PostPosted: Fri Feb 03, 2012 10:30 am    Post subject: Reply with quote

Hi Panch,

If you are writing F90 code, constructs such as modules and allocable arrays contain formats that are unique to each compiler vendor. Hence, it is best to compile all F90 code using a single compiler vendor.

For simple F77 code, then you usually can get various compilers working together. However, for CUDA Fortran, Intel and Gfortran compiled objects aren't compatible. You can try encapsulating the CUDA Fortran code into a library and then write an F77 interface routine, but it would be far simpler to compile all your Fortran source with PGI.

- Mat
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