Actual source code: mpi.h

  1: /*
  2:    This is a special set of bindings for uni-processor use of MPI by the PETSc library.
  3:  
  4:    NOT ALL THE MPI CALLS ARE IMPLEMENTED CORRECTLY! Only those needed in PETSc.

  6:    For example,
  7:    * Does not implement send to self.
  8:    * Does not implement attributes correctly.
  9: */

 11: /*
 12:   The following info is a response to one of the petsc-maint questions 
 13:   regarding MPIUNI.

 15:   MPIUNI was developed with the aim of getting PETSc compiled, and
 16:   usable in the absence of MPI. This is the reason each function is
 17:   not documented.  The development strategy was - to make enough
 18:   changes to it so that PETSc source compiles without errors, and runs
 19:   in the uni-processor mode.

 21:   Most PETSc objects have both sequential and parallel
 22:   implementations, which are separate. For eg: We have two types of
 23:   sparse matrix storage formats - SeqAIJ, and MPIAIJ. Some MPI
 24:   routines are used in the Seq part, but most of them are used in the
 25:   MPI part. The send/receive calls can be found mostly in the MPI
 26:   part.

 28:   When MPIUNI is used, only the Seq version of the PETSc objects are
 29:   used, even though the MPI variant of the objects are compiled. Since
 30:   there are no send/receive calls in the Seq variant, PETSc works fine
 31:   with MPIUNI in seq mode.

 33:   The reason some send/receive functions are defined to abort(), is to
 34:   detect sections of code that use send/receive functions, and gets
 35:   executed in the sequential mode. (which shouldn't happen in case of
 36:   PETSc).

 38:   One of the goals with MPIUNI, is to avoid the function call overhead
 39:   of a regular MPI implementation. If this was not the case, we could
 40:   as well have used a regular implementation of MPI as they are
 41:   available on almost all machines. Hence most of the functions are
 42:   implemented as macros. One of the additional benefits we got from
 43:   MPIUNI is, we were able to use PETSc on machines where using a
 44:   proper implementation of MPI was painful (for eg NT).

 46:   Proper implementation of send/receive would involve writing a
 47:   function for each of them. Inside each of these functions, we have
 48:   to check if the send is to self or receive is from self, and then
 49:   doing the buffering accordingly (until the receive is called) - or
 50:   what if a nonblocking receive is called, do a copy etc.. Handling
 51:   the buffering aspects might be complicated enough, that in this
 52:   case, a proper implementation of MPI might as well be used. This is
 53:   the reason the send to self is not implemented in MPIUNI, and never
 54:   will be.
 55: */


 60: /* Requred by abort() in mpi.c & for win64 */
 61: #include "petscconf.h"

 63: /* require an int variable large enough to hold a pointer */
 64: #if !defined(MPIUNI_INTPTR)
 65: #define MPIUNI_INTPTR long
 66: #endif

 68: #if defined(__BSdependh)
 69: #error You cannot use MPI-uni with BlockSolve95
 70: #endif
 71: #if defined(__basic_H)
 72: #error You cannot use MPI-uni with SPAI
 73: #endif

 75: #define _petsc_mpi_uni

 77: /*

 79:     MPIUNI_TMP is used in the macros below only to stop various C/C++ compilers
 80: from generating warning messages about unused variables while compiling PETSc.
 81: */

 84: #define MPI_COMM_WORLD       1
 85: #define MPI_COMM_SELF        MPI_COMM_WORLD
 86: #define MPI_COMM_NULL        0
 87: #define MPI_SUCCESS          0
 88: #define MPI_IDENT            0
 89: #define MPI_CONGRUENT        0
 90: #define MPI_SIMILAR          0
 91: #define MPI_UNEQUAL          3
 92: #define MPI_ANY_SOURCE     (-2)
 93: #define MPI_KEYVAL_INVALID   0
 94: #define MPI_ERR_UNKNOWN     18
 95: #define MPI_ERR_INTERN      21
 96: #define MPI_ERR_OTHER        1
 97: #define MPI_TAG_UB           0
 98: #define MPI_ERRORS_RETURN    0

