<< MPI_Bcast Scilab MPI MPI_Finalize >>

Scilab Help >> Scilab MPI > MPI_Create_comm

MPI_Create_comm

Create a MPI subcommunicator of MPI_COMM_WORLD

Syntax

comm = MPI_Create_comm(ranks)

Arguments

ranks

Vector of World ranks used to create the new communicator.

comm

The new communicator created.

Description

Create a communicator using world ranks given by the array "ranks". The communicator can be passed to MPI functions using the optional argument "comm". This function have to be called by all process.

Examples

MPI_Init();

worldRnk  = MPI_Comm_rank();
worldSize = MPI_Comm_size();

evenComm = MPI_Create_comm(0:2:(worldSize-1));
oddComm  = MPI_Create_comm(1:2:(worldSize-1));

// Comm rank / size
evenRnk  = MPI_Comm_rank(comm=evenComm);
oddRnk   = MPI_Comm_rank(comm=oddComm);
evenSize = MPI_Comm_size(comm=evenComm);
oddSize  = MPI_Comm_size(comm=oddComm);

if worldRnk == 0 then
    disp("world rank | world size | comm rank | comm size");
end

if evenRnk <> -1 then
    disp("even  "+string(worldRnk)+ "      "+string(worldSize)+ "      "+string(evenRnk)+ "      "+string(evenSize))
else
    disp("odd   "+string(worldRnk)+ "      "+string(worldSize)+ "      "+string(oddRnk) + "      "+string(oddSize))
end

MPI_Finalize();

See also


Report an issue
<< MPI_Bcast Scilab MPI MPI_Finalize >>