Create a MPI subcommunicator of MPI_COMM_WORLD
comm = MPI_Create_comm(ranks)
Vector of World ranks used to create the new communicator.
The new communicator created.
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.
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(); | ![]() | ![]() |