MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RTOp_mpi.c
Go to the documentation of this file.
1 /*
2 // @HEADER
3 // ***********************************************************************
4 //
5 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
6 // Copyright (2003) Sandia Corporation
7 //
8 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9 // license for use of this work by or on behalf of the U.S. Government.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
39 //
40 // ***********************************************************************
41 // @HEADER
42 */
43 
44 /*
45  * This file includes selected hollow MPI function definitions for a
46  * sinlge process implementation.
47  */
48 
49 #include <assert.h>
50 
51 /*
52  * RAB: 2004/01/22: This file is included because it includes
53  * Thyra_Config.h which then defines RTOp_USE_MPI or not. If
54  * RTOp_USE_MPI is defined then this header file will also include
55  * RTOp_mpi.h for these delcarations.
56  */
57 #include "RTOp_MPI_config.h"
58 
59 #ifndef RTOp_USE_MPI
60 
61 int MPI_Init(int *argc, char ***argv)
62 {
63  return 0;
64 }
65 
66 int MPI_Finalize(void)
67 {
68  return 0;
69 }
70 
71 int MPI_Comm_size(MPI_Comm comm, int *size)
72 {
73  *size = 1;
74  return 0;
75 }
76 
77 int MPI_Comm_rank(MPI_Comm comm, int *rank)
78 {
79  *rank = 0;
80  return 0;
81 }
82 
83 int MPI_Type_struct(int count , int *array_of_blocklengths, MPI_Aint *array_of_displacements
84  , MPI_Datatype *array_of_types, MPI_Datatype *data_type)
85 {
86  /* Make the mpi datatype just the extent (needed latter!) */
87  int len = 0, extent = 0, k = 0;
88  for( k = 0; k < count; ++k ) {
89  switch( array_of_types[k] ) {
90  case MPI_CHAR:
91  len = sizeof(char);
92  break;
93  case MPI_INT:
94  len = sizeof(int);
95  break;
96  case MPI_FLOAT:
97  len = sizeof(float);
98  break;
99  case MPI_DOUBLE:
100  len = sizeof(double);
101  break;
102  default:
103  assert(0);
104  }
105  len = array_of_displacements[k] + array_of_blocklengths[k] * len;
106  if( len > extent )
107  extent = len;
108  }
109  *data_type = extent;
110  return 0;
111 }
112 
114 {
115  return 0;
116 }
117 
119 {
120  *op = MPI_DATATYPE_NULL;
121  return 0;
122 }
123 
124 int MPI_Op_create(MPI_User_function *func, int communitive, MPI_Op *op)
125 {
126  *op = (MPI_Op)*func;
127  return 0;
128 }
130 {
131  *op = MPI_OP_NULL;
132  return 0;
133 }
134 
135 int MPI_Send(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)
136 {
137  assert(0); /* Should never be called in serial mode */
138  return 0;
139 }
140 int MPI_Recv(void* buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, RTOP_MPI_Status* status)
141 {
142  assert(0); /* Should never be called in serial mode */
143  return 0;
144 }
145 
146 int MPI_Sendrecv_replace(void* buff, int count, MPI_Datatype datatype, int dest, int sendtag, int source, int recvtag, MPI_Comm comm, RTOP_MPI_Status* status)
147 {
148  assert(0); /* Should never be called in serial mode */
149  return 0;
150 }
151 
152 int MPI_Reduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op
153  , int root, MPI_Comm comm)
154 {
155  char
156  *_sendbuf = sendbuf,
157  *_recvbuf = recvbuf;
158  int k;
159  for( k = 0; k < count * datatype; ++k )
160  _recvbuf[k] =_sendbuf[k]; /* just copy bit for bit */
161  return 0;
162 }
163 
164 int MPI_Allreduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype
165  , MPI_Op op, MPI_Comm comm)
166 {
167  char
168  *_sendbuf = sendbuf,
169  *_recvbuf = recvbuf;
170  int k;
171  for( k = 0; k < count * datatype; ++k )
172  _recvbuf[k] =_sendbuf[k]; /* just copy bit for bit */
173  return 0;
174 }
175 
177 {
178  return 0;
179 }
180 
181 int MPI_Bcast(void* buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm )
182 {
183  return 0;
184 }
185 
186 int MPI_Gather(void* sendbuf, int sendcount, MPI_Datatype sendtype
187  , void* recvbuf, int recvcount, MPI_Datatype recvtype, int root , MPI_Comm comm )
188 {
189  char
190  *_sendbuf = sendbuf,
191  *_recvbuf = recvbuf;
192  int k;
193  assert(sendtype == recvtype);
194  assert(sendcount == recvcount);
195  for( k = 0; k < sendcount * sendtype; ++k )
196  _recvbuf[k] =_sendbuf[k]; /* just copy bit for bit */
197  return 0;
198 }
199 
200 #endif /* RTOp_USE_MPI */
int MPI_Reduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)
Definition: RTOp_mpi.c:152
int MPI_Type_free(MPI_Datatype *op)
Definition: RTOp_mpi.c:118
int MPI_Barrier(MPI_Comm comm)
Definition: RTOp_mpi.c:176
void( MPI_User_function)(void *, void *, int *, MPI_Datatype *)
Definition: RTOp_mpi.h:77
int MPI_Comm_size(MPI_Comm comm, int *size)
Definition: RTOp_mpi.c:71
int MPI_Type_commit(MPI_Datatype *datatype)
Definition: RTOp_mpi.c:113
int MPI_Comm_rank(MPI_Comm comm, int *rank)
Definition: RTOp_mpi.c:77
#define MPI_OP_NULL
Definition: RTOp_mpi.h:71
int MPI_Init(int *argc, char ***argv)
Definition: RTOp_mpi.c:61
int MPI_Sendrecv_replace(void *buff, int count, MPI_Datatype datatype, int dest, int sendtag, int source, int recvtag, MPI_Comm comm, RTOP_MPI_Status *status)
Definition: RTOp_mpi.c:146
int MPI_Op_create(MPI_User_function *func, int communitive, MPI_Op *op)
Definition: RTOp_mpi.c:124
int MPI_Send(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)
Definition: RTOp_mpi.c:135
int MPI_Comm
Definition: RTOp_mpi.h:67
#define MPI_Aint
Definition: RTOp_mpi.h:61
#define MPI_DATATYPE_NULL
Definition: RTOp_mpi.h:75
int MPI_Type_struct(int count, int *array_of_blocklengths, MPI_Aint *array_of_displacements, MPI_Datatype *array_of_types, MPI_Datatype *data_type)
Definition: RTOp_mpi.c:83
int MPI_Allreduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
Definition: RTOp_mpi.c:164
int MPI_Op_free(MPI_Op *op)
Definition: RTOp_mpi.c:129
int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, RTOP_MPI_Status *status)
Definition: RTOp_mpi.c:140
#define MPI_CHAR
Definition: RTOp_mpi.h:63
int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm)
Definition: RTOp_mpi.c:181
#define MPI_DOUBLE
Definition: RTOp_mpi.h:66
int MPI_Op
Definition: RTOp_mpi.h:70
int MPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm)
Definition: RTOp_mpi.c:186
#define MPI_INT
Definition: RTOp_mpi.h:64
#define MPI_FLOAT
Definition: RTOp_mpi.h:65
int MPI_Datatype
Definition: RTOp_mpi.h:62
int MPI_Finalize(void)
Definition: RTOp_mpi.c:66