292. Profiler Implementation


Up: Examples Next: MPI Library Implementation Previous: Examples

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 = 0; 
static double totalTime = 0.0; 
 
int MPI_Send(void* buffer, 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);    
 
   MPI_Type_size(datatype, &extent);  /* Compute size */ 
   totalBytes += count*extent; 
 
   totalTime  += MPI_Wtime() - tstart;         /* and time          */ 
 
   return result;                        
} 



Up: Examples Next: MPI Library Implementation Previous: Examples


Return to MPI-2.2 Standard Index
Return to MPI Forum Home Page

(Unofficial) MPI-2.2 of September 4, 2009
HTML Generated on September 10, 2009