hmmer-3.3/easel/esl_mpi.c
/* Function:  esl_stopwatch_MPIReduce()
 * Synopsis:  Collect total parallel process time into master watch.
 * Incept:    SRE, Thu Jun 14 13:27:20 2007 [Janelia]
 *
 * Purpose:   Collect all user/sys times from stopped stopwatch <w> from
 *            all MPI processes, and sum them into the watch on the
 *            master process of rank <root>, for MPI communicator
 *            <comm>.  A subsequent <esl_stopwatch_Display()> will
 *            then show total user/sys times, not just the master's
 *            usage.
 *            
 *            This routine needs to be called synchronously on all
 *            processes; it does a collective communication using
 *            <MPI_Reduce()>.
 *            
 * Returns:   <eslOK> on success.
 *
 * Throws:    <eslESYS> on MPI call failure.
 */
esl_stopwatch_MPIReduce()
Synopsis:  Collect total parallel process time into master watch.

Collect all user/sys times from stopped stopwatch  from
all MPI processes, and sum them into the watch on the
master process of rank , for MPI communicator
.  A subsequent  will
then show total user/sys times, not just the master's
usage.

This routine needs to be called synchronously on all
processes; it does a collective communication using
.

 on success.

 on MPI call failure.
esl_stopwatch_MPIReduce () Synopsis : Collect total parallel process time into master watch . Collect all user / sys times from stopped stopwatch from all MPI processes and sum them into the watch on the master process of rank for MPI communicator . A subsequent will then show total user / sys times not just the master ' s usage . This routine needs to be called synchronously on all processes ; it does a collective communication using . on success . on MPI call failure .
int
esl_stopwatch_MPIReduce(ESL_STOPWATCH *w, int root, MPI_Comm comm)
{
  double user_total;
  double sys_total;
  if (MPI_Reduce(&(w->user), &user_total, 1, MPI_DOUBLE, MPI_SUM, root, comm) != 0) ESL_EXCEPTION(eslESYS, "mpi reduce failed");
  if (MPI_Reduce(&(w->sys),  &sys_total,  1, MPI_DOUBLE, MPI_SUM, root, comm) != 0) ESL_EXCEPTION(eslESYS, "mpi reduce failed");
  w->user = user_total;
  w->sys  = sys_total;
  return eslOK;
}
int esl_stopwatch_MPIReduce ( ESL_STOPWATCH * w , int root , MPI_Comm comm ) { double user_total ; double sys_total ; if ( MPI_Reduce ( & ( w -> user ) , & user_total , 1 , MPI_DOUBLE , MPI_SUM , root , comm ) != 0 ) ESL_EXCEPTION ( eslESYS , " " ) ; if ( MPI_Reduce ( & ( w -> sys ) , & sys_total , 1 , MPI_DOUBLE , MPI_SUM , root , comm ) != 0 ) ESL_EXCEPTION ( eslESYS , " " ) ; w -> user = user_total ; w -> sys = sys_total ; return eslOK ; }
Function:  esl_stopwatch_MPIReduce()
 Synopsis:  Collect total parallel process time into master watch.
Function : esl_stopwatch_MPIReduce () Synopsis : Collect total parallel process time into master watch .