|
From: Raghu R. <rag...@no...> - 2013-01-17 19:56:32
|
I would like to use valgrind to troubleshoot MPI applications, and before
attempting on a real application, I wanted to see how it works on a simple
hello world application.
I tried google to find this information but didn't have much luck.
I am trying this on an SGI Ice system, with Westmere processors, running Red
Hat linux (Linux fe8 2.6.32-71.el6.x86_64)
I have installed valgrind-3.8.1
Using Intel compilers
I have successfully verified that this works fine with the serial program
with the example listed in the Quickstart guide. It produces the same
output shown in the Quickstart document.
However, I'm not having much luck when I try it with an MPI application.
Included below is the code, and output.
The compilation line used was:
mpicc -DBUG -g -O0 -o hello_mpi_c hello_mpi_c.c
/contrib/valgrind/valgrind-3.8.1/lib/valgrind/libmpiwrap-amd64-linux.so
Execution line used was:
env MPIWRAP_DEBUG=verbose mpiexec_mpt -np 1
/contrib/valgrind/valgrind-3.8.1/bin/valgrind ./hello_mpi_c
Any suggestions on what I may be doing wrong?
Thanks,
--Raghu
Code:
#include <stdio.h>
#include <mpi.h>
int main(int argc, char **argv)
{
int ierr, myid, npes;
int len;
char name[MPI_MAX_PROCESSOR_NAME];
ierr = MPI_Init(&argc, &argv);
#ifdef MACROTEST
#define MACROTEST 10
#endif
ierr = MPI_Comm_rank(MPI_COMM_WORLD, &myid);
ierr = MPI_Comm_size(MPI_COMM_WORLD, &npes);
ierr = MPI_Get_processor_name( name, &len );
printf("Hello from rank %d out of %d; procname = %s\n", myid, npes,
name);
#ifdef MACROTEST
printf("Test Macro: %d\n", MACROTEST);
#endif
#ifdef BUG
{
int* x = (int*)malloc(10 * sizeof(int));
x[10] = 0; // problem 1: heap block overrun
printf("Print something %d\n",x[10]);
} // problem 2: memory leak -- x not freed
#endif
ierr = MPI_Finalize();
}
Ouput:
+ export MPIWRAP_DEBUG=verbose
+ MPIWRAP_DEBUG=verbose
+ mpiexec_mpt -np 1 /contrib/valgrind/valgrind-3.8.1/bin/valgrind
./hello_mpi_c
valgrind MPI wrappers 17652: Active for pid 17652
valgrind MPI wrappers 17652: Try MPIWRAP_DEBUG=help for possible options
valgrind MPI wrappers 17652: enter PMPI_Init
valgrind MPI wrappers 17652: enter PMPI_Init_thread
valgrind MPI wrappers 17652: exit PMPI_Init (err = 0)
valgrind MPI wrappers 17652: enter PMPI_Comm_rank
valgrind MPI wrappers 17652: exit PMPI_Comm_rank (err = 0)
valgrind MPI wrappers 17652: enter PMPI_Comm_size
valgrind MPI wrappers 17652: exit PMPI_Comm_size (err = 0)
valgrind MPI wrappers 17652: enter PMPI_Get_processor_name
Hello from rank 0 out of 1; procname = r2i2n2
valgrind MPI wrappers 17652: enter PMPI_Finalize
valgrind MPI wrappers 17652: exit PMPI_Finalize (err = 0)
+ grep MPIWRAP
+ env
MPIWRAP_DEBUG=verbose
|