Writing profiling routines


Up: Tools for evaluating programs Next: Another profiling example Previous: Profiling

The MPICH implementation contains a program for writing wrappers.

This description will write out each MPI routine that is called.:

#ifdef MPI_BUILD_PROFILING
#undef MPI_BUILD_PROFILING
#endif
#include <stdio.h>
#include "mpi.h"

{{fnall fn_name}}
  {{vardecl int llrank}}
  PMPI_Comm_rank( MPI_COMM_WORLD, &llrank );
  printf( "[%d] Starting {{fn_name}}...\n", llrank ); fflush( stdout );
  {{callfn}}
  printf( "[%d] Ending {{fn_name}}\n", llrank ); fflush( stdout );
{{endfnall}}

The command

wrappergen -w trace.w -o trace.c 
converts this to a C program. The complie the file trace.c and insert the resulting object file into your link line:
cc -o a.out a.o ... trace.o -lpmpi -lmpi 



Up: Tools for evaluating programs Next: Another profiling example Previous: Profiling