Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: Re: [OMPI users] MPI + Mixed language coding(Fortran90 + C++)
From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2008-11-03 14:54:25


Can you replicate the scenario in smaller / different cases?

- write a sample plugin in C instead of C++
- write a non-MPI Fortran application that loads your C++ application
- ...?

In short, *MPI* shouldn't be interfering with Fortran/C++ common
blocks. Try taking MPI out of the picture and see if that makes the
problem go away.

Those are pretty much shots in the dark, but I don't know where to go,
either -- try random things until you find what you want.

On Nov 3, 2008, at 3:51 AM, Rajesh Ramaya wrote:

> Helllo Jeff, Gustavo, Mi
> Thank for the advice. I am familiar with the difference in the
> compiler code generation for C, C++ & FORTRAN. I even tried to look
> at some of the common block symbols. The name of the symbol remains
> the same. The only difference that I observe is in FORTRAN compiled
> *.o 0000000000515bc0 B aux7loc_ and the C++ compiled code U
> aux7loc_ the memory is not allocated as it has been declared as
> extern in C++. When the executable loads the shared library it finds
> all the undefined symbols. Atleast if it did not manage to find a
> single symbol it prints undefined symbol error.
> I am completely stuck up and do not know how to continue further.
>
> Thanks,
> Rajesh
>
> From: users-bounces_at_[hidden] [mailto:users-bounces_at_[hidden]]
> On Behalf Of Mi Yan
> Sent: samedi 1 novembre 2008 23:26
> To: Open MPI Users
> Cc: 'Open MPI Users'; users-bounces_at_[hidden]
> Subject: Re: [OMPI users] MPI + Mixed language coding(Fortran90 + C++)
>
> So your tests show:
> 1. "Shared library in FORTRAN + MPI executable in FORTRAN" works.
> 2. "Shared library in C++ + MPI executable in FORTRAN " does not work.
>
> It seems to me that the symbols in C library are not really
> recognized by FORTRAN executable as you thought. What compilers did
> yo use to built OpenMPI?
>
> Different compiler has different convention to handle symbols. E.g.
> if there is a variable "var_foo" in your FORTRAN code, some FORTRN
> compiler will save "var_foo_" in the object file by default; if you
> want to access "var_foo" in C code, you actually need to refer
> "var_foo_" in C code. If you define "var_foo" in a module in the
> FORTAN compiler, some FORTRAN compiler may append the module name to
> "var_foo".
> So I suggest to check the symbols in the object files generated by
> your FORTAN and C compiler to see the difference.
>
> Mi
> <image001.gif>"Rajesh Ramaya" <rajesh.ramaya_at_[hidden]>
>
>
> "Rajesh Ramaya" <rajesh.ramaya_at_[hidden]>
> Sent by: users-bounces_at_[hidden]
> 10/31/2008 03:07 PM
>
> Please respond to
> Open MPI Users <users_at_[hidden]>
> <image002.gif>
> To
> <image003.gif>
> "'Open MPI Users'" <users_at_[hidden]>, "'Jeff Squyres'" <jsquyres_at_[hidden]
> >
> <image002.gif>
> cc
> <image003.gif>
> <image002.gif>
> Subject
> <image003.gif>
> Re: [OMPI users] MPI + Mixed language coding(Fortran90 + C++)
>
> <image003.gif>
> <image003.gif>
>
> Hello Jeff Squyres,
> Thank you very much for the immediate reply. I am able to
> successfully
> access the data from the common block but the values are zero. In my
> algorithm I even update a common block but the update made by the
> shared
> library is not taken in to account by the executable. Can you please
> be very
> specific how to make the parallel algorithm aware of the data?
> Actually I am
> not writing any MPI code inside? It's the executable (third party
> software)
> who does that part. All that I am doing is to compile my code with
> MPI c
> compiler and add it in the LD_LIBIRARY_PATH.
> In fact I did a simple test by creating a shared library using a
> FORTRAN
> code and the update made to the common block is taken in to account
> by the
> executable. Is there any flag or pragma that need to be activated
> for mixed
> language MPI?
> Thank you once again for the reply.
>
> Rajesh
>
> -----Original Message-----
> From: users-bounces_at_[hidden] [mailto:users-bounces_at_[hidden]]
> On
> Behalf Of Jeff Squyres
> Sent: vendredi 31 octobre 2008 18:53
> To: Open MPI Users
> Subject: Re: [OMPI users] MPI + Mixed language coding(Fortran90 + C++)
>
> On Oct 31, 2008, at 11:57 AM, Rajesh Ramaya wrote:
>
> > I am completely new to MPI. I have a basic question concerning
> > MPI and mixed language coding. I hope any of you could help me out.
> > Is it possible to access FORTRAN common blocks in C++ in a MPI
> > compiled code. It works without MPI but as soon I switch to MPI the
> > access of common block does not work anymore.
> > I have a Linux MPI executable which loads a shared library at
> > runtime and resolves all undefined symbols etc The shared library
> > is written in C++ and the MPI executable in written in FORTRAN. Some
> > of the input that the shared library looking for are in the Fortran
> > common blocks. As I access those common blocks during runtime the
> > values are not initialized. I would like to know if what I am
> > doing is possible ?I hope that my problem is clear......
>
>
> Generally, MPI should not get in the way of sharing common blocks
> between Fortran and C/C++. Indeed, in Open MPI itself, we share a few
> common blocks between Fortran and the main C Open MPI implementation.
>
> What is the exact symptom that you are seeing? Is the application
> failing to resolve symbols at run-time, possibly indicating that
> something hasn't instantiated a common block? Or are you able to
> successfully access the data from the common block, but it doesn't
> have the values you expect (e.g., perhaps you're seeing all zeros)?
>
> If the former, you might want to check your build procedure. You
> *should* be able to simply replace your C++ / F90 compilers with
> mpicxx and mpif90, respectively, and be able to build an MPI version
> of your app. If the latter, you might need to make your parallel
> algorithm aware of what data is available in which MPI process --
> perhaps not all the data is filled in on each MPI process...?
>
> --
> Jeff Squyres
> Cisco Systems
>
>
> _______________________________________________
> users mailing list
> users_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/users
>
> _______________________________________________
> users mailing list
> users_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/users
>
> _______________________________________________
> users mailing list
> users_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/users

-- 
Jeff Squyres
Cisco Systems