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


MPI_Send

Send data from a node to another

Syntax

res = MPI_Send(value, node)
res = MPI_Send(value, node, comm=mpi_comm)

Arguments

value

The value to be sent to the specified node.

node

The node to send the data

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 result of the operation (true if success, false if failed). If the optional argument "comm" is given, all nodes which are not in the communicator will return false.

Description

Send a variable to a specified node. The value should be retrieved by the node with the function MPI_Recv.

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
tag=0;
if Master
    // The master node
    for slaveId = 1:sizeNodes-1
        // Send data to the slaves
        value = rand(100,100) + rand(100,100) * %i;
        MPI_Send(value, slaveId);
    end

    for slaveId = 1:sizeNodes-1
        valueBack = MPI_Recv(slaveId, tag);
        // Check that the slaves gaves us what we expected
        assert_checkequal(valueBack,value + 1);
    end
else
    // The slaves
    rankSource = 0;
    // Receive the information from the master
    value = MPI_Recv(rankSource);
    // Increment all the values by one
    value = value + 1;
    // Send back to the master
    MPI_Send(value, 0);

end
MPI_Finalize();

See also

Report an issue
<< MPI_Recv Scilab MPI MPI implementation >>

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