Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
commpi.h
Go to the documentation of this file.
1 /* *******************************************************************
2  * Rocstar Simulation Suite *
3  * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4  * *
5  * Illinois Rocstar LLC *
6  * Champaign, IL *
7  * www.illinoisrocstar.com *
8  * sales@illinoisrocstar.com *
9  * *
10  * License: See LICENSE file in top level of distribution package or *
11  * http://opensource.org/licenses/NCSA *
12  *********************************************************************/
13 /* *******************************************************************
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22  *********************************************************************/
23 // $Id: commpi.h,v 1.20 2008/12/06 08:43:24 mtcampbe Exp $
24 
32 #ifndef __COM_MPI__
33 #define __COM_MPI__
34 
35 #ifndef DUMMY_MPI /* Whether to use the serial dummy MPI */
36 
37 //#define MPICH_IGNORE_CXX_SEEK
38 #include <mpi.h>
39 
40 #else /* Define the serial dummy MPI */
41 
42 #include "roccom_basic.h"
43 #include <cstdlib>
44 #include <sys/time.h>
45 
46 typedef int MPI_Comm;
47 typedef int MPI_Request;
48 typedef int MPI_Status;
49 typedef int MPI_Op;
50 typedef int MPI_Datatype;
51 
52 enum { MPI_COMM_NULL=-1};
53 enum { MPI_SUM=1, MPI_PROD, MPI_MIN, MPI_MAX, MPI_BOR,
54  MPI_BAND, MPI_LOR, MPI_LAND,
55  MPI_DOUBLE_INT,MPI_MINLOC,
56  MPI_MAXLOC, MPI_COMM_WORLD, MPI_COMM_SELF,
57  MPI_BYTE=COM_BYTE, MPI_CHAR=COM_CHAR, MPI_INT=COM_INT,
58  MPI_FLOAT=COM_FLOAT, MPI_DOUBLE=COM_DOUBLE};
59 
62 extern int MPI_Init( int*, char***);
65 inline int MPI_Initialized( int *flag) { *flag=1; return 0; }
67 extern int MPI_Finalize();
69 inline int MPI_Abort( MPI_Comm, int errorcode) { std::abort(); return 0; }
71 
74 inline int MPI_Comm_size( MPI_Comm, int *size) { *size = 1; return 0; }
77 inline int MPI_Comm_rank( MPI_Comm, int *rank) { *rank = 0; return 0; }
78 
79 inline MPI_Comm MPI_Comm_c2f( MPI_Comm comm) { return comm; }
80 inline MPI_Comm MPI_Comm_f2c( MPI_Comm comm) { return comm; }
82 
85 inline double MPI_Wtime() {
87  ::timeval tv;
88  gettimeofday( &tv, NULL);
89 
90  return tv.tv_sec + tv.tv_usec*1.e-6;
91 }
92 
93 inline void MPI_Pcontrol( int level, ...) {}
94 
97 inline int MPI_Barrier( MPI_Comm) { return 0; }
99 
102 inline int MPI_Bcast( void *buffer, int count, MPI_Datatype datatype,
103  int root, MPI_Comm comm) { return 0; }
104 
107 extern int MPI_Allreduce( void *sendbuf, void *recvbuf, int count,
108  MPI_Datatype datatype, MPI_Op op, MPI_Comm comm );
109 
111 extern int MPI_Allgather( void *sendbuf, int sendcount, MPI_Datatype sendtype,
112  void *recvbuf, int recvcount, MPI_Datatype recvtype,
113  MPI_Comm comm );
114 
116 extern int MPI_Allgatherv ( void *sendbuf, int sendcount,
117  MPI_Datatype sendtype,
118  void *recvbuf, int *recvcounts, int *displs,
119  MPI_Datatype recvtype, MPI_Comm comm );
120 
122 extern int MPI_Alltoall( void *sendbuf, int sendcount, MPI_Datatype sendtype,
123  void *recvbuf, int recvcnt, MPI_Datatype recvtype,
124  MPI_Comm comm );
125 
127 extern int MPI_Alltoallv( void *sendbuf, int *sendcount,
128  int *senddispls, MPI_Datatype sendtype,
129  void *recvbuf, int *recvcounts, int *recvdispls,
130  MPI_Datatype recvtype, MPI_Comm comm );
132 
136 extern int MPI_Isend( void *buf, int count, MPI_Datatype datatype,
138  int dest, int tag,
139  MPI_Comm comm, MPI_Request *request );
140 
142 extern int MPI_Irecv( void *buf, int count, MPI_Datatype datatype,
143  int src, int tag,
144  MPI_Comm comm, MPI_Request *request );
145 
147 inline int MPI_Waitall( int count,
148  MPI_Request array_of_requests[],
149  MPI_Status array_of_statuses[] )
150 { return 0; }
151 
153 inline int MPI_Waitany( int count,
154  MPI_Request array_of_requests[],
155  int *index,
156  MPI_Status *status )
157 { *index=0; return 0; }
159 
160 #endif /* DUMMY_MPI */
161 
162 inline int COMMPI_Comm_rank( MPI_Comm c)
163 { int rank; MPI_Comm_rank( c, &rank); return rank; }
164 
165 inline int COMMPI_Comm_size( MPI_Comm c)
166 { int size; MPI_Comm_size( c, &size); return size; }
167 
168 inline int COMMPI_Initialized()
169 { int flag; MPI_Initialized( &flag); return flag; }
170 
175 extern int COMMPI_Isend( void *buf, int count, MPI_Datatype datatype,
177  int dest, int tag,
178  MPI_Comm comm, MPI_Request *request );
180 
181 
183 extern int COMMPI_Irecv( void *buf, int count, MPI_Datatype datatype,
184  int src, int tag,
185  MPI_Comm comm, MPI_Request *request );
186 
187 // Not all MPI implementations support MPI_Comm_f2c and MPI_Comm_c2f.
188 // Assume C and F communicators are compatible if the C type is int.
189 template <class T>
190 inline int COMMPI_Comm_c2f( T t)
191 { return MPI_Comm_c2f( t); }
192 
193 template <>
194 inline int COMMPI_Comm_c2f( int t)
195 { return t; }
196 
197 template <>
198 inline int COMMPI_Comm_c2f( unsigned int t)
199 { return t; }
200 
201 template <class T>
202 inline T COMMPI_Comm_f2c( int c, T)
203 { return MPI_Comm_f2c( c); }
204 
205 template <>
206 inline int COMMPI_Comm_f2c( int t, int)
207 { return t; }
208 
209 template <>
210 inline unsigned int COMMPI_Comm_f2c( int t, unsigned int)
211 { return t; }
212 
213 #endif /* __MY_MPI__ */
214 
215 
216 
217 
218 
219 
int COMMPI_Comm_rank(MPI_Comm c)
Definition: commpi.h:162
int COMMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Request *request)
Begins a nonblocking receive.
Definition: commpi.C:131
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_BYTE
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_COMM_WORLD
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_COMM_SELF
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_GROUP_EMPTY INTEGER MPI_MAX
T COMMPI_Comm_f2c(int c, T)
Definition: commpi.h:202
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_GROUP_EMPTY INTEGER MPI_MIN
C/C++ Data types.
Definition: roccom_basic.h:129
This file contains some definitions of macros and constants for Roccoms.
int COMMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request)
Begins a nonblocking send.
Definition: commpi.C:112
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_GROUP_EMPTY INTEGER MPI_BAND INTEGER MPI_BOR
int COMMPI_Comm_size(MPI_Comm c)
Definition: commpi.h:165
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_GROUP_EMPTY INTEGER MPI_LAND
int COMMPI_Comm_c2f(T t)
Definition: commpi.h:190
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_GROUP_EMPTY INTEGER MPI_BAND INTEGER MPI_LOR
static int rank
Definition: advectest.C:66
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_GROUP_EMPTY INTEGER MPI_PROD
int COMMPI_Initialized()
Definition: commpi.h:168
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_GROUP_EMPTY INTEGER MPI_SUM