Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2025.1.0 - Русский


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

Report an issue
<< MPI_Comm_size Scilab MPI MPI_Finalize >>

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:55:33 CEST 2025