100: /* External types */
101: typedef int    MPI_Comm;
102: typedef void   *MPI_Request;
103: typedef void   *MPI_Group;
104: typedef struct {int MPI_TAG,MPI_SOURCE,MPI_ERROR;} MPI_Status;
105: typedef char   *MPI_Errhandler;
106: typedef int    MPI_Fint;


110: /* In order to handle datatypes, we make them into "sizeof(raw-type)";
111:     this allows us to do the MPIUNI_Memcpy's easily */
112: #define MPI_Datatype        int
113: #define MPI_FLOAT           sizeof(float)
114: #define MPI_DOUBLE          sizeof(double)
115: #define MPI_CHAR            sizeof(char)
116: #define MPI_BYTE            sizeof(char)
117: #define MPI_INT             sizeof(int)
118: #define MPI_LONG            sizeof(long)
119: #define MPI_LONG_LONG_INT   sizeof(long long)
120: #define MPI_SHORT           sizeof(short)
121: #define MPI_UNSIGNED        sizeof(unsigned)
122: #define MPI_UNSIGNED_CHAR   sizeof(unsigned char)
123: #define MPI_UNSIGNED_LONG   sizeof(unsigned long)
124: #define MPI_COMPLEX         2*sizeof(float)
125: #define MPI_DOUBLE_COMPLEX  2*sizeof(double)
126: #define MPIU_PETSCLOGDOUBLE sizeof(PetscLogDouble)
127: #define MPI_FLOAT_INT       (sizeof(float) + sizeof(int))
128: #define MPI_DOUBLE_INT      (sizeof(double) + sizeof(int))
129: #define MPI_LONG_INT        (sizeof(long) + sizeof(int))
130: #define MPI_SHORT_INT       (sizeof(short) + sizeof(int))
131: #define MPI_2INT            (2* sizeof(int))



135: #define MPI_REQUEST_NULL    ((MPI_Request)0)
136: #define MPI_GROUP_NULL      ((MPI_Group)0)
137: typedef int MPI_Op;

139: #define MPI_SUM           0
140: #define MPI_ANY_TAG     (-1)
141: #define MPI_DATATYPE_NULL 0
142: /*
143:   Prototypes of some functions which are implemented in mpi.c
144: */
145: typedef int   (MPI_Copy_function)(MPI_Comm,int,void *,void *,void *,int *);
146: typedef int   (MPI_Delete_function)(MPI_Comm,int,void *,void *);
147: typedef void  (MPI_User_function)(void*, void *, int *, MPI_Datatype *);

149: /*
150:   In order that the PETSc MPIUNI can be used with another package that has its
151:   own MPIUni we map the following function names to a unique PETSc name. Those functions
152:   are defined in mpi.c
153: */

165: #define MPI_Abort         Petsc_MPI_Abort
166: #define MPI_Attr_get      Petsc_MPI_Attr_get
167: #define MPI_Keyval_free   Petsc_MPI_Keyval_free
168: #define MPI_Attr_put      Petsc_MPI_Attr_put
169: #define MPI_Attr_delete   Petsc_MPI_Attr_delete
170: #define MPI_Keyval_create Petsc_MPI_Keyval_create
171: #define MPI_Comm_free     Petsc_MPI_Comm_free
172: #define MPI_Initialized   Petsc_MPI_Initialized
173: #define MPI_Comm_dup      Petsc_MPI_Comm_dup
174: #define MPI_Finalize      Petsc_MPI_Finalize

176: #define MPI_Aint int
177: /* 
178:     Routines we have replace with macros that do nothing 
179:     Some return error codes others return success
180: */

