Actual source code: mpitr.c

  1: /*$Id: mpitr.c,v 1.29 2001/03/23 23:20:50 balay Exp $*/

  3: /*
  4:     Code for tracing mistakes in MPI usage. For example, sends that are never received,
  5:   nonblocking messages that are not correctly waited for, etc.
  6: */

 8:  #include petsc.h

 10: #if defined(PETSC_USE_LOG) && !defined(_petsc_mpi_uni)

 12: /*@C
 13:    PetscMPIDump - Dumps a listing of incomplete MPI operations, such as sends that
 14:    have never been received, etc.

 16:    Collective on PETSC_COMM_WORLD

 18:    Input Parameter:
 19: .  fp - file pointer.  If fp is NULL, stdout is assumed.

 21:    Options Database Key:
 22: .  -mpidump - Dumps MPI incompleteness during call to PetscFinalize()

 24:     Level: developer

 26: .seealso:  PetscTrDump()
 27:  @*/
 28: int PetscMPIDump(FILE *fd)
 29: {
 30:   int    rank,ierr;
 31:   double tsends,trecvs,work;

 34:   MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
 35:   if (!fd) fd = stdout;
 36: 
 37:   /* Did we wait on all the non-blocking sends and receives? */
 38:   PetscSequentialPhaseBegin(PETSC_COMM_WORLD,1);
 39:   if (irecv_ct + isend_ct != sum_of_waits_ct) {
 40:     fprintf(fd,"[%d]You have not waited on all non-blocking sends and receives",rank);
 41:     fprintf(fd,"[%d]Number non-blocking sends %g receives %g number of waits %gn",rank,isend_ct,
 42:             irecv_ct,sum_of_waits_ct);
 43:     fflush(fd);
 44:   }
 45:   PetscSequentialPhaseEnd(PETSC_COMM_WORLD,1);
 46:   /* Did we receive all the messages that we sent? */
 47:   work = irecv_ct + recv_ct;
 48:   MPI_Reduce(&work,&trecvs,1,MPI_DOUBLE,MPI_SUM,0,PETSC_COMM_WORLD);
 49:   work = isend_ct + send_ct;
 50:   MPI_Reduce(&work,&tsends,1,MPI_DOUBLE,MPI_SUM,0,PETSC_COMM_WORLD);
 51:   if (!rank && tsends != trecvs) {
 52:     fprintf(fd,"Total number sends %g not equal receives %gn",tsends,trecvs);
 53:     fflush(fd);
 54:   }
 55:   return(0);
 56: }

 58: #else

 60: int PetscMPIDump(FILE *fd)
 61: {
 63:   return(0);
 64: }

 66: #endif