C / C ++ MPI: Does cascading MPI_BCast need MPI_Barrier?

I have a question about cascading MPI_Bcast calls, I want to know if there is anything to keep in mind when you want to distribute different blocks of data from changing send streams to all other streams immediately after each other.

Imagine the following:

double buff=12345; // value is not important for this example
for (i=0; i<nthreads; i++) {// loop over all threads
    MPI_BCast(&buff, 1, MPI_DOUBLE, i, MPI_COMM_WORLD); // the i-th threads sends all other receive
    // some, but not all threads do something with the data
    if (threadid > i) {
        // do something that can need much more time on some threads than on others
    }
}

I hope this sample code explains the situation. Basically, there is a for loop for all threads, and a different send thread is used at each iteration. A possible problem is that each thread takes a different amount of time to switch to MPI_Bcast again. Is it possible to have an allready sending stream there while some receiving streams might still be receiving from the last sender? Do I need MPI_Barrier here or can I cascade as many Bcasts as I want, since it is clear that each call is reached by each thread once?

edit: , , - , send ? - , , id i, Bcasts ?

+4

Source: https://habr.com/ru/post/1619359/


All Articles