Isn't it the other way around: implement MPI_ and call PMPI_ ? And if you are mixing Fortran and C, won't you need the underscore? Rajeev On Nov 18, 2014, at 12:40 PM, Junchao Zhang <[email protected]> wrote:
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. <[email protected]> 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@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@howard:f77$ export PROFILE_PRELIB="-lfoo"
fisaila@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@howard:f77_program$ nm /homes/fisaila/software/mpich/lib/libmpi.a | grep MPI_Init 000000000000146d W MPI_Init 000000000000146d T PMPI_Init
fisaila@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 [[email protected]] Sent: Monday, November 17, 2014 3:39 PM To: [email protected] Cc: [email protected] 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." <[email protected]> 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 [email protected] To manage subscription options or unsubscribe: https://lists.mpich.org/mailman/listinfo/discuss
_______________________________________________ discuss mailing list [email protected] To manage subscription options or unsubscribe: https://lists.mpich.org/mailman/listinfo/discuss _______________________________________________ discuss mailing list [email protected] To manage subscription options or unsubscribe: https://lists.mpich.org/mailman/listinfo/discuss
_______________________________________________ discuss mailing list [email protected] To manage subscription options or unsubscribe: https://lists.mpich.org/mailman/listinfo/discuss
_______________________________________________ discuss mailing list [email protected] To manage subscription options or unsubscribe: https://lists.mpich.org/mailman/listinfo/discuss