To use nameshift profiling routines that are either written to the C bindings with an MPI program written in C or that are written to the FORTRAN bindings with an MPI program written in FORTRAN, follow the steps in Using the signal-handling library or Using the threads library.
Programs that use the C MPI language bindings can easily create profiling libraries using the name-shifted interface.
Follow the appropriate steps:
#include <stdio.h>
#include <mpi.h>
int MPI_Init(int *argc, char ***argv) {
int rc;
printf("hello from profiling layer MPI_Init...\n");
rc = PMPI_Init(argc, argv);
printf("goodbye from profiling layer MPI_Init...\n");
return(rc);
}
MPI_Init
cc -c myprof.c -I/usr/lpp/ppe.poe/include
The -I flag defines the location of mpi.h.
ld -o newmyprof.o myprof.o -bM:SRE -H512 -T512 -bnoentry -bE:myprof.exp -lc -lmpi -L/usr/lpp/ppe.poe/lib ar rv libmyprof.a newmyprof.o
mpcc -o test1 test1.c -L. -lmyprof
The shipped product has a library structure that looks like this:
+---------------------+ exports mpi_aaa
| libmpi.a(mpifort.o) | imports MPI_Aaa
+---------------------+
|
|
|
+---------------------+ exports MPI_Aaa
| libmpi.a(mpicore.o) | exports PMPI_Aaa
+---------------------+
You need to change it into the following structure by rebuilding the mpifort.o shared object:
+-------------------------+ exports mpi_aaa
| libpmpi.a(newmpifort.o) | imports MPI_Aaa
+-------------------------+
|
|
|
+-------------------------+ exports MPI_Aaa
| libmyprof.a(newmyprof.o)| imports PMPI_Aaa
+-------------------------+
|
|
|
+---------------------+ exports PMPI_Aaa
| libmpi.a(mpicore.o) | (exports MPI_Aaa)
+---------------------+
To do this, first extract mpifort.o from libmpi.a:
ar -xv /usr/lpp/ppe.poe/lib/libmpi.a mpifort.o
rtl_enable -o newmpifort.o -s mpifort.o -L. -L/usr/lpp/ppe.poe/lib -lmyprof -lmpi -lc
sed "s/-bI:mpifort.imp//" < mpifort.sh > mpifort.newsh
chmod +x mpifort.newsh mpifort.newsh
ar rv libpmpi.a newmpifort.o
c -------------------------------------
program hwinit
include 'mpif.h'
integer forterr
c
call MPI_INIT(forterr)
c
c Write comments to screen.
c
write(6,*)'Hello from task '
c
call MPI_FINALIZE(forterr)
c
stop
end
c
mpxlf -o hwinit hwinit.f -L. -lpmpi
Programs that use the C MPI language bindings can easily create profiling libraries using the name-shifted interface.
Follow the appropriate steps:
#include <pthread.h>
#include <stdio.h>
#include <mpi.h>
int MPI_Init(int *argc, char ***argv) {
int rc;
printf("hello from profiling layer MPI_Init...\n");
rc = PMPI_Init(argc, argv);
printf("goodbye from profiling layer MPI_Init...\n");
return(rc);
}
MPI_Init
cc_r -c myprof_r.c -I/usr/lpp/ppe.poe/include
The -I flag defines the location of mpi.h.
ld -o newmyprof_r.o myprof_r.o -bM:SRE -H512 -T512 -bnoentry -bE:myprof_r.exp -lc -lmpi_r -L/usr/lpp/ppe.poe/lib -lpthreads ar rv libmyprof_r.a newmyprof_r.o
mpcc_r -o test1 test1.c -L. -lmyprof_r
The shipped product has a library structure that looks like this:
+-------------------------+
| libmpi_r.a(mpifort_r.o) | exports mpi_aaa
+-------------------------+ imports MPI_Aaa
|
|
|
+-------------------------+
| libmpi_r.a(mpicore_r.o) | exports MPI_Aaa
+-------------------------+ exports PMPI_Aaa
You need to change it into the following structure by rebuilding the mpifort_r.o shared object:
+-----------------------------+
| libpmpi_r.a(newmpifort_r.o) | exports mpi_aaa
+-----------------------------+ imports MPI_Aaa
|
|
|
+------------------------------+ exports MPI_Aaa
| libmyprof_r.a(newmyprof_r.o) | imports PMPI_Aaa
+------------------------------+
|
|
|
+-------------------------+ exports PMPI_Aaa
| libmpi_r.a(mpicore_r.o) | (exports MPI_Aaa)
+-------------------------+
To do this, first extract mpifort_r.o from libmpi_r.a:
ar -xv /usr/lpp/ppe.poe/lib/libmpi_r.a mpifort_r.o
rtl_enable -o newmpifort_r.o -s mpifort_r.o -L. -L/usr/lpp/ppe.poe/lib -lmyprof_r -lmpi_r -lc_r -lpthreads
sed "s/-bI:mpifort_r.imp//" < mpifort_r.sh > mpifort_r.newsh
chmod +x mpifort_r.newsh mpifort_r.newsh
ar rv libpmpi_r.a newmpifort_r.o
c -------------------------------------
program hwinit
include 'mpif.h'
integer forterr
c
call MPI_INIT(forterr)
c
c Write comments to screen.
c
write(6,*)'Hello from task '
c
call MPI_FINALIZE(forterr)
c
stop
end
c
mpxlf_r -o hwinit hwinit.f -L. -lpmpi_r