Utilities::MPI::broadcast

10 views
Skip to first unread message

Rahul Gopalan Ramachandran

unread,
Feb 2, 2023, 11:32:11 AM2/2/23
to deal.II User Group
Hello everyone,

Is Utilities::MPI::broadcast supposed to do the same as MPI_Bcast? I wanted an integer to be sent to all the ranks. So this is what I wrote:
Utilities::MPI::broadcast(mpi_communicator,rand_seed,0);
However, it seems to be not sending the variable.
Using MPI_Bcast as follows does the job.
 MPI_Bcast(&rand_seed, 1, MPI_INT, 0, mpi_communicator);

Is my usage wrong or is it a bug?

Regards,
Rahul

Wolfgang Bangerth

unread,
Feb 2, 2023, 11:37:59 AM2/2/23
to dea...@googlegroups.com
The only difference is that MPI_Bcast puts the result into the first
argument it is passed, whereas MPI::broadcast returns it. So you
probably want to write
rand_seed = Utilities::MPI::broadcast(mpi_communicator,rand_seed,0);
to assign the value at all processes.

Best
W.


--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/

Rahul Gopalan Ramachandran

unread,
Feb 2, 2023, 11:39:39 AM2/2/23
to dea...@googlegroups.com
Thanks Dr. Bangerth for the clarification, that makes sense!

Regards,
Rahul
> --
> The deal.II project is located at http://www.dealii.org/
> For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
> --- You received this message because you are subscribed to a topic in the Google Groups "deal.II User Group" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/dealii/hftO5LpxCrQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to dealii+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/10249b2e-82c2-1db2-10ae-cc5f9d175fff%40colostate.edu.

Reply all
Reply to author
Forward
0 new messages