Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2025.1.0 - Português


MPI_Bcast

Broadcasts a message from the process with rank root to all other processes of the group

Syntax

res = MPI_Bcast(value, rootID)
res = MPI_Bcast(value, rootID, comm=mpi_comm)

Arguments

value

The value to be sent to all nodes.

rootID

The source of the message

comm = mpi_comm

If the optional argument "comm" is given, this function will use the MPI communicator created by MPI_Create_comm. If not, the default MPI_COMM_WORLD is used.

res

The broadcasted value. If the optional argument "comm" is given, all nodes which are not in the communicator will return empty matrix.

Description

Sends a variable to all nodes. The value should be retrieved by the node with the function MPI_Recv.

On the internal technical side, two broadcasts are used transparently. The first one sends the size of the data, the second the data themself.

Examples

MPI_Init();
rnk = MPI_Comm_rank();
sizeNodes = MPI_Comm_size();

SLV = rnk;          // handy shortcuts, master is rank 0
Master = ~ SLV;     // slaves are all other
a = -1;
if Master
    // Declare a
    a = 42
end
b = MPI_Bcast(a, 0);
b == 42
MPI_Finalize();

See also

Report an issue
<< MPI Scilab MPI MPI_Comm_rank >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu May 22 12:56:24 CEST 2025