mpi.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #ifndef _MPI_STUB_H_
  2. #define _MPI_STUB_H_
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. /* Communicators */
  9. typedef int MPI_Comm;
  10. #define MPI_COMM_WORLD ((MPI_Comm)91)
  11. #define MPI_COMM_SELF ((MPI_Comm)92)
  12. #define MPI_COMM_NULL ((MPI_Comm)0)
  13. /* Define MPI_Datatype */
  14. typedef size_t MPI_Datatype;
  15. /* Define native MPI datatypes. */
  16. #define DECLARE_NATIVE_MPI_DATATYPE(MPITYPE, CTYPE) \
  17. const MPI_Datatype MPITYPE=sizeof(CTYPE);
  18. DECLARE_NATIVE_MPI_DATATYPE(MPI_BYTE ,char);
  19. DECLARE_NATIVE_MPI_DATATYPE(MPI_CHAR ,char);
  20. DECLARE_NATIVE_MPI_DATATYPE(MPI_SHORT ,signed short int);
  21. DECLARE_NATIVE_MPI_DATATYPE(MPI_INT ,signed int);
  22. DECLARE_NATIVE_MPI_DATATYPE(MPI_LONG ,signed long int);
  23. DECLARE_NATIVE_MPI_DATATYPE(MPI_LONG_LONG_INT ,signed long long int);
  24. DECLARE_NATIVE_MPI_DATATYPE(MPI_LONG_LONG ,signed long long int);
  25. DECLARE_NATIVE_MPI_DATATYPE(MPI_SIGNED_CHAR ,signed char);
  26. DECLARE_NATIVE_MPI_DATATYPE(MPI_UNSIGNED_CHAR ,unsigned char);
  27. DECLARE_NATIVE_MPI_DATATYPE(MPI_UNSIGNED_SHORT ,unsigned short int);
  28. DECLARE_NATIVE_MPI_DATATYPE(MPI_UNSIGNED ,unsigned int);
  29. DECLARE_NATIVE_MPI_DATATYPE(MPI_UNSIGNED_LONG ,unsigned long int);
  30. DECLARE_NATIVE_MPI_DATATYPE(MPI_UNSIGNED_LONG_LONG,unsigned long long int);
  31. DECLARE_NATIVE_MPI_DATATYPE(MPI_FLOAT ,float);
  32. DECLARE_NATIVE_MPI_DATATYPE(MPI_DOUBLE ,double);
  33. DECLARE_NATIVE_MPI_DATATYPE(MPI_LONG_DOUBLE ,long double);
  34. DECLARE_NATIVE_MPI_DATATYPE(MPI_WCHAR ,wchar_t);
  35. /* Define MPI_Op */
  36. typedef int MPI_Op;
  37. #define MPI_SUM ((MPI_Op)0)
  38. #define MPI_MIN ((MPI_Op)0)
  39. #define MPI_MAX ((MPI_Op)0)
  40. typedef void (*MPI_User_function)(void*, void*, int*, MPI_Datatype*);
  41. int MPI_Type_contiguous(int count, MPI_Datatype oldtype, MPI_Datatype *newtype);
  42. int MPI_Op_create(MPI_User_function *user_fn, int commute, MPI_Op *op);
  43. int MPI_Type_commit(MPI_Datatype *datatype);
  44. /* Basic MPI functions */
  45. int MPI_Init( int *argc, char ***argv);
  46. int MPI_Finalize(void);
  47. int MPI_Comm_rank( MPI_Comm comm, int *rank );
  48. int MPI_Comm_size( MPI_Comm comm, int *size );
  49. /* MPI send/recv functions */
  50. typedef int MPI_Request;
  51. typedef int MPI_Status;
  52. int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag,
  53. MPI_Comm comm, MPI_Status *status);
  54. int MPI_Irecv(void *buf, int count, MPI_Datatype datatype, int source,
  55. int tag, MPI_Comm comm, MPI_Request *request);
  56. int MPI_Send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag,
  57. MPI_Comm comm);
  58. int MPI_Issend(const void *buf, int count, MPI_Datatype datatype, int dest, int tag,
  59. MPI_Comm comm, MPI_Request *request);
  60. int MPI_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
  61. int dest, int sendtag,
  62. void *recvbuf, int recvcount, MPI_Datatype recvtype,
  63. int source, int recvtag,
  64. MPI_Comm comm, MPI_Status *status);
  65. /* MPI collectives */
  66. int MPI_Barrier(MPI_Comm comm);
  67. int MPI_Scan(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
  68. MPI_Op op, MPI_Comm comm);
  69. int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype, int root,
  70. MPI_Comm comm);
  71. int MPI_Reduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
  72. MPI_Op op, int root, MPI_Comm comm);
  73. int MPI_Allreduce(const void *sendbuf, void *recvbuf, int count,
  74. MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
  75. int MPI_Allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
  76. void *recvbuf, int recvcount, MPI_Datatype recvtype,
  77. MPI_Comm comm);
  78. int MPI_Allgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
  79. void *recvbuf, const int *recvcounts, const int *displs,
  80. MPI_Datatype recvtype, MPI_Comm comm);
  81. int MPI_Alltoall(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
  82. void *recvbuf, int recvcount, MPI_Datatype recvtype,
  83. MPI_Comm comm);
  84. /* Miscellaneous MPI functions */
  85. int MPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm *newcomm);
  86. int MPI_Comm_free(MPI_Comm *comm);
  87. int MPI_Comm_dup(MPI_Comm comm, MPI_Comm *newcomm);
  88. int MPI_Wait(MPI_Request *request, MPI_Status *status);
  89. int MPI_Waitall(int count, MPI_Request array_of_requests[],
  90. MPI_Status array_of_statuses[]);
  91. #ifdef __cplusplus
  92. }
  93. #endif
  94. #endif //_MPI_STUB_H_