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 a full MPI implementation. With this, we
17: were able to provide PETSc on Windows, Windows64 even before any MPI
18: implementation was available on these platforms. [Or with certain
19: compilers - like borland, that do not have a usable MPI
20: implementation]
22: However - providing a seqential, standards compliant MPI
23: implementation is *not* the goal of MPIUNI. The development strategy
24: was - to make enough changes to it so that PETSc sources, examples
25: compile without errors, and runs in the uni-processor mode. This is
26: the reason each function is not documented.
28: PETSc usage of MPIUNI is primarily from C. However a minimal fortran
29: interface is also provided - to get PETSc fortran examples with a
30: few MPI calls working.
32: One of the optimzation with MPIUNI, is to avoid the function call
33: overhead, when possible. Hence most of the C functions are
34: implemented as macros. However the function calls cannot be avoided
35: with fortran usage.
37: Most PETSc objects have both sequential and parallel
38: implementations, which are separate. For eg: We have two types of
39: sparse matrix storage formats - SeqAIJ, and MPIAIJ. Some MPI
40: routines are used in the Seq part, but most of them are used in the
41: MPI part. The send/receive calls can be found mostly in the MPI
42: part.
44: When MPIUNI is used, only the Seq version of the PETSc objects are
45: used, even though the MPI variant of the objects are compiled. Since
46: there are no send/receive calls in the Seq variant, PETSc works fine
47: with MPIUNI in seq mode.
49: The reason some send/receive functions are defined to abort(), is to
50: detect sections of code that use send/receive functions, and gets
51: executed in the sequential mode. (which shouldn't happen in case of
52: PETSc).
54: Proper implementation of send/receive would involve writing a
55: function for each of them. Inside each of these functions, we have
56: to check if the send is to self or receive is from self, and then
57: doing the buffering accordingly (until the receive is called) - or
58: what if a nonblocking receive is called, do a copy etc.. Handling
59: the buffering aspects might be complicated enough, that in this
60: case, a proper implementation of MPI might as well be used. This is
61: the reason the send to self is not implemented in MPIUNI, and never
62: will be.
63:
64: Proper implementations of MPI [for eg: MPICH & OpenMPI] are
65: available for most machines. When these packages are available, Its
66: generally preferable to use one of them instead of MPIUNI - even if
67: the user is using PETSc sequentially.
69: - MPIUNI does not support all MPI functions [or functionality].
70: Hence it might not work with external packages or user code that
71: might have MPI calls in it.
73: - MPIUNI is not a standards compliant implementation for np=1.
74: For eg: if the user code has send/recv to self, then it will
75: abort. [Similar issues with a number of other MPI functionality]
76: However MPICH & OpenMPI are the correct implementations of MPI
77: standard for np=1.
79: - When user code uses multiple MPI based packages that have their
80: own *internal* stubs equivalent to MPIUNI - in sequential mode,
81: invariably these multiple implementations of MPI for np=1 conflict
82: with each other. The correct thing to do is: make all such
83: packages use the *same* MPI implementation for np=1. MPICH/OpenMPI
84: satisfy this requirement correctly [and hence the correct choice].
86: - Using MPICH/OpenMPI sequentially should have minimal
87: disadvantages. [for eg: these binaries can be run without
88: mpirun/mpiexec as ./executable, without requiring any extra
89: configurations for ssh/rsh/daemons etc..]. This should not be a
90: reason to avoid these packages for sequential use.
92: Instructions for building standalone MPIUNI [for eg: linux/gcc+gfortran]:
93: - extract include/mpiuni/mpi.h,mpif.f, src/sys/mpiuni/mpi.c from PETSc
94: - remove reference to petscconf.h from mpi.h
95: - gcc -c mpi.c -DPETSC_HAVE_STDLIB_H -DPETSC_HAVE_FORTRAN_UNDERSCORE
96: - ar cr libmpiuni.a mpi.o
98: */
103: /* Requred by abort() in mpi.c & for win64 */
104: #include "petscconf.h"
106: #if defined(__cplusplus)
108: #endif
110: /* require an int variable large enough to hold a pointer */
111: #if !defined(MPIUNI_INTPTR)
112: #define MPIUNI_INTPTR long
113: #endif
115: /*
117: MPIUNI_TMP is used in the macros below only to stop various C/C++ compilers
118: from generating warning messages about unused variables while compiling PETSc.
119: */
122: #define MPI_COMM_WORLD 1
123: #define MPI_COMM_SELF MPI_COMM_WORLD
124: #define MPI_COMM_NULL 0
125: #define MPI_SUCCESS 0
126: #define MPI_IDENT 0
127: #define MPI_CONGRUENT 1
128: #define MPI_SIMILAR 2
129: #define MPI_UNEQUAL 3
130: #define MPI_ANY_SOURCE (-2)
131: #define MPI_KEYVAL_INVALID 0
132: #define MPI_ERR_UNKNOWN 18
133: #define MPI_ERR_INTERN 21
134: #define MPI_ERR_OTHER 1
135: #define MPI_TAG_UB 0
136: #define MPI_ERRORS_RETURN 0
137: #define MPI_UNDEFINED (-32766)
139: /* External types */
140: typedef int MPI_Comm;
141: typedef void *MPI_Request;
142: typedef void *MPI_Group;
143: typedef struct {int MPI_TAG,MPI_SOURCE,MPI_ERROR;} MPI_Status;
144: typedef char *MPI_Errhandler;
145: typedef int MPI_Fint;
146: typedef int MPI_File;
147: typedef int MPI_Info;
148: typedef int MPI_Offset;
151: /* In order to handle datatypes, we make them into "sizeof(raw-type)";
152: this allows us to do the MPIUNI_Memcpy's easily */
153: #define MPI_Datatype int
154: #define MPI_FLOAT sizeof(float)
155: #define MPI_DOUBLE sizeof(double)
156: #define MPI_LONG_DOUBLE sizeof(long double)
157: #define MPI_CHAR sizeof(char)
158: #define MPI_BYTE sizeof(char)
159: #define MPI_INT sizeof(int)
160: #define MPI_LONG sizeof(long)
161: #define MPI_LONG_LONG_INT sizeof(long long)
162: #define MPI_SHORT sizeof(short)
163: #define MPI_UNSIGNED_SHORT sizeof(unsigned short)
164: #define MPI_UNSIGNED sizeof(unsigned)
165: #define MPI_UNSIGNED_CHAR sizeof(unsigned char)
166: #define MPI_UNSIGNED_LONG sizeof(unsigned long)
167: #define MPI_COMPLEX 2*sizeof(float)
168: #define MPI_C_COMPLEX 2*sizeof(float)
169: #define MPI_C_DOUBLE_COMPLEX 2*sizeof(double)
170: #define MPI_FLOAT_INT (sizeof(float) + sizeof(int))
171: #define MPI_DOUBLE_INT (sizeof(double) + sizeof(int))
172: #define MPI_LONG_INT (sizeof(long) + sizeof(int))
173: #define MPI_SHORT_INT (sizeof(short) + sizeof(int))
174: #define MPI_2INT (2* sizeof(int))
176: #if defined(PETSC_USE_REAL___FLOAT128)
178: #define MPI_sizeof(datatype) ((datatype == MPIU___FLOAT128) ? 2*sizeof(double) : datatype)
179: #else
180: #define MPI_sizeof(datatype) (datatype)
181: #endif
185: #define MPI_REQUEST_NULL ((MPI_Request)0)
186: #define MPI_GROUP_NULL ((MPI_Group)0)
187: #define MPI_INFO_NULL ((MPI_Info)0)
188: #define MPI_BOTTOM (void *)0
189: typedef int MPI_Op;
191: #define MPI_MODE_RDONLY 0
192: #define MPI_MODE_WRONLY 0
193: #define MPI_MODE_CREATE 0
195: #define MPI_SUM 0
196: #define MPI_MAX 0
197: #define MPI_MIN 0
198: #define MPI_ANY_TAG (-1)
199: #define MPI_DATATYPE_NULL 0
200: #define MPI_PACKED 0
201: #define MPI_MAX_ERROR_STRING 2056
202: #define MPI_STATUS_IGNORE (MPI_Status *)1
203: #define MPI_ORDER_FORTRAN 57
204: #define MPI_IN_PLACE (void *) -1
206: /*
207: Prototypes of some functions which are implemented in mpi.c
208: */
209: typedef int (MPI_Copy_function)(MPI_Comm,int,void *,void *,void *,int *);
210: typedef int (MPI_Delete_function)(MPI_Comm,int,void *,void *);
211: typedef void (MPI_User_function)(void*, void *, int *, MPI_Datatype *);
213: /*
214: In order that the PETSc MPIUNI can be used with another package that has its
215: own MPIUni we map the following function names to a unique PETSc name. Those functions
216: are defined in mpi.c and put into the libpetscsys.a or libpetsc.a library.
218: Note that this does not work for the MPIUni Fortran symbols which are explicitly in the
219: PETSc libraries unless the flag MPIUNI_AVOID_MPI_NAMESPACE is set.
220: */
221: #define MPI_Abort Petsc_MPI_Abort
222: #define MPI_Attr_get Petsc_MPI_Attr_get
223: #define MPI_Keyval_free Petsc_MPI_Keyval_free
224: #define MPI_Attr_put Petsc_MPI_Attr_put
225: #define MPI_Attr_delete Petsc_MPI_Attr_delete
226: #define MPI_Keyval_create Petsc_MPI_Keyval_create
227: #define MPI_Comm_free Petsc_MPI_Comm_free
228: #define MPI_Comm_dup Petsc_MPI_Comm_dup
229: #define MPI_Comm_create Petsc_MPI_Comm_create
230: #define MPI_Init Petsc_MPI_Init
231: #define MPI_Finalize Petsc_MPI_Finalize
232: #define MPI_Initialized Petsc_MPI_Initialized
233: #define MPI_Finalized Petsc_MPI_Finalized
250: #define MPI_Aint MPIUNI_INTPTR
251: /*
252: Routines we have replace with macros that do nothing
253: Some return error codes others return success
254: */
256: #define MPI_Comm_f2c(comm) (MPI_Comm)(comm)
257: #define MPI_Comm_c2f(comm) (MPI_Fint)(comm)
259: #define MPI_Send(buf,count,datatype,dest,tag,comm) \
260: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
261: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
262: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
263: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
264: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
265: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
266: MPI_Abort(MPI_COMM_WORLD,0))
267: #define MPI_Recv(buf,count,datatype,source,tag,comm,status) \
268: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
269: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
270: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
271: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (source),\
272: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
273: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
274: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (status),\
275: MPI_Abort(MPI_COMM_WORLD,0))
276: #define MPI_Get_count(status, datatype,count) \
277: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (status),\
278: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
279: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
280: MPI_Abort(MPI_COMM_WORLD,0))
281: #define MPI_Bsend(buf,count,datatype,dest,tag,comm) \
282: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
283: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
284: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
285: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
286: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
287: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
288: MPI_Abort(MPI_COMM_WORLD,0))
289: #define MPI_Ssend(buf,count, datatype,dest,tag,comm) \
290: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
291: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
292: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
293: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
294: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
295: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
296: MPI_Abort(MPI_COMM_WORLD,0))
297: #define MPI_Rsend(buf,count, datatype,dest,tag,comm) \
298: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
299: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
300: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
301: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
302: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
303: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
304: MPI_Abort(MPI_COMM_WORLD,0))
305: #define MPI_Buffer_attach(buffer,size) \
306: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buffer),\
307: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (size),\
308: MPI_SUCCESS)
309: #define MPI_Buffer_detach(buffer,size)\
310: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buffer),\
311: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (size),\
312: MPI_SUCCESS)
313: #define MPI_Ibsend(buf,count, datatype,dest,tag,comm,request) \
314: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
315: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
316: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
317: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
318: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
319: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
320: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
321: MPI_Abort(MPI_COMM_WORLD,0))
322: #define MPI_Issend(buf,count, datatype,dest,tag,comm,request) \
323: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
324: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
325: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
326: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
327: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
328: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
329: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
330: MPI_Abort(MPI_COMM_WORLD,0))
331: #define MPI_Irsend(buf,count, datatype,dest,tag,comm,request) \
332: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
333: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
334: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
335: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
336: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
337: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
338: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
339: MPI_Abort(MPI_COMM_WORLD,0))
340: #define MPI_Irecv(buf,count, datatype,source,tag,comm,request) \
341: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
342: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
343: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
344: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (source),\
345: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
346: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
347: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
348: MPI_Abort(MPI_COMM_WORLD,0))
349: #define MPI_Isend(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_Abort(MPI_COMM_WORLD,0))
358: #define MPI_Wait(request,status) \
359: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
360: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (status),\
361: MPI_SUCCESS)
362: #define MPI_Test(request,flag,status) \
363: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
364: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (status),\
365: *(flag) = 0, \
366: MPI_SUCCESS)
367: #define MPI_Request_free(request) \
368: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
369: MPI_SUCCESS)
370: #define MPI_Waitany(a,b,c,d) \
371: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (a),\
372: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (b),\
373: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (c),\
374: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (d),(*c = 0), \
375: MPI_SUCCESS)
376: #define MPI_Testany(a,b,c,d,e) \
377: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (a),\
378: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (b),\
379: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (c),\
380: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (d),\
381: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (e),\
382: MPI_SUCCESS)
383: #define MPI_Waitall(count,array_of_requests,array_of_statuses) \
384: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
385: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (array_of_requests),\
386: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (array_of_statuses),\
387: MPI_SUCCESS)
388: #define MPI_Testall(count,array_of_requests,flag,array_of_statuses) \
389: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
390: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (array_of_requests),\
391: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (flag),\
392: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (array_of_statuses),\
393: MPI_SUCCESS)
394: #define MPI_Waitsome(incount,array_of_requests,outcount,\
395: array_of_indices,array_of_statuses) \
396: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (incount),\
397: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (array_of_requests),\
398: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (outcount),\
399: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (array_of_indices),\
400: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (array_of_statuses),\
401: MPI_SUCCESS)
402: #define MPI_Comm_group(comm,group) \
403: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
404: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (group),\
405: MPI_SUCCESS)
406: #define MPI_Group_incl(group,n,ranks,newgroup) \
407: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (group),\
408: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (n),\
409: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (ranks),\
410: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (newgroup),\
411: MPI_SUCCESS)
412: #define MPI_Testsome(incount,array_of_requests,outcount,\
413: array_of_indices,array_of_statuses) MPI_SUCCESS
414: #define MPI_Iprobe(source,tag,comm,flag,status) (*(flag)=0, MPI_SUCCESS)
415: #define MPI_Probe(source,tag,comm,status) MPI_SUCCESS
416: #define MPI_Cancel(request) (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),MPI_SUCCESS)
417: #define MPI_Test_cancelled(status,flag) (*(flag)=0,MPI_SUCCESS)
418: #define MPI_Send_init(buf,count, datatype,dest,tag,comm,request) \
419: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
420: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
421: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
422: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
423: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
424: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
425: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
426: MPI_SUCCESS)
427: #define MPI_Bsend_init(buf,count, datatype,dest,tag,comm,request) \
428: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
429: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
430: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
431: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
432: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
433: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
434: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
435: MPI_SUCCESS)
436: #define MPI_Ssend_init(buf,count, datatype,dest,tag,comm,request) \
437: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
438: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
439: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
440: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
441: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
442: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
443: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
444: MPI_SUCCESS)
445: #define MPI_Bsend_init(buf,count, datatype,dest,tag,comm,request) \
446: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
447: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
448: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
449: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
450: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
451: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
452: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
453: MPI_SUCCESS)
454: #define MPI_Rsend_init(buf,count, datatype,dest,tag,comm,request) \
455: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
456: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
457: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
458: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (dest),\
459: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
460: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
461: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
462: MPI_SUCCESS)
463: #define MPI_Recv_init(buf,count, datatype,source,tag,comm,request) \
464: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf),\
465: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
466: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
467: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (source),\
468: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (tag),\
469: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
470: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),\
471: MPI_SUCCESS)
472: #define MPI_Start(request) (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (request),MPI_SUCCESS)
473: #define MPI_Startall(count,array_of_requests) \
474: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
475: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (array_of_requests),\
476: MPI_SUCCESS)
477: #define MPI_Op_create(function,commute,op) \
478: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (function),\
479: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (commute),\
480: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (op),\
481: MPI_SUCCESS)
482: #define MPI_Op_free(op) \
483: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (op),\
484: MPI_SUCCESS)
485: /* Need to determine sizeof "sendtype" */
486: #define MPI_Sendrecv(sendbuf,sendcount, sendtype,\
487: dest,sendtag,recvbuf,recvcount,\
488: recvtype,source,recvtag,\
489: comm,status) \
490: MPIUNI_Memcpy(recvbuf,sendbuf,(sendcount) * MPI_sizeof(sendtype))
491: #define MPI_Sendrecv_replace(buf,count, datatype,dest,sendtag,\
492: source,recvtag,comm,status) MPI_SUCCESS
493: #define MPI_Type_contiguous(count, oldtype,newtype) \
494: (*(newtype) = (count)*(oldtype),MPI_SUCCESS)
495: #define MPI_Type_vector(count,blocklength,stride,oldtype, newtype) MPI_SUCCESS
496: #define MPI_Type_hvector(count,blocklength,stride,oldtype, newtype) MPI_SUCCESS
497: #define MPI_Type_indexed(count,array_of_blocklengths,\
498: array_of_displacements, oldtype,\
499: newtype) MPI_SUCCESS
500: #define MPI_Type_hindexed(count,array_of_blocklengths,\
501: array_of_displacements, oldtype,\
502: newtype) MPI_SUCCESS
503: #define MPI_Type_struct(count,array_of_blocklengths,\
504: array_of_displacements,\
505: array_of_types, newtype) MPI_SUCCESS
506: #define MPI_Address(location,address) \
507: (*(address) = (MPIUNI_INTPTR)(char *)(location),MPI_SUCCESS)
508: #define MPI_Type_extent(datatype,extent) *(extent) = datatype
509: #define MPI_Type_size(datatype,size) *(size) = datatype
510: #define MPI_Type_lb(datatype,displacement) \
511: MPI_Abort(MPI_COMM_WORLD,0)
512: #define MPI_Type_ub(datatype,displacement) \
513: MPI_Abort(MPI_COMM_WORLD,0)
514: #define MPI_Type_commit(datatype) (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
515: MPI_SUCCESS)
516: #define MPI_Type_free(datatype) MPI_SUCCESS
517: #define MPI_Get_elements(status, datatype,count) \
518: MPI_Abort(MPI_COMM_WORLD,0)
519: #define MPI_Pack(inbuf,incount, datatype,outbuf,\
520: outsize,position, comm) \
521: MPI_Abort(MPI_COMM_WORLD,0)
522: #define MPI_Unpack(inbuf,insize,position,outbuf,\
523: outcount, datatype,comm) \
524: MPI_Abort(MPI_COMM_WORLD,0)
525: #define MPI_Pack_size(incount, datatype,comm,size) \
526: MPI_Abort(MPI_COMM_WORLD,0)
527: #define MPI_Barrier(comm) \
528: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
529: MPI_SUCCESS)
530: #define MPI_Bcast(buffer,count,datatype,root,comm) \
531: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buffer),\
532: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count),\
533: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype),\
534: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
535: MPI_SUCCESS)
536: #define MPI_Gather(sendbuf,sendcount, sendtype,\
537: recvbuf,recvcount, recvtype,\
538: root,comm) \
539: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvcount),\
540: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (root),\
541: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvtype),\
542: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
543: MPIUNI_Memcpy(recvbuf,sendbuf,(sendcount)*MPI_sizeof(sendtype)),\
544: MPI_SUCCESS)
545: #define MPI_Gatherv(sendbuf,sendcount, sendtype,\
546: recvbuf,recvcounts,displs,\
547: recvtype,root,comm) \
548: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvcounts),\
549: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (displs),\
550: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvtype),\
551: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (root),\
552: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
553: MPIUNI_Memcpy(recvbuf,sendbuf,(sendcount)*MPI_sizeof(sendtype)),\
554: MPI_SUCCESS)
555: #define MPI_Scatter(sendbuf,sendcount, sendtype,\
556: recvbuf,recvcount, recvtype,\
557: root,comm) \
558: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (sendbuf),\
559: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (sendcount),\
560: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (sendtype),\
561: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvbuf),\
562: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvcount),\
563: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvtype),\
564: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (root),\
565: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),MPI_Abort(MPI_COMM_WORLD,0))
566: #define MPI_Scatterv(sendbuf,sendcounts,displs,\
567: sendtype, recvbuf,recvcount,\
568: recvtype,root,comm) \
569: (MPIUNI_Memcpy(recvbuf,sendbuf,(recvcount)*MPI_sizeof(recvtype)),\
570: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (displs),\
571: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (sendtype),\
572: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (sendcounts),\
573: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (root),\
574: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
575: MPI_SUCCESS)
576: #define MPI_Allgather(sendbuf,sendcount, sendtype,\
577: recvbuf,recvcount, recvtype,comm) \
578: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvcount),\
579: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvtype),\
580: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
581: MPIUNI_Memcpy(recvbuf,sendbuf,(sendcount)*MPI_sizeof(sendtype)),\
582: MPI_SUCCESS)
583: #define MPI_Allgatherv(sendbuf,sendcount, sendtype,\
584: recvbuf,recvcounts,displs,recvtype,comm) \
585: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvcounts),\
586: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (displs),\
587: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvtype),\
588: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
589: (sendbuf != MPI_IN_PLACE) ? MPIUNI_Memcpy((recvbuf),(sendbuf),(sendcount)*MPI_sizeof(sendtype)) : 0, \
590: MPI_SUCCESS)
591: #define MPI_Alltoall(sendbuf,sendcount, sendtype,\
592: recvbuf,recvcount, recvtype,comm) \
593: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvcount),\
594: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (recvtype),\
595: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
596: MPIUNI_Memcpy(recvbuf,sendbuf,(sendcount)*MPI_sizeof(sendtype)),\
597: MPI_SUCCESS)
598: #define MPI_Alltoallv(sendbuf,sendcounts,sdispls,\
599: sendtype, recvbuf,recvcounts,\
600: rdispls, recvtype,comm) MPI_Abort(MPI_COMM_WORLD,0)
601: #define MPI_Alltoallw(sendbuf,sendcounts,sdispls,\
602: sendtypes, recvbuf,recvcounts,\
603: rdispls, recvtypes,comm) MPI_Abort(MPI_COMM_WORLD,0)
604: #define MPI_Reduce(sendbuf, recvbuf,count,\
605: datatype,op,root,comm) \
606: (MPIUNI_Memcpy(recvbuf,sendbuf,(count)*MPI_sizeof(datatype)),\
607: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),MPI_SUCCESS)
608: #define MPI_Allreduce(sendbuf, recvbuf,count,datatype,op,comm) \
609: ((sendbuf != MPI_IN_PLACE) ? MPIUNI_Memcpy(recvbuf,sendbuf,(count)*MPI_sizeof(datatype)) : 0, \
610: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),MPI_SUCCESS)
611: #define MPI_Scan(sendbuf, recvbuf,count,datatype,op,comm) \
612: (MPIUNI_Memcpy(recvbuf,sendbuf,(count)*MPI_sizeof(datatype)),\
613: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),MPI_SUCCESS)
614: #define MPI_Exscan(sendbuf, recvbuf,count,datatype,op,comm) MPI_SUCCESS
615: #define MPI_Reduce_scatter(sendbuf, recvbuf,recvcounts,\
616: datatype,op,comm) \
617: MPI_Abort(MPI_COMM_WORLD,0)
618: #define MPI_Group_size(group,size) (*(size)=1,MPI_SUCCESS)
619: #define MPI_Group_rank(group,rank) (*(rank)=0,MPI_SUCCESS)
620: #define MPI_Group_translate_ranks (group1,n,ranks1,\
621: group2,ranks2) MPI_Abort(MPI_COMM_WORLD,0)
622: #define MPI_Group_compare(group1,group2,result) \
623: (*(result)=1,MPI_SUCCESS)
624: #define MPI_Group_union(group1,group2,newgroup) MPI_SUCCESS
625: #define MPI_Group_intersection(group1,group2,newgroup) MPI_SUCCESS
626: #define MPI_Group_difference(group1,group2,newgroup) MPI_SUCCESS
627: #define MPI_Group_excl(group,n,ranks,newgroup) MPI_SUCCESS
628: #define MPI_Group_range_incl(group,n,ranges,newgroup) MPI_SUCCESS
629: #define MPI_Group_range_excl(group,n,ranges,newgroup) MPI_SUCCESS
630: #define MPI_Group_free(group) \
631: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (group),\
632: MPI_SUCCESS)
633: #define MPI_Comm_size(comm,size) \
634: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
635: *(size)=1,\
636: MPI_SUCCESS)
637: #define MPI_Comm_rank(comm,rank) \
638: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
639: *(rank)=0,\
640: MPI_SUCCESS)
641: #define MPI_Comm_compare(comm1,comm2,result) \
642: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm1),\
643: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm2),\
644: *(result)=MPI_IDENT,\
645: MPI_SUCCESS)
646: #define MPI_Comm_split(comm,color,key,newcomm) MPI_Comm_dup(comm,newcomm)
647: #define MPI_Comm_test_inter(comm,flag) (*(flag)=1,MPI_SUCCESS)
648: #define MPI_Comm_remote_size(comm,size) (*(size)=1,MPI_SUCCESS)
649: #define MPI_Comm_remote_group(comm,group) MPI_SUCCESS
650: #define MPI_Intercomm_create(local_comm,local_leader,peer_comm,\
651: remote_leader,tag,newintercomm) MPI_SUCCESS
652: #define MPI_Intercomm_merge(intercomm,high,newintracomm) MPI_SUCCESS
654: #define MPI_Topo_test(comm,status) MPI_SUCCESS
655: #define MPI_Cart_create(comm_old,ndims,dims,periods,\
656: reorder,comm_cart) MPI_SUCCESS
657: #define MPI_Dims_create(nnodes,ndims,dims) MPI_Abort(MPI_COMM_WORLD,0)
658: #define MPI_Graph_create(comm,a,b,c,d,e) MPI_SUCCESS
659: #define MPI_Graphdims_Get(comm,nnodes,nedges) MPI_Abort(MPI_COMM_WORLD,0)
660: #define MPI_Graph_get(comm,a,b,c,d) MPI_Abort(MPI_COMM_WORLD,0)
661: #define MPI_Cartdim_get(comm,ndims) MPI_Abort(MPI_COMM_WORLD,0)
662: #define MPI_Cart_get(comm,maxdims,dims,periods,coords) \
663: MPI_Abort(MPI_COMM_WORLD,0)
664: #define MPI_Cart_rank(comm,coords,rank) MPI_Abort(MPI_COMM_WORLD,0)
665: #define MPI_Cart_coords(comm,rank,maxdims,coords) \
666: MPI_Abort(MPI_COMM_WORLD,0)
667: #define MPI_Graph_neighbors_count(comm,rank,nneighbors) \
668: MPI_Abort(MPI_COMM_WORLD,0)
669: #define MPI_Graph_neighbors(comm,rank,maxneighbors,neighbors) \
670: MPI_Abort(MPI_COMM_WORLD,0)
671: #define MPI_Cart_shift(comm,direction,disp,rank_source,rank_dest) \
672: MPI_Abort(MPI_COMM_WORLD,0)
673: #define MPI_Cart_sub(comm,remain_dims,newcomm) MPI_Abort(MPI_COMM_WORLD,0)
674: #define MPI_Cart_map(comm,ndims,dims,periods,newrank) MPI_Abort(MPI_COMM_WORLD,0)
675: #define MPI_Graph_map(comm,a,b,c,d) MPI_Abort(MPI_COMM_WORLD,0)
676: #define MPI_Get_processor_name(name,result_len) \
677: (MPIUNI_Memcpy(name,"localhost",9*sizeof(char)),name[10] = 0,*(result_len) = 10)
678: #define MPI_Errhandler_create(function,errhandler) (*(errhandler) = (MPI_Errhandler) 0, MPI_SUCCESS)
679: #define MPI_Errhandler_set(comm,errhandler) \
680: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm),\
681: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (errhandler),\
682: MPI_SUCCESS)
683: #define MPI_Errhandler_get(comm,errhandler) MPI_SUCCESS
684: #define MPI_Errhandler_free(errhandler) MPI_SUCCESS
685: #define MPI_Error_string(errorcode,string,result_len) MPI_SUCCESS
686: #define MPI_Error_class(errorcode,errorclass) MPI_SUCCESS
687: #define MPI_Wtick() 1.0
688: #define MPI_Wtime() 0.0
689: #define MPI_Pcontrol(level) MPI_SUCCESS
691: #define MPI_NULL_COPY_FN 0
692: #define MPI_NULL_DELETE_FN 0
694: /* MPI-IO additions */
696: #define MPI_File_open(comm,filename,amode,info,mpi_fh) \
697: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (comm), \
698: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (filename), \
699: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (amode), \
700: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (info), \
701: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (mpi_fh), \
702: MPI_Abort(MPI_COMM_WORLD,0))
704: #define MPI_File_close(mpi_fh) \
705: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (mpi_fh), \
706: MPI_Abort(MPI_COMM_WORLD,0))
708: #define MPI_File_set_view(mpi_fh,disp,etype,filetype,datarep,info) \
709: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (mpi_fh), \
710: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (disp), \
711: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (etype), \
712: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (filetype), \
713: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datarep), \
714: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (info), \
715: MPI_Abort(MPI_COMM_WORLD,0))
717: #define MPI_Type_get_extent(datatype,lb,extent) \
718: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype), \
719: *(lb) = 0, *(extent) = datatype,0)
721: #define MPI_File_write_all(mpi_fh,buf,count,datatype,status) \
722: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (mpi_fh), \
723: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf), \
724: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count), \
725: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype), \
726: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (status), \
727: MPI_Abort(MPI_COMM_WORLD,0))
729: #define MPI_File_read_all(mpi_fh,buf,count,datatype,status) \
730: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (mpi_fh), \
731: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (buf), \
732: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (count), \
733: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (datatype), \
734: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (status), \
735: MPI_Abort(MPI_COMM_WORLD,0))
737: /* called from PetscInitialize() - so return success */
738: #define MPI_Register_datarep(name,read_conv_fn,write_conv_fn,extent_fn,state) \
739: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (name), \
740: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (read_conv_fn), \
741: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (write_conv_fn), \
742: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (extent_fn), \
743: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (state), \
744: MPI_SUCCESS)
746: #define MPI_Type_create_subarray(ndims,array_of_sizes,array_of_subsizes,array_of_starts,order,oldtype,newtype) \
747: (MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (ndims), \
748: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (array_of_sizes), \
749: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (array_of_subsizes), \
750: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (array_of_starts), \
751: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (order), \
752: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (oldtype), \
753: MPIUNI_TMP = (void*)(MPIUNI_INTPTR) (newtype), \
754: MPI_Abort(MPI_COMM_WORLD,0))
756: #if defined(__cplusplus)
757: }
758: #endif
759: #endif