mpi.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. #ifndef _MPI_H_
  2. #define _MPI_H_
  3. typedef int MPI_Comm;
  4. typedef int MPI_Request;
  5. #define MPI_COMM_WORLD (1)
  6. #define MPI_COMM_NULL (0) /* handle 0 maps to NULL */
  7. typedef int MPI_Group;
  8. /* MPI_GROUP_EMPTY and MPI_GROUP_NULL must not conflict with MPI_GROUP_ONE */
  9. #define MPI_GROUP_EMPTY (-1)
  10. #define MPI_GROUP_NULL (0)
  11. /*
  12. * Return codes
  13. * On error, mpi-serial aborts so the values don't really matter
  14. * as long as they are different than MPI_SUCCESS
  15. *
  16. */
  17. #define MPI_SUCCESS (0)
  18. #define MPI_ERR_BUFFER (-1)
  19. #define MPI_ERR_COUNT (-1)
  20. #define MPI_ERR_TYPE (-1)
  21. #define MPI_ERR_TAG (-1)
  22. #define MPI_ERR_COMM (-1)
  23. #define MPI_ERR_RANK (-1)
  24. #define MPI_ERR_REQUEST (-1)
  25. #define MPI_ERR_ROOT (-1)
  26. #define MPI_ERR_GROUP (-1)
  27. #define MPI_ERR_OP (-1)
  28. #define MPI_ERR_TOPOLOGY (-1)
  29. #define MPI_ERR_DIMS (-1)
  30. #define MPI_ERR_ARG (-1)
  31. #define MPI_ERR_UNKNOWN (-1)
  32. #define MPI_ERR_TRUNCATE (-1)
  33. #define MPI_ERR_OTHER (-1)
  34. #define MPI_ERR_INTERN (-1)
  35. #define MPI_PENDING (-1)
  36. #define MPI_ERR_IN_STATUS (-1)
  37. #define MPI_ERR_LASTCODE (-1)
  38. /*
  39. * MPI_UNDEFINED
  40. *
  41. * Uses:
  42. * value for "color" in e.g. comm_split
  43. * value for rank in Group_translate_ranks
  44. *
  45. */
  46. #define MPI_UNDEFINED (-1)
  47. /*
  48. * Data types etc.
  49. */
  50. typedef unsigned long int MPI_Aint;
  51. #define MPI_BOTTOM (0)
  52. typedef int MPI_Datatype;
  53. /* The type's value is its size in bytes */
  54. #define MPI_DATATYPE_NULL (0)
  55. #define MPI_BYTE (sizeof(char))
  56. #define MPI_CHAR (sizeof(char))
  57. #define MPI_UNSIGNED_CHAR (sizeof(unsigned char))
  58. #define MPI_SHORT (sizeof(short))
  59. #define MPI_UNSIGNED_SHORT (sizeof(unsigned short))
  60. #define MPI_INT (sizeof(int))
  61. #define MPI_UNSIGNED (sizeof(unsigned))
  62. #define MPI_LONG (sizeof(long))
  63. #define MPI_UNSIGNED_LONG (sizeof(unsigned long))
  64. #define MPI_FLOAT (sizeof(float))
  65. #define MPI_DOUBLE (sizeof(double))
  66. #define MPI_LONG_DOUBLE (sizeof(long double))
  67. #define MPI_PACKED (sizeof(char))
  68. /* types for MINLOC and MAXLOC */
  69. #define MPI_FLOAT_INT (sizeof(struct{float a; int b;}))
  70. #define MPI_DOUBLE_INT (sizeof(struct{double a; int b;}))
  71. #define MPI_LONG_INT (sizeof(struct{long a; int b;}))
  72. #define MPI_2INT (sizeof(struct{int a; int b;}))
  73. #define MPI_SHORT_INT (sizeof (struct{short a; int b;}))
  74. #define MPI_LONG_DOUBLE_INT (sizeof (struct{long double a; int b;}))
  75. /* size-specific types */
  76. #define MPI_INTEGER1 (1)
  77. #define MPI_INTEGER2 (2)
  78. #define MPI_INTEGER4 (4)
  79. #define MPI_INTEGER8 (8)
  80. #define MPI_INTEGER16 (16)
  81. #define MPI_REAL4 (4)
  82. #define MPI_REAL8 (8)
  83. #define MPI_REAL16 (16)
  84. /*
  85. * Fortran int size
  86. *
  87. */
  88. typedef int MPI_Fint;
  89. #define MPI_ANY_TAG (-1)
  90. #define MPI_ANY_SOURCE (-1)
  91. #define MPI_PROC_NULL (-2)
  92. #define MPI_ROOT (-3)
  93. #define MPI_REQUEST_NULL (0)
  94. #define MPI_MAX_ERROR_STRING (128)
  95. #define MPI_MAX_PROCESSOR_NAME (128)
  96. /*
  97. * MPI_Status
  98. *
  99. * definition must be compatible with the mpif.h values for
  100. * MPI_STATUS_SIZE, MPI_SOURCE, MPI_TAG, and MPI_ERROR.
  101. *
  102. * Note: The type used for MPI_Status_int must be chosen to match
  103. * Fortran INTEGER.
  104. *
  105. */
  106. typedef int MPI_Status_int;
  107. typedef struct /* Fortran: INTEGER status(MPI_STATUS_SIZE) */
  108. {
  109. MPI_Status_int MPI_SOURCE; /* Fortran: status(MPI_SOURCE) */
  110. MPI_Status_int MPI_TAG; /* Fortran: status(MPI_TAG) */
  111. MPI_Status_int MPI_ERROR; /* Fortran: status(MPI_ERROR) */
  112. } MPI_Status;
  113. /*
  114. * Collective operations
  115. */
  116. typedef int MPI_Op;
  117. typedef void MPI_User_function( void *invec, void *inoutvec, int *len,
  118. MPI_Datatype *datatype);
  119. #define MPI_OP_NULL (0)
  120. #define MPI_MAX (0)
  121. #define MPI_MIN (0)
  122. #define MPI_SUM (0)
  123. #define MPI_PROD (0)
  124. #define MPI_LAND (0)
  125. #define MPI_BAND (0)
  126. #define MPI_LOR (0)
  127. #define MPI_BOR (0)
  128. #define MPI_LXOR (0)
  129. #define MPI_BXOR (0)
  130. #define MPI_MAXLOC (0)
  131. #define MPI_MINLOC (0)
  132. /*
  133. * These are provided for Fortran...
  134. */
  135. #define MPI_INTEGER MPI_INT
  136. #define MPI_REAL MPI_FLOAT
  137. #define MPI_DOUBLE_PRECISION MPI_DOUBLE
  138. #define MPI_STATUS_SIZE (sizeof(MPI_Status) / sizeof(int))
  139. /**********************************************************
  140. *
  141. * Note: if you need to regenerate the prototypes below,
  142. * you can use 'protify.awk' and paste the output here.
  143. *
  144. */
  145. extern int MPI_Barrier(MPI_Comm comm );
  146. extern int MPI_Bcast(void* buffer, int count, MPI_Datatype datatype,
  147. int root, MPI_Comm comm );
  148. extern int MPI_Gather(void* sendbuf, int sendcount, MPI_Datatype sendtype,
  149. void* recvbuf, int recvcount, MPI_Datatype recvtype,
  150. int root, MPI_Comm comm);
  151. extern int MPI_Gatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype,
  152. void* recvbuf, int *recvcounts, int *displs,
  153. MPI_Datatype recvtype, int root, MPI_Comm comm);
  154. extern int MPI_Allgather(void* sendbuf, int sendcount, MPI_Datatype sendtype,
  155. void* recvbuf, int recvcount, MPI_Datatype recvtype,
  156. MPI_Comm comm);
  157. extern int MPI_Allgatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype,
  158. void* recvbuf, int *recvcounts, int *displs,
  159. MPI_Datatype recvtype, MPI_Comm comm);
  160. extern int MPI_Scatter( void* sendbuf, int sendcount, MPI_Datatype sendtype,
  161. void* recvbuf, int recvcount, MPI_Datatype recvtype,
  162. int root, MPI_Comm comm);
  163. extern int MPI_Scatterv(void* sendbuf, int *sendcounts, int *displs,
  164. MPI_Datatype sendtype, void* recvbuf, int recvcount,
  165. MPI_Datatype recvtype, int root, MPI_Comm comm);
  166. extern int MPI_Reduce(void* sendbuf, void* recvbuf, int count,
  167. MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm);
  168. extern int MPI_Allreduce(void* sendbuf, void* recvbuf, int count,
  169. MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
  170. extern int MPI_Scan( void* sendbuf, void* recvbuf, int count,
  171. MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
  172. extern int MPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
  173. void *recvbuf, int recvcount, MPI_Datatype recvtype,
  174. MPI_Comm comm);
  175. extern int MPI_Alltoallv(void *sendbuf, int *sendcounts,
  176. int *sdispls, MPI_Datatype sendtype,
  177. void *recvbuf, int *recvcounts,
  178. int *rdispls, MPI_Datatype recvtype,
  179. MPI_Comm comm) ;
  180. extern int MPI_Op_create(MPI_User_function *function, int commute,
  181. MPI_Op *op);
  182. extern MPI_Op MPI_Op_f2c(MPI_Fint op);
  183. extern MPI_Fint MPI_Op_c2f(MPI_Op op);
  184. extern MPI_Comm mpi_comm_new(void);
  185. extern int MPI_Comm_free(MPI_Comm *comm);
  186. extern int MPI_Comm_size(MPI_Comm comm, int *size);
  187. extern int MPI_Comm_rank(MPI_Comm comm, int *rank);
  188. extern int MPI_Comm_dup(MPI_Comm comm, MPI_Comm *newcomm);
  189. extern int MPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm *newcomm);
  190. extern int MPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm *newcomm);
  191. extern int MPI_Comm_group(MPI_Comm comm, MPI_Group *group);
  192. extern MPI_Comm MPI_Comm_f2c(MPI_Fint comm);
  193. extern MPI_Fint MPI_Comm_c2f(MPI_Comm comm);
  194. extern int MPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group *newgroup);
  195. extern int MPI_Group_range_incl(MPI_Group group, int n, int ranges[][3],
  196. MPI_Group *newgroup);
  197. extern int MPI_Group_union(MPI_Group group1, MPI_Group group2, MPI_Group *newgroup);
  198. extern int MPI_Group_intersection(MPI_Group group1, MPI_Group group2,
  199. MPI_Group *newgroup);
  200. extern int MPI_Group_difference(MPI_Group group1, MPI_Group group2,
  201. MPI_Group *newgroup);
  202. extern int MPI_Group_free(MPI_Group *group);
  203. extern int MPI_Group_translate_ranks(MPI_Group group1, int n, int *ranks1,
  204. MPI_Group group2, int *ranks2);
  205. extern MPI_Group MPI_Group_f2c(MPI_Fint group);
  206. extern MPI_Fint MPI_Group_c2f(MPI_Group group);
  207. extern int MPI_Init(int *argc, char **argv[]) ;
  208. extern int MPI_Finalize(void);
  209. extern int MPI_Abort(MPI_Comm comm, int errorcode);
  210. extern int MPI_Error_string(int errorcode, char *string, int *resultlen);
  211. extern int MPI_Get_processor_name(char *name, int *resultlen);
  212. extern int MPI_Initialized(int *flag);
  213. extern int MPI_Pack( void *inbuf, int incount, MPI_Datatype datatype,
  214. void *outbuf, int outsize, int *position, MPI_Comm comm);
  215. extern int MPI_Unpack( void *inbuf, int insize, int *position,
  216. void *outbuf, int outcount, MPI_Datatype datatype,
  217. MPI_Comm comm );
  218. extern int MPI_Irecv(void *buf, int count, MPI_Datatype datatype,
  219. int source, int tag, MPI_Comm comm, MPI_Request *request);
  220. extern int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source,
  221. int tag, MPI_Comm comm, MPI_Status *status);
  222. extern int MPI_Test(MPI_Request *request, int *flag, MPI_Status *status);
  223. extern int MPI_Wait(MPI_Request *request, MPI_Status *status);
  224. extern int MPI_Waitany(int count, MPI_Request *array_of_requests,
  225. int *index, MPI_Status *status);
  226. extern int MPI_Waitall(int count, MPI_Request *array_of_requests,
  227. MPI_Status *array_of_statuses);
  228. extern MPI_Request MPI_Request_f2c(MPI_Fint request);
  229. extern MPI_Fint MPI_Request_c2f(MPI_Request request);
  230. extern int MPI_Isend(void *buf, int count, MPI_Datatype datatype,
  231. int dest, int tag, MPI_Comm comm, MPI_Request *request) ;
  232. extern int MPI_Send(void* buf, int count, MPI_Datatype datatype,
  233. int dest, int tag, MPI_Comm comm);
  234. extern int MPI_Ssend(void* buf, int count, MPI_Datatype datatype,
  235. int dest, int tag, MPI_Comm comm);
  236. extern int MPI_Rsend(void* buf, int count, MPI_Datatype datatype,
  237. int dest, int tag, MPI_Comm comm);
  238. extern int MPI_Irsend(void *buf, int count, MPI_Datatype datatype,
  239. int dest, int tag, MPI_Comm comm, MPI_Request *request) ;
  240. extern int MPI_Sendrecv(void* sendbuf, int sendcount, MPI_Datatype sendtype,
  241. int dest, int sendtag,
  242. void *recvbuf, int recvcount, MPI_Datatype recvtype,
  243. int source, int recvtag,
  244. MPI_Comm comm, MPI_Status *status);
  245. extern double MPI_Wtime(void);;
  246. extern double MPI_Wtime(void);
  247. #endif