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 mprintf("even %d %d %d %d\n", worldRnk, worldSize, evenRnk, evenSize); else mprintf("odd %d %d %d %d\n", worldRnk, worldSize, oddRnk, oddSize); end MPI_Finalize();
See also
- MPI_Recv — Recv data from a node
- MPI_Send — Send data from a node to another
- MPI_Init — Initialize the MPI environment
- MPI_Finalize — Terminate the MPI environment
Report an issue | ||
<< MPI_Comm_size | Scilab MPI | MPI_Finalize >> |