X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e3ff3ecad20b9ea7acb4aa9176059a65f0e5e4cf..dff9e15c44ab6340d27215957c56fa72fad246a2:/include/smpi/smpi.h diff --git a/include/smpi/smpi.h b/include/smpi/smpi.h index fe73d2337c..67a740ef68 100644 --- a/include/smpi/smpi.h +++ b/include/smpi/smpi.h @@ -1,13 +1,16 @@ #ifndef SMPI_H #define SMPI_H +#include #include +#include #include +SG_BEGIN_DECL() #define SMPI_RAND_SEED 5 - #define MPI_ANY_SOURCE -1 - +#define MPI_ANY_TAG -1 +#define MPI_UNDEFINED -1 // errorcodes #define MPI_SUCCESS 0 #define MPI_ERR_COMM 1 @@ -18,52 +21,49 @@ #define MPI_ERR_COUNT 6 #define MPI_ERR_RANK 7 #define MPI_ERR_TAG 8 - // MPI_Comm -typedef struct smpi_mpi_communicator_t *smpi_mpi_communicator_t; -typedef smpi_mpi_communicator_t MPI_Comm; - -// MPI_Status -struct smpi_mpi_status_t { - int MPI_SOURCE; -}; -typedef struct smpi_mpi_status_t smpi_mpi_status_t; -typedef smpi_mpi_status_t MPI_Status; + typedef struct smpi_mpi_communicator_t *smpi_mpi_communicator_t; + typedef smpi_mpi_communicator_t MPI_Comm; // MPI_Datatype -typedef struct smpi_mpi_datatype_t { - size_t size; -} s_smpi_mpi_datatype_t; -typedef struct smpi_mpi_datatype_t *smpi_mpi_datatype_t; -typedef smpi_mpi_datatype_t MPI_Datatype; + typedef struct smpi_mpi_datatype_t *smpi_mpi_datatype_t; + typedef smpi_mpi_datatype_t MPI_Datatype; // MPI_Request -typedef struct smpi_mpi_request_t *smpi_mpi_request_t; -typedef smpi_mpi_request_t MPI_Request; + typedef struct smpi_mpi_request_t *smpi_mpi_request_t; + typedef smpi_mpi_request_t MPI_Request; // MPI_Op -typedef struct smpi_mpi_op_t { - void (*func)(void *x, void *y, void *z); -} s_smpi_mpi_op_t; -typedef struct smpi_mpi_op_t *smpi_mpi_op_t; -typedef smpi_mpi_op_t MPI_Op; + typedef struct smpi_mpi_op_t *smpi_mpi_op_t; + typedef smpi_mpi_op_t MPI_Op; + +// MPI_Status + struct smpi_mpi_status_t { + int MPI_SOURCE; + int MPI_TAG; + int MPI_ERROR; + }; + typedef struct smpi_mpi_status_t smpi_mpi_status_t; + typedef smpi_mpi_status_t MPI_Status; // global SMPI data structure -typedef struct SMPI_MPI_Global { + typedef struct smpi_mpi_global_t { - smpi_mpi_communicator_t mpi_comm_world; + smpi_mpi_communicator_t mpi_comm_world; - smpi_mpi_datatype_t mpi_byte; - smpi_mpi_datatype_t mpi_int; - smpi_mpi_datatype_t mpi_double; + smpi_mpi_datatype_t mpi_byte; + smpi_mpi_datatype_t mpi_int; + smpi_mpi_datatype_t mpi_double; - smpi_mpi_op_t mpi_land; - smpi_mpi_op_t mpi_sum; + smpi_mpi_op_t mpi_land; + smpi_mpi_op_t mpi_sum; -} s_SMPI_MPI_Global_t, *SMPI_MPI_Global_t; -extern SMPI_MPI_Global_t smpi_mpi_global; + } s_smpi_mpi_global_t; + typedef struct smpi_mpi_global_t *smpi_mpi_global_t; + extern smpi_mpi_global_t smpi_mpi_global; #define MPI_COMM_WORLD (smpi_mpi_global->mpi_comm_world) +#define MPI_COMM_NULL NULL #define MPI_STATUS_IGNORE NULL @@ -74,23 +74,58 @@ extern SMPI_MPI_Global_t smpi_mpi_global; #define MPI_LAND (smpi_mpi_global->mpi_land) #define MPI_SUM (smpi_mpi_glboal->mpi_sum) -// MPI Functions -int MPI_Init(int *argc, char ***argv); -int MPI_Finalize(void); -int MPI_Abort(MPI_Comm comm, int errorcode); -int MPI_Comm_size(MPI_Comm comm, int *size); -int MPI_Comm_rank(MPI_Comm comm, int *rank); -int MPI_Type_size(MPI_Datatype datatype, size_t *size); -int MPI_Barrier(MPI_Comm comm); -int MPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Request *request); -int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status *status); -int MPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request *request); -int MPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm); +// MPI macros +#define MPI_Init(a, b) SMPI_MPI_Init(a, b) +#define MPI_Finalize() SMPI_MPI_Finalize() +#define MPI_Abort(a, b) SMPI_MPI_Abort(a, b) +#define MPI_Comm_size(a, b) SMPI_MPI_Comm_size(a, b) +#define MPI_Comm_rank(a, b) SMPI_MPI_Comm_rank(a, b) +#define MPI_Type_size(a, b) SMPI_MPI_Type_size(a, b) +#define MPI_Barrier(a) SMPI_MPI_Barrier(a) +#define MPI_Irecv(a, b, c, d, e, f, g) SMPI_MPI_Irecv(a, b, c, d, e, f, g) +#define MPI_Recv(a, b, c, d, e, f, g) SMPI_MPI_Recv(a, b, c, d, e, f, g) +#define MPI_Isend(a, b, c, d, e, f, g) SMPI_MPI_Isend(a, b, c, d, e, f, g) +#define MPI_Send(a, b, c, d, e, f) SMPI_MPI_Send(a, b, c, d, e, f) +#define MPI_Bcast(a, b, c, d, e) SMPI_MPI_Bcast(a, b, c, d, e) +#define MPI_Wait(a, b) SMPI_MPI_Wait(a, b) +#define MPI_Comm_split(a, b, c, d) SMPI_MPI_Comm_split(a, b, c, d) + +// SMPI Functions +XBT_PUBLIC(int) SMPI_MPI_Init(int *argc, char ***argv); +XBT_PUBLIC(int) SMPI_MPI_Finalize(void); +XBT_PUBLIC(int) SMPI_MPI_Abort(MPI_Comm comm, int errorcode); +XBT_PUBLIC(int) SMPI_MPI_Comm_size(MPI_Comm comm, int *size); +XBT_PUBLIC(int) SMPI_MPI_Comm_rank(MPI_Comm comm, int *rank); +XBT_PUBLIC(int) SMPI_MPI_Type_size(MPI_Datatype datatype, size_t * size); +XBT_PUBLIC(int) SMPI_MPI_Barrier(MPI_Comm comm); +XBT_PUBLIC(int) SMPI_MPI_Irecv(void *buf, int count, MPI_Datatype datatype, + int src, int tag, MPI_Comm comm, + MPI_Request * request); +XBT_PUBLIC(int) SMPI_MPI_Recv(void *buf, int count, MPI_Datatype datatype, + int src, int tag, MPI_Comm comm, + MPI_Status * status); +XBT_PUBLIC(int) SMPI_MPI_Isend(void *buf, int count, MPI_Datatype datatype, + int dst, int tag, MPI_Comm comm, + MPI_Request * request); +XBT_PUBLIC(int) SMPI_MPI_Send(void *buf, int count, MPI_Datatype datatype, + int dst, int tag, MPI_Comm comm); +XBT_PUBLIC(int) SMPI_MPI_Bcast(void *buf, int count, MPI_Datatype datatype, + int root, MPI_Comm comm); +XBT_PUBLIC(int) SMPI_MPI_Wait(MPI_Request * request, MPI_Status * status); +XBT_PUBLIC(int) SMPI_MPI_Comm_split(MPI_Comm comm, int color, int key, + MPI_Comm * comm_out); // smpi functions XBT_IMPORT_NO_EXPORT(int) smpi_simulated_main(int argc, char **argv); -unsigned int smpi_sleep(unsigned int); -void smpi_exit(int); -int smpi_gettimeofday(struct timeval *tv, struct timezone *tz); +XBT_PUBLIC(unsigned int) smpi_sleep(unsigned int); +XBT_PUBLIC(void) smpi_exit(int); +XBT_PUBLIC(int) smpi_gettimeofday(struct timeval *tv, struct timezone *tz); + +XBT_PUBLIC(void) smpi_do_once_1(const char *file, int line); +XBT_PUBLIC(int) smpi_do_once_2(void); +XBT_PUBLIC(void) smpi_do_once_3(void); + +#define SMPI_DO_ONCE for (smpi_do_once_1(__FILE__, __LINE__); smpi_do_once_2(); smpi_do_once_3()) +SG_END_DECL() #endif