PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

mixed language programming using fortran c++ and openmp

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



Joined: 09 Jun 2005
Posts: 1

PostPosted: Fri Mar 17, 2006 2:20 am    Post subject: mixed language programming using fortran c++ and openmp Reply with quote

Hello
I have extended a scientific model code written in fortran 90 with a submodel written in c++.
The model couppling works fine using portland 6.0 and 6.1 compilers.

The model written in fortran code is parallelized with openmp directives and is working fine on my dual opteron x2 workstation without the c++ code.

Some general questions on how to tackle the openmp parallelization of the coupled model:

I have no openmp directives in the c++ model. When compiling the coupled model, do I have to set the compiler flags
-mp -Mnosgimp
to the fortran and the c++ compiler flags???
I did so and after quite some time solving the problem with the libnuma openmp http://www.pgroup.com/userforum/viewtopic.php?t=431&highlight=libnuma
I get an executable. The main differentes in the coupled model are the local libraries which are extended to suit the c++ programms

Using our standard setup
export OMP_NUM_THREADS=4
export _DSM_PLACEMENT=ROUND_ROBIN
export _DSM_WAIT=SPIN
export OMP_DYNAMIC=FALSE
export MPC_GANG=OFF
I run the resulting code and get the message:

Warning: OMP_NUM_THREADS or NCPUS (4) greater than available cpus (1)

The programm stalls at this point and eats one processors performance without getting anyfurther...
If I set
export OMP_NUM_THREADS=1
the code runs fine.

My question is in generally, is it posible to parallelize a mixed fortran c++ code???
Back to top
View user's profile
mkcolg



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

PostPosted: Fri Mar 17, 2006 1:25 pm    Post subject: Reply with quote

Hi Edwin,

Quote:
I have no openmp directives in the c++ model. When compiling the coupled model, do I have to set the compiler flags
-mp -Mnosgimp
to the fortran and the c++ compiler flags???


You only need compile those source files which contain OpenMP directives with "-mp" so mixing Fortran code which use OpenMP and C++ code which does not should work fine. Granted, I have not tested this myself so if it doesn't work I'd consider it a bug. Note that you do need to link with "-mp".
Quote:

I did so and after quite some time solving the problem with the libnuma openmp http://www.pgroup.com/userforum/viewtopic.php?t=431&highlight=libnuma
I get an executable.

Since this problem had to do with statically linking the Numa libraries, have you tried linking dynamically?

Quote:

Warning: OMP_NUM_THREADS or NCPUS (4) greater than available cpus (1)

The programm stalls at this point and eats one processors performance without getting anyfurther...

This warning is letting you know that you're running 4 threads on a system which only has 1 CPU. The question is why only one CPU is being recognized.?

Can you try rerunning without your standard set-up variables and only set OMP_NUM_THREADS?
Quote:

My question is in generally, is it posible to parallelize a mixed fortran c++ code???

It should. If it doesn't, it's a bug. Would you be able to send the code to trs@pgroup.com?

Thanks,
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