OpenMPI  0.1.1
mpicxx.h
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-2008 Cisco Systems, Inc. All rights reserved.
14 // Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
15 // Copyright (c) 2011 FUJITSU LIMITED. All rights reserved.
16 // $COPYRIGHT$
17 //
18 // Additional copyrights may follow
19 //
20 // $HEADER$
21 //
22 
23 #ifndef MPIPP_H
24 #define MPIPP_H
25 
26 //
27 // Let's ensure that we're really in C++, and some errant programmer
28 // hasn't included <mpicxx.h> just "for completeness"
29 //
30 
31 // We do not include the opal_config.h and may not replace extern "C" {
32 #if defined(c_plusplus) || defined(__cplusplus)
33 
34 // do not include ompi_config.h. it will smash free() as a symbol
35 #include "mpi.h"
36 
37 // we include all this here so that we escape the silly namespacing issues
38 #include <map>
39 #include <utility>
40 
41 #include <stdarg.h>
42 
43 #if OMPI_PROVIDE_MPI_FILE_INTERFACE && !defined(OMPI_IGNORE_CXX_SEEK) & OMPI_WANT_MPI_CXX_SEEK
44 // We need to include the header files that define SEEK_* or use them
45 // in ways that require them to be #defines so that if the user
46 // includes them later, the double inclusion logic in the headers will
47 // prevent trouble from occuring.
48 
49 // include so that we can smash SEEK_* properly
50 #include <stdio.h>
51 // include because on Linux, there is one place that assumes SEEK_* is
52 // a #define (it's used in an enum).
53 #include <iostream>
54 
55 static const int ompi_stdio_seek_set = SEEK_SET;
56 static const int ompi_stdio_seek_cur = SEEK_CUR;
57 static const int ompi_stdio_seek_end = SEEK_END;
58 
59 // smash SEEK_* #defines
60 #ifdef SEEK_SET
61 #undef SEEK_SET
62 #undef SEEK_CUR
63 #undef SEEK_END
64 #endif
65 
66 // make globally scoped constants to replace smashed #defines
67 static const int SEEK_SET = ompi_stdio_seek_set;
68 static const int SEEK_CUR = ompi_stdio_seek_cur;
69 static const int SEEK_END = ompi_stdio_seek_end;
70 #endif
71 
72 #ifdef OPAL_HAVE_SYS_SYNCH_H
73 // Solaris threads.h pulls in sys/synch.h which in certain versions
74 // defines LOCK_SHARED.
75 
76 // include so that we can smash LOCK_SHARED
77 #include <sys/synch.h>
78 
79 // a user app may be included on a system with an older version
80 // sys/synch.h
81 #ifdef LOCK_SHARED
82 static const int ompi_synch_lock_shared = LOCK_SHARED;
83 
84 // smash LOCK_SHARED #defines
85 #undef LOCK_SHARED
86 
87 // make globally scoped constants to replace smashed #defines
88 static const int LOCK_SHARED = ompi_synch_lock_shared;
89 #endif
90 #endif
91 
92 // forward declare so that we can still do inlining
93 struct opal_mutex_t;
94 
95 // See lengthy explanation in intercepts.cc about this function.
96 extern "C" void
97 ompi_mpi_cxx_op_intercept(void *invec, void *outvec, int *len,
98  MPI_Datatype *datatype, MPI_User_function *fn);
99 
100 extern "C" void
101 ompi_mpi_cxx_comm_errhandler_invoke(ompi_errhandler_t *c_errhandler,
102  MPI_Comm *mpi_comm, int *err,
103  const char *message);
104 extern "C" void
105 ompi_mpi_cxx_win_errhandler_invoke(ompi_errhandler_t *c_errhandler,
106  MPI_Win *mpi_comm, int *err,
107  const char *message);
108 #if OMPI_PROVIDE_MPI_FILE_INTERFACE
109 extern "C" void
110 ompi_mpi_cxx_file_errhandler_invoke(ompi_errhandler_t *c_errhandler,
111  MPI_File *mpi_comm, int *err,
112  const char *message);
113 #endif
114 
115 //used for attr intercept functions
116 enum CommType { eIntracomm, eIntercomm, eCartcomm, eGraphcomm};
117 
118 extern "C" int
119 ompi_mpi_cxx_comm_copy_attr_intercept(MPI_Comm oldcomm, int keyval,
120  void *extra_state, void *attribute_val_in,
121  void *attribute_val_out, int *flag,
122  MPI_Comm newcomm);
123 extern "C" int
124 ompi_mpi_cxx_comm_delete_attr_intercept(MPI_Comm comm, int keyval,
125  void *attribute_val, void *extra_state);
126 
127 extern "C" int
128 ompi_mpi_cxx_type_copy_attr_intercept(MPI_Datatype oldtype, int keyval,
129  void *extra_state, void *attribute_val_in,
130  void *attribute_val_out, int *flag);
131 extern "C" int
132 ompi_mpi_cxx_type_delete_attr_intercept(MPI_Datatype type, int keyval,
133  void *attribute_val, void *extra_state);
134 
135 extern "C" int
136 ompi_mpi_cxx_win_copy_attr_intercept(MPI_Win oldwin, int keyval,
137  void *extra_state, void *attribute_val_in,
138  void *attribute_val_out, int *flag);
139 extern "C" int
140 ompi_mpi_cxx_win_delete_attr_intercept(MPI_Win win, int keyval,
141  void *attribute_val, void *extra_state);
142 
143 
144 
145 //
146 // MPI generalized request intercepts
147 //
148 
149 extern "C" int
150 ompi_mpi_cxx_grequest_query_fn_intercept(void *state, MPI_Status *status);
151 extern "C" int
152 ompi_mpi_cxx_grequest_free_fn_intercept(void *state);
153 extern "C" int
154 ompi_mpi_cxx_grequest_cancel_fn_intercept(void *state, int canceled);
155 
156 /**
157  * Windows bool type is not any kind of integer. Special care should
158  * be taken in order to cast it correctly.
159  */
160 #if defined(WIN32) || defined(_WIN32) || defined(WIN64)
161 #define OPAL_INT_TO_BOOL(VALUE) ((VALUE) != 0 ? true : false)
162 #else
163 #define OPAL_INT_TO_BOOL(VALUE) ((bool)(VALUE))
164 #endif /* defined(WIN32) || defined(_WIN32) || defined(WIN64) */
165 
166 #if 0 /* OMPI_ENABLE_MPI_PROFILING */
167 #include "ompi/mpi/cxx/pmpicxx.h"
168 #endif
169 
170 namespace MPI {
171 
172 #if ! OMPI_HAVE_CXX_EXCEPTION_SUPPORT
173  extern int mpi_errno;
174 #endif
175 
176  class Comm_Null;
177  class Comm;
178  class Intracomm;
179  class Intercomm;
180  class Graphcomm;
181  class Cartcomm;
182  class Datatype;
183  class Errhandler;
184  class Group;
185  class Op;
186  class Request;
187  class Grequest;
188  class Status;
189  class Info;
190  class Win;
191 #if OMPI_PROVIDE_MPI_FILE_INTERFACE
192  class File;
193 #endif
194 
195  typedef MPI_Aint Aint;
196  typedef MPI_Fint Fint;
197  typedef MPI_Offset Offset;
198 
199 #ifdef OMPI_BUILDING_CXX_BINDINGS_LIBRARY
200 #include "ompi/mpi/cxx/constants.h"
201 #include "ompi/mpi/cxx/functions.h"
202 #include "ompi/mpi/cxx/datatype.h"
203 #else
204 #include "openmpi/ompi/mpi/cxx/constants.h"
205 #include "openmpi/ompi/mpi/cxx/functions.h"
206 #include "openmpi/ompi/mpi/cxx/datatype.h"
207 #endif
208 
209  typedef void User_function(const void* invec, void* inoutvec, int len,
210  const Datatype& datatype);
211 
212  /* Prevent needing a -I${prefix}/include/openmpi, as it seems to
213  really annoy peope that don't use the wrapper compilers and is
214  no longer worth the fight of getting right... */
215 #ifdef OMPI_BUILDING_CXX_BINDINGS_LIBRARY
216 #include "ompi/mpi/cxx/exception.h"
217 #include "ompi/mpi/cxx/op.h"
218 #include "ompi/mpi/cxx/status.h"
219 #include "ompi/mpi/cxx/request.h" //includes class Prequest
220 #include "ompi/mpi/cxx/group.h"
221 #include "ompi/mpi/cxx/comm.h"
222 #include "ompi/mpi/cxx/win.h"
223 #if OMPI_PROVIDE_MPI_FILE_INTERFACE
224 #include "ompi/mpi/cxx/file.h"
225 #endif
226 #include "ompi/mpi/cxx/errhandler.h"
227 #include "ompi/mpi/cxx/intracomm.h"
228 #include "ompi/mpi/cxx/topology.h" //includes Cartcomm and Graphcomm
229 #include "ompi/mpi/cxx/intercomm.h"
230 #include "ompi/mpi/cxx/info.h"
231 #else
232 #include "openmpi/ompi/mpi/cxx/exception.h"
233 #include "openmpi/ompi/mpi/cxx/op.h"
234 #include "openmpi/ompi/mpi/cxx/status.h"
235 #include "openmpi/ompi/mpi/cxx/request.h" //includes class Prequest
236 #include "openmpi/ompi/mpi/cxx/group.h"
237 #include "openmpi/ompi/mpi/cxx/comm.h"
238 #include "openmpi/ompi/mpi/cxx/win.h"
239 #if OMPI_PROVIDE_MPI_FILE_INTERFACE
240 #include "openmpi/ompi/mpi/cxx/file.h"
241 #endif
242 #include "openmpi/ompi/mpi/cxx/errhandler.h"
243 #include "openmpi/ompi/mpi/cxx/intracomm.h"
244 #include "openmpi/ompi/mpi/cxx/topology.h" //includes Cartcomm and Graphcomm
245 #include "openmpi/ompi/mpi/cxx/intercomm.h"
246 #include "openmpi/ompi/mpi/cxx/info.h"
247 #endif
248 
249  // Version string
250  extern const char ompi_libcxx_version_string[];
251 }
252 
253 #if 0 /* OMPI_ENABLE_MPI_PROFILING */
254 #include "ompi/mpi/cxx/pop_inln.h"
255 #include "ompi/mpi/cxx/pgroup_inln.h"
256 #include "ompi/mpi/cxx/pstatus_inln.h"
257 #include "ompi/mpi/cxx/prequest_inln.h"
258 #endif
259 
260 //
261 // These are the "real" functions, whether prototyping is enabled
262 // or not. These functions are assigned to either the MPI::XXX class
263 // or the PMPI::XXX class based on the value of the macro MPI
264 // which is set in mpi2cxx_config.h.
265 // If prototyping is enabled, there is a top layer that calls these
266 // PMPI functions, and this top layer is in the XXX.cc files.
267 //
268 
269 /* see note above... */
270 #ifdef OMPI_BUILDING_CXX_BINDINGS_LIBRARY
271 #include "ompi/mpi/cxx/datatype_inln.h"
272 #include "ompi/mpi/cxx/functions_inln.h"
273 #include "ompi/mpi/cxx/request_inln.h"
274 #include "ompi/mpi/cxx/comm_inln.h"
275 #include "ompi/mpi/cxx/intracomm_inln.h"
276 #include "ompi/mpi/cxx/topology_inln.h"
277 #include "ompi/mpi/cxx/intercomm_inln.h"
278 #include "ompi/mpi/cxx/group_inln.h"
279 #include "ompi/mpi/cxx/op_inln.h"
280 #include "ompi/mpi/cxx/errhandler_inln.h"
281 #include "ompi/mpi/cxx/status_inln.h"
282 #include "ompi/mpi/cxx/info_inln.h"
283 #include "ompi/mpi/cxx/win_inln.h"
284 #if OMPI_PROVIDE_MPI_FILE_INTERFACE
285 #include "ompi/mpi/cxx/file_inln.h"
286 #endif
287 #else
288 #include "openmpi/ompi/mpi/cxx/datatype_inln.h"
289 #include "openmpi/ompi/mpi/cxx/functions_inln.h"
290 #include "openmpi/ompi/mpi/cxx/request_inln.h"
291 #include "openmpi/ompi/mpi/cxx/comm_inln.h"
292 #include "openmpi/ompi/mpi/cxx/intracomm_inln.h"
293 #include "openmpi/ompi/mpi/cxx/topology_inln.h"
294 #include "openmpi/ompi/mpi/cxx/intercomm_inln.h"
295 #include "openmpi/ompi/mpi/cxx/group_inln.h"
296 #include "openmpi/ompi/mpi/cxx/op_inln.h"
297 #include "openmpi/ompi/mpi/cxx/errhandler_inln.h"
298 #include "openmpi/ompi/mpi/cxx/status_inln.h"
299 #include "openmpi/ompi/mpi/cxx/info_inln.h"
300 #include "openmpi/ompi/mpi/cxx/win_inln.h"
301 #if OMPI_PROVIDE_MPI_FILE_INTERFACE
302 #include "openmpi/ompi/mpi/cxx/file_inln.h"
303 #endif
304 #endif
305 
306 #endif // #if defined(c_plusplus) || defined(__cplusplus)
307 #endif // #ifndef MPIPP_H_
Definition: request.h:200
Definition: win.h:53
Definition: datatype.h:24
Definition: errhandler.h:21
Definition: win.h:23
Definition: comm.h:97
Definition: ompi_datatype.h:68
Definition: status.h:22
Back-end type for MPI_Errorhandler.
Definition: errhandler.h:108
Definition: mutex_unix.h:53
Definition: op.h:21
Definition: topology.h:22
Definition: comm.h:22
Definition: mpicxx.cc:33
Definition: request.h:22
Definition: intercomm.h:23
Back-end structure for MPI_File.
Definition: file.h:42
Definition: mpi.h:337
Definition: topology.h:99
Definition: communicator.h:118
Definition: group.h:21
Definition: info.h:22
Definition: intracomm.h:21