[mpich-discuss] How does the fortran binding work?
Ruini Xue
xueruini at gmail.com
Wed Jul 30 20:17:10 CDT 2008
Here is a link which illustrate this topic:
http://www.netlib.org/utk/papers/mpi-book/node190.html
All C version MPI_XXXX() are defined as *weak symbols* to PMPI_XXXX(), which
means that if there is no MPI_XXX() definition, the
user application would use the coresponding PMPI_XXX(). The figure also
shows that in normal case (without profiling), PMPI_Bcast()
do all the real work (see MPI_Bcast()--->PMPI_Bcast()) because MPI_Bcast()
is not defined yet, otherwise (with profiling), since MPI_Send() is provided
by the profiling lib, use app would be linked to the MPI_Send() in profiling
lib, which in turn calls the original PMPI_Send(). So, I think it's
PMPI_XXX() do all the work internally, both C and Fortran bindings calls
PMPI_XXX().
Now let check code. There a piece of code from: src/mpi/pt2pt/bsend.c
///////////////////////////////////////////////////////////
/* -- Begin Profiling Symbol Block for routine MPI_Bsend */
#if defined(HAVE_PRAGMA_WEAK)
#pragma weak MPI_Bsend = PMPI_Bsend
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
#pragma _HP_SECONDARY_DEF PMPI_Bsend MPI_Bsend
#elif defined(HAVE_PRAGMA_CRI_DUP)
#pragma _CRI duplicate MPI_Bsend as PMPI_Bsend
#endif
/* -- End Profiling Symbol Block */
/* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build
the MPI routines */
#ifndef MPICH_MPI_FROM_PMPI
#undef MPI_Bsend
#define MPI_Bsend PMPI_Bsend
#endif
#undef FUNCNAME
#define FUNCNAME MPI_Bsend
//////////////////////////////////////////////////////////////////////////
It seems that if #pragma weak is supported, MPI_Bsend is weakly defined to
PMPI_Bsend, otherwise MPI_Bsend is defined to
PMPI_Bsend via macro. That's to say, MPI_Bsend always does nothing, but is
mapped to PMPI_Bsend. This is the C binding version.
For fortran binding, check src/binding/f77/bsendf.c:
//////////////////////////////////////////////////////////////////////
FORT_DLL_SPEC void FORT_CALL mpi_bsend_ ( void*v1, MPI_Fint *v2, MPI_Fint
*v3, MPI_Fint *v4, MPI_Fint *v5, MPI_Fint *v6, MPI_Fint *ierr ){
*ierr = MPI_Bsend( v1, *v2, (MPI_Datatype)(*v3), *v4, *v5,
(MPI_Comm)(*v6) );
}
/////////////////////////////////////////////////////////////////////
It seems that the fortran binding calls the C binding directly, but actually
MPI_Bsend() is PMPI_Bsend().
I am not sure whether I describe and analysis it accurately.
Best
Andrew
On Thu, Jul 31, 2008 at 2:11 AM, Jayesh Krishna <jayesh at mcs.anl.gov> wrote:
> >> Looks like the Fortran interface does call the MPI version of the C
> function.
>
> Only if the call is from PMPI_* funcs. (If the MPI call is not from PMPI,
> MPI_* funcs get defined to PMPI_*)
>
> >> If the fortran binding calls PMPI version of C function...
>
> In windows this currently does not work (I guess, it is due to the
> different calling convention/name mangling by the mpe lib and the fortran
> lib in windows) :( Defenitely a TODO item :)
>
> Regards,
> Jayesh
>
> -----Original Message-----
> From: owner-mpich-discuss at mcs.anl.gov [
> mailto:owner-mpich-discuss at mcs.anl.gov <owner-mpich-discuss at mcs.anl.gov>]
> On Behalf Of Rajeev Thakur
> Sent: Wednesday, July 30, 2008 12:42 PM
> To: mpich-discuss at mcs.anl.gov
> Subject: RE: [mpich-discuss] How does the fortran binding work?
>
> Looks like the Fortran interface does call the MPI version of the C
> function.
>
>
> > -----Original Message-----
> > From: owner-mpich-discuss at mcs.anl.gov
> > [mailto:owner-mpich-discuss at mcs.anl.gov<owner-mpich-discuss at mcs.anl.gov>]
> On Behalf Of Anthony Chan
> > Sent: Wednesday, July 30, 2008 12:01 PM
> > To: mpich-discuss at mcs.anl.gov
> > Subject: Re: [mpich-discuss] How does the fortran binding work?
> >
> > If the fortran binding calls PMPI version of C function, can the
> > fortran MPI program still be profiled ?
> >
> > ----- "Rajeev Thakur" <thakur at mcs.anl.gov> wrote:
> >
> > > The Fortran binding calls the PMPI version of the C function.
> > >
> > > Rajeev
> > >
> > > > -----Original Message-----
> > > > From: owner-mpich-discuss at mcs.anl.gov
> > > > [mailto:owner-mpich-discuss at mcs.anl.gov<owner-mpich-discuss at mcs.anl.gov>]
> On Behalf Of Anthony Chan
> > > > Sent: Wednesday, July 30, 2008 9:46 AM
> > > > To: mpich-discuss at mcs.anl.gov
> > > > Cc: mpich-discuss at mcs.anl.gov
> > > > Subject: Re: [mpich-discuss] How does the fortran binding work?
> > > >
> > > >
> > > > No. PMPI is the MPI profiling interface and is standardized by
> > > > the MPI forum.
> > > > Fortran/C++ MPI binding just calls the C MPI routine.
> > > >
> > > > A.Chan
> > > >
> > > > ----- "Ruini Xue" <xueruini at gmail.com> wrote:
> > > >
> > > > > On Wed, Jul 30, 2008 at 8:54 PM, Dave Goodell <
> > > > goodell at mcs.anl.gov >
> > > > > wrote:
> > > > >
> > > > >
> > > > > Hi Andrew,
> > > > >
> > > > > Yes, the fortran and c++ bindings are just wrappers over the C
> > > > > bindings. The C binding implements the functionality directly.
> > > > >
> > > > > Are they wrappers of MPI_XXX() or PMPI_XXX()?
> > > > >
> > > > > Best
> > > > >
> > > > > Andrew
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > -Dave
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > On Jul 30, 2008, at 6:11 AM, Ruini Xue wrote:
> > > > >
> > > > >
> > > > >
> > > > > Hello, everyone,
> > > > >
> > > > > I am working with MPICH2 on Windows platfrom. The fortran MIP
> > > > > application is linked to fmpich.lib, and fmpich2.dll is
> > loaded in
> > > > > runtime, which in turn loads mipch2mpi.dll.
> > > > > mpich2mpi.dll contains all MPI APIs which exported C
> > > > interface. What I
> > > > > want to know is: what is the 'underlying' relation between
> > > > fmpich2.dll
> > > > > and mpich2mip.dll? Do all
> > > > > Fortran MPI calls are converted to c bindings in mpich2mpi.dll?
> > > For
> > > > > example, does MPI_BCAST() in fmich2.dll directly calls
> > > > MPI_Bcast() in
> > > > > mpich2mpi.dll? Is MPI_BCAST() just a stub while MPI_Bcast() do
> > > the
> > > > > real job?
> > > > >
> > > > > Thanks
> > > > >
> > > > > Andrew
> > > >
> > > >
> >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/mpich-discuss/attachments/20080731/ef7fb574/attachment.htm>
More information about the mpich-discuss
mailing list