[mpich-discuss] Bcast question?

William Gropp wgropp at illinois.edu
Fri Aug 10 08:58:02 CDT 2012

The most likely newbe mistake is that you are timing the time time that the MPI_Bcast is waiting - for example, if your code looks like this:

if (rank == 0) { tr = MPI_Wtime(); read data tr = MPI_Wtime()-tr; }
tb = MPI_Wtime(): MPI_Bcast(…); tb = MPI_Wtime() - tb;

then on all but rank 0, you are timing the time that MPI_Bcast is waiting for the read data step to finish.  Instead, consider adding an MPI_Barrier before the MPI_Bcast:

if (rank == 0) { tr = MPI_Wtime(); read data tr = MPI_Wtime()-tr; }
tb = MPI_Wtime(): MPI_Bcast(…); tb = MPI_Wtime() - tb;
*Only* do this when you are trying to answer such timing questions.

You may also want to consider using MPI-IO to parallelize the read step.


William Gropp
Director, Parallel Computing Institute
Deputy Director for Research
Institute for Advanced Computing Applications and Technologies
Paul and Cynthia Saylor Professor of Computer Science
University of Illinois Urbana-Champaign

On Aug 10, 2012, at 3:03 AM, John Chludzinski wrote:

> I have a problem which requires all process to have a copy of an array of data that is read in from a file (process 0).  I Bcast the array to all processes (using MPI_COMM_WORLD).  
> I instrumented the code with some calls to Wtime to find the time consumed for different actions.  In particular, I was interested in comparing the time required for Bcast's vs. fread's.  The size of the array is 1,200,000 of type MPI_DOUBLE.  
> For a 3 process run:
> RANK = 0      fread_time = 2.323575
> vs.
> RANK = 2      bcast_time = 2.361233 
> RANK = 0      bcast_time = 0.081910
> RANK = 1      bcast_time = 2.399790
> These numbers seem to indicate that Bcast-ing the data is as slow as reading the data from a file (on my Western Digital Passport USB drive).  Am I making a newbie mistake?
> ---John
> PS> I'm using Fedora 16 (32 bit) notebook with a dual core AMD Phenom processor.
> _______________________________________________
> mpich-discuss mailing list     mpich-discuss at mcs.anl.gov
> To manage subscription options or unsubscribe:
> https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss

More information about the mpich-discuss mailing list