23 MPI::Intracomm::Intracomm(
MPI_Comm data) {
25 if (MPI::Is_initialized() && (data != MPI_COMM_NULL)) {
26 (void)MPI_Comm_test_inter(data, &flag);
28 mpi_comm = MPI_COMM_NULL;
39 MPI::Intracomm::Scan(
const void *sendbuf,
void *recvbuf,
int count,
40 const MPI::Datatype & datatype,
const MPI::Op& op)
const
42 (void)MPI_Scan(const_cast<void *>(sendbuf), recvbuf, count, datatype, op, mpi_comm);
46 MPI::Intracomm::Exscan(
const void *sendbuf,
void *recvbuf,
int count,
47 const MPI::Datatype & datatype,
48 const MPI::Op& op)
const
50 (void)MPI_Exscan(const_cast<void *>(sendbuf), recvbuf, count, datatype, op, mpi_comm);
54 MPI::Intracomm::Dup()
const
57 (void)MPI_Comm_dup(mpi_comm, &newcomm);
61 inline MPI::Intracomm&
62 MPI::Intracomm::Clone()
const
65 (void)MPI_Comm_dup(mpi_comm, &newcomm);
66 MPI::Intracomm* dup =
new MPI::Intracomm(newcomm);
71 MPI::Intracomm::Create(
const MPI::Group& group)
const
74 (void)MPI_Comm_create(mpi_comm, group, &newcomm);
79 MPI::Intracomm::Split(
int color,
int key)
const
82 (void)MPI_Comm_split(mpi_comm, color, key, &newcomm);
89 MPI::Intracomm::Create_intercomm(
int local_leader,
90 const MPI::Comm& peer_comm,
91 int remote_leader,
int tag)
const
94 (void)MPI_Intercomm_create(mpi_comm, local_leader, peer_comm,
95 remote_leader, tag, &newintercomm);
100 MPI::Intracomm::Create_cart(
int ndims,
const int dims[],
101 const bool periods[],
bool reorder)
const
103 int *int_periods =
new int [ndims];
104 for (
int i=0; i<ndims; i++)
105 int_periods[i] = (
int) periods[i];
108 (void)MPI_Cart_create(mpi_comm, ndims, const_cast<int *>(dims),
109 int_periods, (int)reorder, &newcomm);
110 delete [] int_periods;
114 inline MPI::Graphcomm
115 MPI::Intracomm::Create_graph(
int nnodes,
const int index[],
116 const int edges[],
bool reorder)
const
119 (void)MPI_Graph_create(mpi_comm, nnodes, const_cast<int *>(index),
120 const_cast<int *
>(edges), (
int)reorder, &newcomm);
129 inline MPI::Intercomm
130 MPI::Intracomm::Accept(
const char* port_name,
131 const MPI::Info& info,
135 (void) MPI_Comm_accept(const_cast<char *>(port_name), info, root, mpi_comm,
141 inline MPI::Intercomm
142 MPI::Intracomm::Connect(
const char* port_name,
143 const MPI::Info& info,
147 (void) MPI_Comm_connect(const_cast<char *>(port_name), info, root, mpi_comm,
153 inline MPI::Intercomm
154 MPI::Intracomm::Spawn(
const char* command,
const char* argv[],
155 int maxprocs,
const MPI::Info& info,
159 (void) MPI_Comm_spawn(const_cast<char *>(command),
const_cast<char **
>(argv), maxprocs,
160 info, root, mpi_comm, &newcomm,
161 (
int *)MPI_ERRCODES_IGNORE);
166 inline MPI::Intercomm
167 MPI::Intracomm::Spawn(
const char* command,
const char* argv[],
168 int maxprocs,
const MPI::Info& info,
169 int root,
int array_of_errcodes[])
const
172 (void) MPI_Comm_spawn(const_cast<char *>(command),
const_cast<char **
>(argv), maxprocs,
173 info, root, mpi_comm, &newcomm,
179 inline MPI::Intercomm
180 MPI::Intracomm::Spawn_multiple(
int count,
181 const char* array_of_commands[],
182 const char** array_of_argv[],
183 const int array_of_maxprocs[],
184 const Info array_of_info[],
int root)
188 convert_info_to_mpi_info(count, array_of_info);
190 MPI_Comm_spawn_multiple(count, const_cast<char **>(array_of_commands),
191 const_cast<char ***>(array_of_argv),
192 const_cast<int *>(array_of_maxprocs),
193 array_of_mpi_info, root,
194 mpi_comm, &newcomm, (
int *)MPI_ERRCODES_IGNORE);
195 delete[] array_of_mpi_info;
200 MPI::Intracomm::convert_info_to_mpi_info(
int p_nbr,
const Info p_info_tbl[])
204 for (
int i_tbl=0; i_tbl < p_nbr; i_tbl++) {
205 mpi_info_tbl[i_tbl] = p_info_tbl[i_tbl];
211 inline MPI::Intercomm
212 MPI::Intracomm::Spawn_multiple(
int count,
213 const char* array_of_commands[],
214 const char** array_of_argv[],
215 const int array_of_maxprocs[],
216 const Info array_of_info[],
int root,
217 int array_of_errcodes[])
221 convert_info_to_mpi_info(count, array_of_info);
223 MPI_Comm_spawn_multiple(count, const_cast<char **>(array_of_commands),
224 const_cast<char ***>(array_of_argv),
225 const_cast<int *>(array_of_maxprocs),
226 array_of_mpi_info, root,
227 mpi_comm, &newcomm, array_of_errcodes);
228 delete[] array_of_mpi_info;
Definition: communicator.h:118