182: #define MPI_Comm_f2c(comm) (MPI_Comm)(comm)
183: #define MPI_Comm_c2f(comm) (MPI_Fint)(comm)


186: #define MPI_Init(argc,argv) \
187:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (argc),\
188:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (argv),\
189:       MPI_SUCCESS)
190: #define MPI_Send(buf,count,datatype,dest,tag,comm)  \
191:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
192:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
193:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
194:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
195:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
196:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
197:       MPI_SUCCESS)
198: #define MPI_Recv(buf,count,datatype,source,tag,comm,status) \
199:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
200:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
201:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
202:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (source),\
203:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
204:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
205:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (status),\
206:       MPI_Abort(MPI_COMM_WORLD,0))
207: #define MPI_Get_count(status, datatype,count) \
208:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (status),\
209:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
210:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
211:       MPI_Abort(MPI_COMM_WORLD,0))
212: #define MPI_Bsend(buf,count,datatype,dest,tag,comm)  \
213:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
214:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
215:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
216:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
217:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
218:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
219:       MPI_SUCCESS)
220: #define MPI_Ssend(buf,count, datatype,dest,tag,comm) \
221:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
222:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
223:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
224:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
225:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
226:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
227:       MPI_SUCCESS)
228: #define MPI_Rsend(buf,count, datatype,dest,tag,comm) \
229:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
230:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
231:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
232:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
233:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
234:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
235:       MPI_SUCCESS)
236: #define MPI_Buffer_attach(buffer,size) \
237:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buffer),\
238:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (size),\
239:       MPI_SUCCESS)
240: #define MPI_Buffer_detach(buffer,size)\
241:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buffer),\
242:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (size),\
243:       MPI_SUCCESS)
244: #define MPI_Ibsend(buf,count, datatype,dest,tag,comm,request) \
245:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
246:        MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
247:        MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
248:        MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
249:        MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
250:        MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
251:        MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
252:        MPI_SUCCESS)
253: #define MPI_Issend(buf,count, datatype,dest,tag,comm,request) \
254:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
255:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
256:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
257:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
258:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
259:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
260:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
261:       MPI_SUCCESS)
262: #define MPI_Irsend(buf,count, datatype,dest,tag,comm,request) \
263:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
264:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
265:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
266:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
267:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
268:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
269:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
270:       MPI_SUCCESS)
271: #define MPI_Irecv(buf,count, datatype,source,tag,comm,request) \
272:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
273:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
274:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
275:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (source),\
276:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
277:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
278:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
279:       MPI_Abort(MPI_COMM_WORLD,0))
280: #define MPI_Isend(buf,count, datatype,dest,tag,comm,request) \
281:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
282:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
283:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
284:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
285:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
286:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
287:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
288:       MPI_Abort(MPI_COMM_WORLD,0))
289: #define MPI_Wait(request,status) \
290:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
291:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (status),\
292:       MPI_SUCCESS)
293: #define MPI_Test(request,flag,status) \
294:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
295:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (status),\
296:       *(flag) = 0, \
297:       MPI_SUCCESS)
298: #define MPI_Request_free(request) \
299:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
300:       MPI_SUCCESS)
301: #define MPI_Waitany(a,b,c,d) \
302:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (a),\
303:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (b),\
304:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (c),\
305:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (d),\
306:       MPI_SUCCESS)
307: #define MPI_Testany(a,b,c,d,e) \
308:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (a),\
309:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (b),\
310:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (c),\
311:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (d),\
312:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (e),\
313:       MPI_SUCCESS)
314: #define MPI_Waitall(count,array_of_requests,array_of_statuses) \
315:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
316:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (array_of_requests),\
317:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (array_of_statuses),\
318:       MPI_SUCCESS)
319: #define MPI_Testall(count,array_of_requests,flag,array_of_statuses) \
320:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
321:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (array_of_requests),\
322:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (flag),\
323:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (array_of_statuses),\
324:       MPI_SUCCESS)
325: #define MPI_Waitsome(incount,array_of_requests,outcount,\
326:                      array_of_indices,array_of_statuses) \
327:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (incount),\
328:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (array_of_requests),\
329:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (outcount),\
330:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (array_of_indices),\
331:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (array_of_statuses),\
332:       MPI_SUCCESS)
333: #define MPI_Comm_group(comm,group) \
334:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
335:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (group),\
336:       MPI_SUCCESS)
337: #define MPI_Group_incl(group,n,ranks,newgroup) \
338:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (group),\
339:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (n),\
340:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (ranks),\
341:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (newgroup),\
342:       MPI_SUCCESS)
343: #define MPI_Testsome(incount,array_of_requests,outcount,\
344:                      array_of_indices,array_of_statuses) MPI_SUCCESS
345: #define MPI_Iprobe(source,tag,comm,flag,status) (*(flag)=0, MPI_SUCCESS)
346: #define MPI_Probe(source,tag,comm,status) MPI_SUCCESS
347: #define MPI_Cancel(request) (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),MPI_SUCCESS)
348: #define MPI_Test_cancelled(status,flag) (*(flag)=0,MPI_SUCCESS)
349: #define MPI_Send_init(buf,count, datatype,dest,tag,comm,request) \
350:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
351:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
352:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
353:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
354:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
355:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
356:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
357:      MPI_SUCCESS)
358: #define MPI_Bsend_init(buf,count, datatype,dest,tag,comm,request) \
359:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
360:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
361:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
362:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
363:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
364:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
365:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
366:      MPI_SUCCESS)
367: #define MPI_Ssend_init(buf,count, datatype,dest,tag,comm,request) \
368:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
369:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
370:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
371:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
372:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
373:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
374:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
375:      MPI_SUCCESS)
376: #define MPI_Bsend_init(buf,count, datatype,dest,tag,comm,request) \
377:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
378:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
379:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
380:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
381:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
382:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
383:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
384:      MPI_SUCCESS)
385: #define MPI_Rsend_init(buf,count, datatype,dest,tag,comm,request) \
386:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
387:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
388:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
389:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
390:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
391:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
392:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
393:      MPI_SUCCESS)
394: #define MPI_Recv_init(buf,count, datatype,source,tag,comm,request) \
395:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
396:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
397:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
398:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (source),\
399:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
400:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
401:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
402:      MPI_SUCCESS)
403: #define MPI_Start(request) (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),MPI_SUCCESS)
404: #define MPI_Startall(count,array_of_requests) \
405:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
406:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (array_of_requests),\
407:      MPI_SUCCESS)
408: #define MPI_Op_create(function,commute,op) \
409:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (function),\
410:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (commute),\
411:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (op),\
412:      MPI_SUCCESS)
413: #define MPI_Op_free(op) \
414:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (op),\
415:      MPI_SUCCESS)
416:      /* Need to determine sizeof "sendtype" */
417: #define MPI_Sendrecv(sendbuf,sendcount, sendtype,\
418:      dest,sendtag,recvbuf,recvcount,\
419:      recvtype,source,recvtag,\
420:      comm,status) \
421:      MPIUNI_Memcpy(recvbuf,sendbuf,(sendcount) * (sendtype))
422: #define MPI_Sendrecv_replace(buf,count, datatype,dest,sendtag,\
423:      source,recvtag,comm,status) MPI_SUCCESS
424: #define MPI_Type_contiguous(count, oldtype,newtype) \
425:      (*(newtype) = (count)*(oldtype),MPI_SUCCESS)
426: #define MPI_Type_vector(count,blocklength,stride,oldtype, newtype) MPI_SUCCESS
427: #define MPI_Type_hvector(count,blocklength,stride,oldtype, newtype) MPI_SUCCESS
428: #define MPI_Type_indexed(count,array_of_blocklengths,\
429:      array_of_displacements, oldtype,\
430:      newtype) MPI_SUCCESS
431: #define MPI_Type_hindexed(count,array_of_blocklengths,\
432:      array_of_displacements, oldtype,\
433:      newtype) MPI_SUCCESS
434: #define MPI_Type_struct(count,array_of_blocklengths,\
435:      array_of_displacements,\
436:      array_of_types, newtype) MPI_SUCCESS
437: #define MPI_Address(location,address) \
438:      (*(address) = (MPIUNI_INTPTR)(char *)(location),MPI_SUCCESS)
439: #define MPI_Type_extent(datatype,extent) \
440:      MPI_Abort(MPI_COMM_WORLD,0)
441: #define MPI_Type_size(datatype,size) \
442:      MPI_Abort(MPI_COMM_WORLD,0)
443: #define MPI_Type_lb(datatype,displacement) \
444:      MPI_Abort(MPI_COMM_WORLD,0)
445: #define MPI_Type_ub(datatype,displacement) \
446:      MPI_Abort(MPI_COMM_WORLD,0)
447: #define MPI_Type_commit(datatype) (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
448:      MPI_SUCCESS)
449: #define MPI_Type_free(datatype) MPI_SUCCESS
450: #define MPI_Get_elements(status, datatype,count) \
451:      MPI_Abort(MPI_COMM_WORLD,0)
452: #define MPI_Pack(inbuf,incount, datatype,outbuf,\
453:      outsize,position, comm) \
454:      MPI_Abort(MPI_COMM_WORLD,0)
455: #define MPI_Unpack(inbuf,insize,position,outbuf,\
456:      outcount, datatype,comm) \
457:      MPI_Abort(MPI_COMM_WORLD,0)
458: #define MPI_Pack_size(incount, datatype,comm,size) \
459:      MPI_Abort(MPI_COMM_WORLD,0)
460: #define MPI_Barrier(comm) \
461:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
462:      MPI_SUCCESS)
463: #define MPI_Bcast(buffer,count,datatype,root,comm) \
464:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buffer),\
465:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
466:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
467:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
468:      MPI_SUCCESS)
469: #define MPI_Gather(sendbuf,sendcount, sendtype,\
470:      recvbuf,recvcount, recvtype,\
471:      root,comm) \
472:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvcount),\
473:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (root),\
474:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvtype),\
475:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
476:      MPIUNI_Memcpy(recvbuf,sendbuf,(sendcount)* (sendtype)),\
477:      MPI_SUCCESS)
478: #define MPI_Gatherv(sendbuf,sendcount, sendtype,\
479:      recvbuf,recvcounts,displs,\
480:      recvtype,root,comm) \
481:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvcounts),\
482:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (displs),\
483:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvtype),\
484:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (root),\
485:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
486:      MPIUNI_Memcpy(recvbuf,sendbuf,(sendcount)* (sendtype)),\
487:      MPI_SUCCESS)
488: #define MPI_Scatter(sendbuf,sendcount, sendtype,\
489:      recvbuf,recvcount, recvtype,\
490:      root,comm) \
491:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (sendbuf),\
492:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (sendcount),\
493:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (sendtype),\
494:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvbuf),\
495:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvcount),\
496:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvtype),\
497:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (root),\
498:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),MPI_Abort(MPI_COMM_WORLD,0))
499: #define MPI_Scatterv(sendbuf,sendcounts,displs,\
500:      sendtype, recvbuf,recvcount,\
501:      recvtype,root,comm) \
502:      (MPIUNI_Memcpy(recvbuf,sendbuf,(recvcount)*(recvtype)),\
503:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (displs),\
504:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (sendtype),\
505:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (sendcounts),\
506:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (root),\
507:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
508:      MPI_SUCCESS)
509: #define MPI_Allgather(sendbuf,sendcount, sendtype,\
510:      recvbuf,recvcount, recvtype,comm) \
511:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvcount),\
512:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvtype),\
513:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
514:      MPIUNI_Memcpy(recvbuf,sendbuf,(sendcount)* (sendtype)),\
515:      MPI_SUCCESS)
516: #define MPI_Allgatherv(sendbuf,sendcount, sendtype,\
517:      recvbuf,recvcounts,displs,recvtype,comm) \
518:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvcounts),\
519:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (displs),\
520:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvtype),\
521:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
522:      MPIUNI_Memcpy(recvbuf,sendbuf,(sendcount)* (sendtype)),\
523:      MPI_SUCCESS)
524: #define MPI_Alltoall(sendbuf,sendcount, sendtype,\
525:      recvbuf,recvcount, recvtype,comm) \
526:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvcount),\
527:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvtype),\
528:       MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
529:       MPIUNI_Memcpy(recvbuf,sendbuf,(sendcount)* (sendtype)),\
530:       MPI_SUCCESS)
531: #define MPI_Alltoallv(sendbuf,sendcounts,sdispls,\
532:      sendtype, recvbuf,recvcounts,\
533:      rdispls, recvtype,comm) MPI_Abort(MPI_COMM_WORLD,0)
534: #define MPI_Reduce(sendbuf, recvbuf,count,\
535:      datatype,op,root,comm) \
536:      (MPIUNI_Memcpy(recvbuf,sendbuf,(count)*(datatype)),\
537:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),MPI_SUCCESS)
538: #define MPI_Allreduce(sendbuf, recvbuf,count,datatype,op,comm) \
539:      (MPIUNI_Memcpy(recvbuf,sendbuf,(count)*(datatype)),\
540:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),MPI_SUCCESS)
541: #define MPI_Scan(sendbuf, recvbuf,count,datatype,op,comm) \
542:      (MPIUNI_Memcpy(recvbuf,sendbuf,(count)*(datatype)),\
543:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),MPI_SUCCESS)
544: #define MPI_Reduce_scatter(sendbuf, recvbuf,recvcounts,\
545:      datatype,op,comm) \
546:      MPI_Abort(MPI_COMM_WORLD,0)
547: #define MPI_Group_size(group,size) (*(size)=1,MPI_SUCCESS)
548: #define MPI_Group_rank(group,rank) (*(rank)=0,MPI_SUCCESS)
549: #define MPI_Group_translate_ranks (group1,n,ranks1,\
550:      group2,ranks2) MPI_Abort(MPI_COMM_WORLD,0)
551: #define MPI_Group_compare(group1,group2,result) \
552:      (*(result)=1,MPI_SUCCESS)
553: #define MPI_Group_union(group1,group2,newgroup) MPI_SUCCESS
554: #define MPI_Group_intersection(group1,group2,newgroup) MPI_SUCCESS
555: #define MPI_Group_difference(group1,group2,newgroup) MPI_SUCCESS
556: #define MPI_Group_excl(group,n,ranks,newgroup) MPI_SUCCESS
557: #define MPI_Group_range_incl(group,n,ranges,newgroup) MPI_SUCCESS
558: #define MPI_Group_range_excl(group,n,ranges,newgroup) MPI_SUCCESS
559: #define MPI_Group_free(group) \
560:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (group),\
561:      MPI_SUCCESS)
562: #define MPI_Comm_size(comm,size) \
563:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
564:      *(size)=1,\
565:      MPI_SUCCESS)
566: #define MPI_Comm_rank(comm,rank) \
567:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
568:      *(rank)=0,\
569:      MPI_SUCCESS)
570: #define MPI_Comm_compare(comm1,comm2,result) \
571:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm1),\
572:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm2),\
573:      *(result)=MPI_IDENT,\
574:      MPI_SUCCESS)
575: #define MPI_Comm_create(comm,group,newcomm)  \
576:      (*(newcomm) =  (comm),\
577:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (group),\
578:      MPI_SUCCESS)
579: #define MPI_Comm_split(comm,color,key,newcomm) MPI_SUCCESS
580: #define MPI_Comm_test_inter(comm,flag) (*(flag)=1,MPI_SUCCESS)
581: #define MPI_Comm_remote_size(comm,size) (*(size)=1,MPI_SUCCESS)
582: #define MPI_Comm_remote_group(comm,group) MPI_SUCCESS
583: #define MPI_Intercomm_create(local_comm,local_leader,peer_comm,\
584:      remote_leader,tag,newintercomm) MPI_SUCCESS
585: #define MPI_Intercomm_merge(intercomm,high,newintracomm) MPI_SUCCESS

