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: #undef __FUNCT__  
 14: /*@C
 15:    PetscMPIDump - Dumps a listing of incomplete MPI operations, such as sends that
 16:    have never been received, etc.

 18:    Collective on PETSC_COMM_WORLD

 20:    Input Parameter:
 21: .  fp - file pointer.  If fp is NULL, stdout is assumed.

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

 26:     Level: developer

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

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

 60: #else

 62: #undef __FUNCT__  
 64: int PetscMPIDump(FILE *fd)
 65: {
 67:   return(0);
 68: }

 70: #endif