PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

CUDA Fortran: how to use CUDA Fortran in Fortran90 projects
Goto page 1, 2  Next
 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
Chinacxt



Joined: 19 Sep 2012
Posts: 9

PostPosted: Wed Oct 10, 2012 10:44 pm    Post subject: CUDA Fortran: how to use CUDA Fortran in Fortran90 projects Reply with quote

Hi,

I am currently improving one large Fortran90 project using CUDA Fortran. The problem is that I want to redesign some modules using CUDA Fortran, but the new modules which are compiled by the pgf90 cannot be used in original fortran90 codes directly.
It seems like that gfortran can only use its own module files.

This may be a common problem, I think. Is there any good approach to solve this?

Thanks~
chengxuntao@gmail.com
Back to top
View user's profile
mkcolg



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

PostPosted: Thu Oct 11, 2012 9:32 am    Post subject: Reply with quote

Hi Chinacxt,

F90 modules are not compatible across Fortran compilers. You will need to compile your entire Fortran project using PGI or redesign your project so that mixing modules in not necessary.

- Mat
Back to top
View user's profile
Chinacxt



Joined: 19 Sep 2012
Posts: 9

PostPosted: Thu Oct 11, 2012 8:03 pm    Post subject: Reply with quote

mkcolg wrote:
Hi Chinacxt,

F90 modules are not compatible across Fortran compilers. You will need to compile your entire Fortran project using PGI or redesign your project so that mixing modules in not necessary.

- Mat


HI, mkcolg

Thanks for your reply.
Is it possible to compile the .cuf into .o and then linke this .o together with other f90 .o files? This method works in 'Calling CUDA C in Fortran'. I am trying this but many error messages show up during linking.
Back to top
View user's profile
mkcolg



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

PostPosted: Fri Oct 12, 2012 7:45 am    Post subject: Reply with quote

Hi Chinacxt,

If you compile all your F90 files with PGI, then yes CUDA Fortran and F90 objects are compatible. However, F90 features such as allocatable arrays and modules are not compatible across compiler vendors so you would not be able to compile the F90 objects with gfortran or ifort.

However what you can do is write an interface layer that does not use these F90 features (basically F77) and can act as a bridge between the two objects. Granted, it's easier to just compile with PGI, but if you're looking to write a library that can be used with any compiler, then this is what you'd need to do.

Quote:
This method works in 'Calling CUDA C in Fortran'. I am trying this but many error messages show up during linking.
I'm not clear on the question. What are you trying to do and what error messages are you getting?

- Mat
Back to top
View user's profile
Chinacxt



Joined: 19 Sep 2012
Posts: 9

PostPosted: Sun Oct 14, 2012 7:31 pm    Post subject: Reply with quote

mkcolg wrote:
Hi Chinacxt,

If you compile all your F90 files with PGI, then yes CUDA Fortran and F90 objects are compatible. However, F90 features such as allocatable arrays and modules are not compatible across compiler vendors so you would not be able to compile the F90 objects with gfortran or ifort.

However what you can do is write an interface layer that does not use these F90 features (basically F77) and can act as a bridge between the two objects. Granted, it's easier to just compile with PGI, but if you're looking to write a library that can be used with any compiler, then this is what you'd need to do.

Quote:
This method works in 'Calling CUDA C in Fortran'. I am trying this but many error messages show up during linking.
I'm not clear on the question. What are you trying to do and what error messages are you getting?

- Mat


Thank you.
I've decided to compile all codes using pgfortran. But a new problem shows up.
A lot of this kind of error messages show up when I am using pgfortran to compile some .f90 codes. Some subroutines cannot reference to others due to the "underscore" appended, I think.
Code:
"m_common_struct.F90:(.data+0x12c): undefined reference to `fox_utils_'
m_common_struct.F90:(.data+0x154): undefined reference to `fox_m_utils_mtprng_'
m_common_struct.F90:(.data+0x15c): undefined reference to `fox_m_utils_uuid_'
m_common_struct.F90:(.data+0x164): undefined reference to `fox_m_fsys_array_str_'
m_common_struct.F90:(.data+0x184): undefined reference to `fox_m_utils_uri_'
"

Pgfrotran appends underscores to all global names when compiling, right? Since I use it to compile all codes, there should be no dis-match about underscores. So, I don't understand why this happens.
Would you please explain to me the 'underscore' mechanism?
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
Goto page 1, 2  Next
Page 1 of 2

 
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