[mpich-discuss] f77 bindings and profiling

Junchao Zhang jczhang at mcs.anl.gov
Tue Nov 18 12:40:01 CST 2014


Florin,
  As we discussed, it looks your aim is to provide MPI profiling
(implemented in C) to Fortran+MPI code.
  Try this:  Implement your profiling layer in PMPI_Xxxx(), and call
MPI_Xxxx() in it. You do not need to change cases or add trailing
underscores. Then, insert your library after libmpifort.a,  before libmpi.a
in linking


--Junchao Zhang

On Tue, Nov 18, 2014 at 9:47 AM, Isaila, Florin D. <fisaila at mcs.anl.gov>
wrote:

> Hi,
>
> it works what Rajeev suggests, defining the C function as mpi_init_ (one
> underscore for g77). In this case I would need a wrapper for  and one for
> Fortran.
>
> However I understand from Section 14.2.1 of the MPI3 document (thanks
> Junchao for pointing to this) that I should be able to define just an
> MPI_Init wrapper in C and the call of MPI_Init(0, 0) from the Fortran
> implementation of mpi_init should be also redirected to my function.
>
> Pavan, I use MPICH-3.1.3. There is slight difference when I run the
> example you gave me, the libpmpi library does not appear:
> fisaila at howard:f77$ mpif77 -show fpi.f
> gfortran fpi.f -I/homes/fisaila/software/mpich/include
> -I/homes/fisaila/software/mpich/include -L/homes/fisaila/software/mpich/lib
> -lmpifort -Wl,-rpath -Wl,/homes/fisaila/software/mpich/lib
> -Wl,--enable-new-dtags -lmpi
>
> fisaila at howard:f77$ export PROFILE_PRELIB="-lfoo"
>
> fisaila at howard:f77$ mpif77 -show fpi.f
> gfortran fpi.f -I/homes/fisaila/software/mpich/include
> -I/homes/fisaila/software/mpich/include -L/homes/fisaila/software/mpich/lib
> -lmpifort -lfoo -Wl,-rpath -Wl,/homes/fisaila/software/mpich/lib
> -Wl,--enable-new-dtags -lmpi
>
> The mpi and mpifort have the following symbols:
>
> fisaila at howard:f77_program$ nm /homes/fisaila/software/mpich/lib/libmpi.a
> | grep MPI_Init
> 000000000000146d W MPI_Init
> 000000000000146d T PMPI_Init
>
>
> fisaila at howard:f77_program$ nm
> /homes/fisaila/software/mpich/lib/libmpifort.a | grep -i MPI_Init
> 0000000000000000 W MPI_INIT
> 0000000000000000 W PMPI_INIT
>                  U PMPI_Init
> 0000000000000000 W mpi_init
> 0000000000000000 W mpi_init_
> 0000000000000000 W mpi_init__
> 0000000000000000 W pmpi_init
> 0000000000000000 T pmpi_init_
> 0000000000000000 W pmpi_init__
>
> Thanks
> Florin
>
>
> ________________________________________
> From: Rajeev Thakur [thakur at mcs.anl.gov]
> Sent: Monday, November 17, 2014 3:39 PM
> To: discuss at mpich.org
> Cc: mpich-discuss at mcs.anl.gov
> Subject: Re: [mpich-discuss] f77 bindings and profiling
>
> You need to add the right number of underscores at the end of the C
> function depending on the Fortran compiler you are using. For gfortran I
> think it is two underscores. So define the C function as mpi_init__. If
> that doesn't work, use one underscore. MPICH detects all this automatically
> at configure time.
>
> Rajeev
>
> On Nov 17, 2014, at 3:28 PM, "Isaila, Florin D." <fisaila at mcs.anl.gov>
> wrote:
>
> > Hi ,
> >
> > I am trying to use MPI profiling to make mpi_init from a F77 program
> call my MPI_Init (written in C), but I do not manage to achieve that. In
> this simple F77 program:
> >        program main
> >        include  'mpif.h'
> >        integer error
> >        call mpi_init(error)
> >        call mpi_finalize(error)
> >        end
> >
> > I try to make the mpi_init  call:
> > int MPI_Init (int *argc, char ***argv){  int ret;
> >   printf("My function!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
> >   ret = PMPI_Init(argc, argv);
> >   return ret;
> > }
> >
> > My MPI_Init belongs to a library libtarget.a I created. I use -profile
> for compiling and I created the target.conf containing:
> > PROFILE_PRELIB="-L/homes/fisaila/benches/try/staticlib_mpif77 -ltarget"
> > in the right place.
> >
> > The library appears in the command line  before the mpich library:
> > mpif77 -show -g -profile=target init_finalize.f -o init_finalize
> > gfortran -g init_finalize.f -o init_finalize
> -I/homes/fisaila/software/mpich/include -L/homes/fisaila/software/mpich/lib
> -L/homes/fisaila/benches/try/staticlib_mpif77 -ltarget -Wl,-rpath
> -Wl,/homes/fisaila/software/mpich/lib -lmpich -lopa -lmpl -lrt -lpthread
> >
> > However, the program never gets into my MPI_Init.
> >
> > Any suggestion about what I am missing?
> >
> > Thanks
> > Florin
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > _______________________________________________
> > discuss mailing list     discuss at mpich.org
> > To manage subscription options or unsubscribe:
> > https://lists.mpich.org/mailman/listinfo/discuss
>
> _______________________________________________
> discuss mailing list     discuss at mpich.org
> To manage subscription options or unsubscribe:
> https://lists.mpich.org/mailman/listinfo/discuss
> _______________________________________________
> discuss mailing list     discuss at mpich.org
> To manage subscription options or unsubscribe:
> https://lists.mpich.org/mailman/listinfo/discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mpich.org/pipermail/discuss/attachments/20141118/7fead991/attachment.html>
-------------- next part --------------
_______________________________________________
discuss mailing list     discuss at mpich.org
To manage subscription options or unsubscribe:
https://lists.mpich.org/mailman/listinfo/discuss


More information about the discuss mailing list