Suppose that the profiler wishes to accumulate the total amount of data sent by the MPI_SEND function, along with the total elapsed time spent in the function. This could trivially be achieved thus
static int totalBytes; static double totalTime;int MPI_SEND(void * buffer, const int count, MPI_Datatype datatype, int dest, int tag, MPI_comm comm) { double tstart = MPI_Wtime(); /* Pass on all the arguments */ int extent; int result = PMPI_Send(buffer,count,datatype,dest,tag,comm);
/* Accumulate byte count */ totalBytes += count * MPI_Type_size(datatype,&extent); /* and time */ totalTime += MPI_Wtime() - tstart;
return result; }