587: #define MPI_Topo_test(comm,status) MPI_SUCCESS
588: #define MPI_Cart_create(comm_old,ndims,dims,periods,\
589:      reorder,comm_cart) MPI_SUCCESS
590: #define MPI_Dims_create(nnodes,ndims,dims) MPI_Abort(MPI_COMM_WORLD,0)
591: #define MPI_Graph_create(comm,a,b,c,d,e) MPI_SUCCESS
592: #define MPI_Graphdims_Get(comm,nnodes,nedges) MPI_Abort(MPI_COMM_WORLD,0)
593: #define MPI_Graph_get(comm,a,b,c,d) MPI_Abort(MPI_COMM_WORLD,0)
594: #define MPI_Cartdim_get(comm,ndims) MPI_Abort(MPI_COMM_WORLD,0)
595: #define MPI_Cart_get(comm,maxdims,dims,periods,coords) \
596:      MPI_Abort(MPI_COMM_WORLD,0)
597: #define MPI_Cart_rank(comm,coords,rank) MPI_Abort(MPI_COMM_WORLD,0)
598: #define MPI_Cart_coords(comm,rank,maxdims,coords) \
599:      MPI_Abort(MPI_COMM_WORLD,0)
600: #define MPI_Graph_neighbors_count(comm,rank,nneighbors) \
601:      MPI_Abort(MPI_COMM_WORLD,0)
602: #define MPI_Graph_neighbors(comm,rank,maxneighbors,neighbors) \
603:      MPI_Abort(MPI_COMM_WORLD,0)
604: #define MPI_Cart_shift(comm,direction,disp,rank_source,rank_dest) \
605:      MPI_Abort(MPI_COMM_WORLD,0)
606: #define MPI_Cart_sub(comm,remain_dims,newcomm) MPI_Abort(MPI_COMM_WORLD,0)
607: #define MPI_Cart_map(comm,ndims,dims,periods,newrank) MPI_Abort(MPI_COMM_WORLD,0)
608: #define MPI_Graph_map(comm,a,b,c,d) MPI_Abort(MPI_COMM_WORLD,0)
609: #define MPI_Get_processor_name(name,result_len) \
610:      (MPIUNI_Memcpy(name,"localhost",9*sizeof(char)),name[10] = 0,*(result_len) = 10)
611: #define MPI_Errhandler_create(function,errhandler) \
612:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (errhandler),\
613:      MPI_SUCCESS)
614: #define MPI_Errhandler_set(comm,errhandler) \
615:      (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
616:      MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (errhandler),\
617:      MPI_SUCCESS)
618: #define MPI_Errhandler_get(comm,errhandler) MPI_SUCCESS
619: #define MPI_Errhandler_free(errhandler) MPI_SUCCESS
620: #define MPI_Error_string(errorcode,string,result_len) MPI_SUCCESS
621: #define MPI_Error_class(errorcode,errorclass) MPI_SUCCESS
622: #define MPI_Wtick() 1.0
623: #define MPI_Wtime() 0.0
624: #define MPI_Pcontrol(level) MPI_SUCCESS

626: #define MPI_NULL_COPY_FN   0
627: #define MPI_NULL_DELETE_FN 0

629: #endif