source: proiecte/hpl/openmpi_compiled/include/openmpi/ompi/mpi/cxx/intracomm_inln.h @ 97

Last change on this file since 97 was 97, checked in by (none), 14 years ago

Adding compiled files

File size: 6.4 KB
Line 
1// -*- c++ -*-
2//
3// Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
4//                         University Research and Technology
5//                         Corporation.  All rights reserved.
6// Copyright (c) 2004-2005 The University of Tennessee and The University
7//                         of Tennessee Research Foundation.  All rights
8//                         reserved.
9// Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10//                         University of Stuttgart.  All rights reserved.
11// Copyright (c) 2004-2005 The Regents of the University of California.
12//                         All rights reserved.
13// Copyright (c) 2006      Cisco Systems, Inc.  All rights reserved.
14// Copyright (c) 2007      Sun Microsystems, Inc.  All rights reserved.
15// $COPYRIGHT$
16//
17// Additional copyrights may follow
18//
19// $HEADER$
20//
21
22inline
23MPI::Intracomm::Intracomm(MPI_Comm data) {
24  int flag = 0;
25  if (MPI::Is_initialized() && (data != MPI_COMM_NULL)) {
26    (void)MPI_Comm_test_inter(data, &flag);
27    if (flag) {
28      mpi_comm = MPI_COMM_NULL;
29    } else {
30      mpi_comm = data;
31    }
32  }
33  else {
34    mpi_comm = data;
35  }
36}
37
38inline void
39MPI::Intracomm::Scan(const void *sendbuf, void *recvbuf, int count, 
40     const MPI::Datatype & datatype, const MPI::Op& op) const
41{
42  (void)MPI_Scan(const_cast<void *>(sendbuf), recvbuf, count, datatype, op, mpi_comm);
43}
44
45inline void
46MPI::Intracomm::Exscan(const void *sendbuf, void *recvbuf, int count,
47                              const MPI::Datatype & datatype, 
48                              const MPI::Op& op) const
49{
50  (void)MPI_Exscan(const_cast<void *>(sendbuf), recvbuf, count, datatype, op, mpi_comm);
51}
52
53inline MPI::Intracomm
54MPI::Intracomm::Dup() const
55{
56  MPI_Comm newcomm;
57  (void)MPI_Comm_dup(mpi_comm, &newcomm);
58  return newcomm;
59}
60
61inline MPI::Intracomm&
62MPI::Intracomm::Clone() const
63{
64  MPI_Comm newcomm;
65  (void)MPI_Comm_dup(mpi_comm, &newcomm);
66  MPI::Intracomm* dup = new MPI::Intracomm(newcomm);
67  return *dup;
68}
69
70inline MPI::Intracomm
71MPI::Intracomm::Create(const MPI::Group& group) const
72{
73  MPI_Comm newcomm;
74  (void)MPI_Comm_create(mpi_comm, group, &newcomm);
75  return newcomm;
76}
77
78inline MPI::Intracomm
79MPI::Intracomm::Split(int color, int key) const
80{
81  MPI_Comm newcomm;
82  (void)MPI_Comm_split(mpi_comm, color, key, &newcomm);
83  return newcomm;
84}
85
86
87
88inline MPI::Intercomm
89MPI::Intracomm::Create_intercomm(int local_leader,
90                                        const MPI::Comm& peer_comm,
91                                        int remote_leader, int tag) const
92{
93  MPI_Comm newintercomm;
94  (void)MPI_Intercomm_create(mpi_comm, local_leader, peer_comm,
95                             remote_leader, tag, &newintercomm); 
96  return newintercomm;
97}
98
99inline MPI::Cartcomm
100MPI::Intracomm::Create_cart(int ndims, const int dims[],
101                                   const bool periods[], bool reorder) const
102{
103  int *int_periods = new int [ndims];
104  for (int i=0; i<ndims; i++)
105    int_periods[i] = (int) periods[i];
106 
107  MPI_Comm newcomm;
108  (void)MPI_Cart_create(mpi_comm, ndims, const_cast<int *>(dims), 
109                      int_periods, (int)reorder, &newcomm);
110  delete [] int_periods;
111  return newcomm;
112}
113
114inline MPI::Graphcomm
115MPI::Intracomm::Create_graph(int nnodes, const int index[],
116                                    const int edges[], bool reorder) const
117{
118  MPI_Comm newcomm;
119  (void)MPI_Graph_create(mpi_comm, nnodes, const_cast<int *>(index), 
120                         const_cast<int *>(edges), (int)reorder, &newcomm);
121  return newcomm;
122}
123
124
125//
126// Process Creation and Management
127//
128
129inline MPI::Intercomm
130MPI::Intracomm::Accept(const char* port_name, 
131                              const MPI::Info& info,
132                              int root) const
133{
134  MPI_Comm newcomm;
135  (void) MPI_Comm_accept(const_cast<char *>(port_name), info, root, mpi_comm,
136                         &newcomm);
137  return newcomm;
138}
139
140
141inline MPI::Intercomm
142MPI::Intracomm::Connect(const char* port_name,
143                               const MPI::Info& info,
144                               int root) const
145{
146  MPI_Comm newcomm;
147  (void) MPI_Comm_connect(const_cast<char *>(port_name), info, root, mpi_comm,
148                          &newcomm);
149  return newcomm;
150}
151
152
153inline MPI::Intercomm
154MPI::Intracomm::Spawn(const char* command, const char* argv[],
155                             int maxprocs, const MPI::Info& info, 
156                             int root) const
157{
158  MPI_Comm newcomm;
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);
162  return newcomm;
163}
164
165
166inline MPI::Intercomm
167MPI::Intracomm::Spawn(const char* command, const char* argv[],
168                             int maxprocs, const MPI::Info& info,
169                             int root, int array_of_errcodes[]) const
170{
171  MPI_Comm newcomm;
172  (void) MPI_Comm_spawn(const_cast<char *>(command), const_cast<char **>(argv), maxprocs,
173                        info, root, mpi_comm, &newcomm, 
174                        array_of_errcodes);
175  return newcomm;
176}
177
178
179inline MPI::Intercomm
180MPI::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)
185{
186  MPI_Comm newcomm;
187  MPI_Info *const array_of_mpi_info = 
188      convert_info_to_mpi_info(count, array_of_info);
189
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;
196  return newcomm;
197}
198
199inline MPI_Info *
200MPI::Intracomm::convert_info_to_mpi_info(int p_nbr, const Info p_info_tbl[])
201{
202   MPI_Info *const mpi_info_tbl = new MPI_Info [p_nbr];
203
204   for (int i_tbl=0; i_tbl < p_nbr; i_tbl++) {
205       mpi_info_tbl[i_tbl] = p_info_tbl[i_tbl];
206   }
207
208   return mpi_info_tbl;
209}
210
211inline MPI::Intercomm
212MPI::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[])
218{
219  MPI_Comm newcomm;
220  MPI_Info *const array_of_mpi_info = 
221      convert_info_to_mpi_info(count, array_of_info);
222
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;
229  return newcomm;
230}
231
232
233
234
235
236
237
238
239
240
Note: See TracBrowser for help on using the repository browser.