pmpi简单实例

1. Compile OpenMPI with --enable-mpi-profile. This option will enable building of PMPI interface.

./configure --prefix=/home/dycz0fx/opt/ompi/debug --enable-mpirun-prefix-by-default --enable-debug --enable-mpi-profile

2. Build OpenMPI

make all install

3. Write PMPI profiler, name it as test_pmpi.c.

/* PMPI profiler example */
#include 
#include "mpi.h"

int MPI_Init(int *argc, char ***argv){
    int rank, err;
    err = PMPI_Init(argc, argv);
    PMPI_Comm_rank(MPI_COMM_WORLD, &rank) ;
    printf("[%d]: Profile MPI_Init.\n", rank) ;
    return err;
}


int MPI_Finalize(){
	int rank;
	PMPI_Comm_rank(MPI_COMM_WORLD, &rank) ;
	printf("[%d]: Profile MPI_Finalize.\n", rank) ;
	return PMPI_Finalize( );
}


4. Compile test_pmpi.c to a ob

你可能感兴趣的:(MPI)