Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'mc'
[simgrid.git] / include / smpi / smpi.h
index eea0032..b990c4b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007, 2008, 2009, 2010. The SimGrid Team.
+/* Copyright (c) 2007-2014. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -7,6 +7,7 @@
 #ifndef SMPI_H
 #define SMPI_H
 
+#include <unistd.h>
 #include <stddef.h>
 #include <sys/time.h>
 #include <xbt/misc.h>
@@ -40,11 +41,12 @@ SG_BEGIN_DECL()
 #define MPI_MAX_LIBRARY_VERSION_STRING 100
 #define SMPI_RAND_SEED 5
 #define MPI_ANY_SOURCE -555
-#define MPI_BOTTOM (void *)0
+#define MPI_BOTTOM (void *)-111
 #define MPI_PROC_NULL -666
 #define MPI_ANY_TAG -444
 #define MPI_UNDEFINED -333
 #define MPI_IN_PLACE (void *)-222
+
 // errorcodes
 #define MPI_SUCCESS       0
 #define MPI_ERR_COMM      1
@@ -63,6 +65,10 @@ SG_BEGIN_DECL()
 #define MPI_ERR_PENDING   14
 #define MPI_ERR_BUFFER    15
 #define MPI_ERR_NAME      16
+#define MPI_ERR_DIMS      17
+#define MPI_ERR_TOPOLOGY  18
+#define MPI_ERR_NO_MEM    19
+#define MPI_ERR_WIN       20
 #define MPI_ERRCODES_IGNORE (int *)0
 #define MPI_IDENT     0
 #define MPI_SIMILAR   1
@@ -74,6 +80,14 @@ SG_BEGIN_DECL()
 #define MPI_IO               0
 #define MPI_BSEND_OVERHEAD   0
 
+
+#define MPI_MODE_NOSTORE 0x1
+#define MPI_MODE_NOPUT 0x2
+#define MPI_MODE_NOPRECEDE 0x4
+#define MPI_MODE_NOSUCCEED 0x8
+#define MPI_MODE_NOCHECK 0x10
+
+
 #define MPI_KEYVAL_INVALID 0
 #define MPI_NULL_COPY_FN NULL
 #define MPI_NULL_DELETE_FN NULL
@@ -86,19 +100,6 @@ SG_BEGIN_DECL()
 #define MPI_CXX_DOUBLE_COMPLEX MPI_DATATYPE_NULL
 #define MPI_CXX_LONG_DOUBLE_COMPLEX MPI_DATATYPE_NULL
 
-#define MPI_REAL4 MPI_DATATYPE_NULL
-#define MPI_REAL8 MPI_DATATYPE_NULL
-#define MPI_REAL16 MPI_DATATYPE_NULL
-#define MPI_COMPLEX8 MPI_DATATYPE_NULL
-#define MPI_COMPLEX16 MPI_DATATYPE_NULL
-#define MPI_COMPLEX32 MPI_DATATYPE_NULL
-#define MPI_INTEGER1 MPI_DATATYPE_NULL
-#define MPI_INTEGER2 MPI_DATATYPE_NULL
-#define MPI_INTEGER4 MPI_DATATYPE_NULL
-#define MPI_INTEGER8 MPI_DATATYPE_NULL
-#define MPI_COMPLEX MPI_DATATYPE_NULL
-#define MPI_DOUBLE_COMPLEX MPI_DATATYPE_NULL
-
 #define MPI_DISTRIBUTE_BLOCK 0
 #define MPI_DISTRIBUTE_NONE 1
 #define MPI_DISTRIBUTE_CYCLIC 2
@@ -112,6 +113,7 @@ SG_BEGIN_DECL()
 #define MPI_ROOT 0
 #define MPI_INFO_NULL -1
 #define MPI_COMM_TYPE_SHARED    1
+#define MPI_WIN_NULL NULL
 
 #define MPI_VERSION 1
 #define MPI_SUBVERSION 1
@@ -121,6 +123,7 @@ SG_BEGIN_DECL()
 #define MPI_LOCK_EXCLUSIVE           1
 #define MPI_LOCK_SHARED              2
 
+// FIXME : used nowhere...
 typedef enum MPIR_Combiner_enum{
   MPI_COMBINER_NAMED,
   MPI_COMBINER_DUP,
@@ -152,6 +155,15 @@ typedef enum MPIR_Topo_type {
 typedef ptrdiff_t MPI_Aint;
 typedef long long MPI_Offset;
 
+// To compile code that declare MPI_File variables
+struct s_empty {
+#if !defined(__GNUC__) || defined(__STRICT_ANSI__)
+  char empty;
+#endif
+};
+typedef struct s_empty *MPI_File;
+
+
 struct s_smpi_mpi_datatype;
 typedef struct s_smpi_mpi_datatype *MPI_Datatype;
 
@@ -162,10 +174,14 @@ typedef struct {
   int count;
 } MPI_Status;
 
-#define MPI_STATUS_IGNORE NULL
-#define MPI_STATUSES_IGNORE NULL
+struct s_smpi_mpi_win;
+typedef struct s_smpi_mpi_win* MPI_Win;
+typedef int MPI_Info;
+
+#define MPI_STATUS_IGNORE ((MPI_Status*)NULL)
+#define MPI_STATUSES_IGNORE ((MPI_Status*)NULL)
 
-#define MPI_DATATYPE_NULL NULL
+#define MPI_DATATYPE_NULL ((MPI_Datatype)NULL)
 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_CHAR;
 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_SHORT;
 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_INT;
@@ -188,7 +204,7 @@ XBT_PUBLIC_DATA( MPI_Datatype ) MPI_INT16_T;
 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_INT32_T;
 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_INT64_T;
 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_UINT8_T;
-#define MPI_BYTE MPI_UINT8_T
+XBT_PUBLIC_DATA( MPI_Datatype ) MPI_BYTE;
 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_UINT16_T;
 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_UINT32_T;
 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_UINT64_T;
@@ -209,15 +225,54 @@ XBT_PUBLIC_DATA(MPI_Datatype) MPI_2INT;
 XBT_PUBLIC_DATA(MPI_Datatype) MPI_LONG_DOUBLE_INT;
 XBT_PUBLIC_DATA(MPI_Datatype) MPI_2FLOAT;
 XBT_PUBLIC_DATA(MPI_Datatype) MPI_2DOUBLE;
+XBT_PUBLIC_DATA(MPI_Datatype) MPI_2LONG;//only for compatibility with Fortran
+
+XBT_PUBLIC_DATA(MPI_Datatype) MPI_REAL4;
+XBT_PUBLIC_DATA(MPI_Datatype) MPI_REAL8;
+XBT_PUBLIC_DATA(MPI_Datatype) MPI_REAL16;
+XBT_PUBLIC_DATA(MPI_Datatype) MPI_COMPLEX8;
+XBT_PUBLIC_DATA(MPI_Datatype) MPI_COMPLEX16;
+XBT_PUBLIC_DATA(MPI_Datatype) MPI_COMPLEX32;
+XBT_PUBLIC_DATA(MPI_Datatype) MPI_INTEGER1;
+XBT_PUBLIC_DATA(MPI_Datatype) MPI_INTEGER2;
+XBT_PUBLIC_DATA(MPI_Datatype) MPI_INTEGER4;
+XBT_PUBLIC_DATA(MPI_Datatype) MPI_INTEGER8;
+XBT_PUBLIC_DATA(MPI_Datatype) MPI_INTEGER16;
+
 //for now we only send int values at max
 #define MPI_Count int
 #define MPI_COUNT MPI_INT
+
+//defines for fortran compatibility
+#if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
+  #define MPI_INTEGER MPI_INT
+  #define MPI_2INTEGER MPI_2INT
+  #define MPI_LOGICAL MPI_INT
+#else
+  #define MPI_INTEGER MPI_LONG
+  #define MPI_2INTEGER MPI_2LONG
+  #define MPI_LOGICAL MPI_LONG
+#endif
+
+#define MPI_COMPLEX MPI_C_FLOAT_COMPLEX
+#define MPI_DOUBLE_COMPLEX MPI_C_DOUBLE_COMPLEX
+#define MPI_LOGICAL1 MPI_UINT8_T
+#define MPI_LOGICAL2 MPI_UINT16_T
+#define MPI_LOGICAL4 MPI_UINT32_T
+#define MPI_LOGICAL8 MPI_UINT64_T
+#define MPI_2REAL MPI_2FLOAT
+#define MPI_CHARACTER MPI_CHAR
+#define MPI_DOUBLE_PRECISION MPI_DOUBLE
+#define MPI_2DOUBLE_PRECISION MPI_2DOUBLE
+
+
+
 typedef void MPI_User_function(void *invec, void *inoutvec, int *len,
                                MPI_Datatype * datatype);
 struct s_smpi_mpi_op;
 typedef struct s_smpi_mpi_op *MPI_Op;
 
-#define MPI_OP_NULL NULL
+#define MPI_OP_NULL ((MPI_Op)NULL)
 XBT_PUBLIC_DATA( MPI_Op ) MPI_MAX;
 XBT_PUBLIC_DATA( MPI_Op ) MPI_MIN;
 XBT_PUBLIC_DATA( MPI_Op ) MPI_MAXLOC;
@@ -230,26 +285,32 @@ XBT_PUBLIC_DATA( MPI_Op ) MPI_LXOR;
 XBT_PUBLIC_DATA( MPI_Op ) MPI_BAND;
 XBT_PUBLIC_DATA( MPI_Op ) MPI_BOR;
 XBT_PUBLIC_DATA( MPI_Op ) MPI_BXOR;
+//For accumulate
+XBT_PUBLIC_DATA( MPI_Op ) MPI_REPLACE;
 
+struct s_smpi_mpi_topology;
+typedef struct s_smpi_mpi_topology *MPI_Topology;
+                                   
 struct s_smpi_mpi_group;
 typedef struct s_smpi_mpi_group *MPI_Group;
 
-#define MPI_GROUP_NULL NULL
+#define MPI_GROUP_NULL ((MPI_Group)NULL)
 
 XBT_PUBLIC_DATA( MPI_Group ) MPI_GROUP_EMPTY;
 
 struct s_smpi_mpi_communicator;
 typedef struct s_smpi_mpi_communicator *MPI_Comm;
 
-#define MPI_COMM_NULL NULL
+#define MPI_COMM_NULL ((MPI_Comm)NULL)
 XBT_PUBLIC_DATA( MPI_Comm ) MPI_COMM_WORLD;
-#define MPI_UNIVERSE_SIZE smpi_comm_size(MPI_COMM_WORLD)
+XBT_PUBLIC_DATA( int ) MPI_UNIVERSE_SIZE;
 #define MPI_COMM_SELF smpi_process_comm_self()
 
 struct s_smpi_mpi_request;
 typedef struct s_smpi_mpi_request *MPI_Request;
 
-#define MPI_REQUEST_NULL NULL
+#define MPI_REQUEST_NULL ((MPI_Request)NULL)
+#define MPI_FORTRAN_REQUEST_NULL -1
 
 MPI_CALL(XBT_PUBLIC(int), MPI_Init, (int *argc, char ***argv));
 MPI_CALL(XBT_PUBLIC(int), MPI_Finalize, (void));
@@ -279,6 +340,9 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Type_commit, (MPI_Datatype* datatype));
 MPI_CALL(XBT_PUBLIC(int), MPI_Type_hindexed,
                             (int count, int* blocklens, MPI_Aint* indices,
                             MPI_Datatype old_type, MPI_Datatype* newtype));
+MPI_CALL(XBT_PUBLIC(int), MPI_Type_create_hindexed,
+                            (int count, int* blocklens, MPI_Aint* indices,
+                            MPI_Datatype old_type, MPI_Datatype* newtype));
 MPI_CALL(XBT_PUBLIC(int), MPI_Type_create_hindexed_block,
                             (int count, int blocklength, MPI_Aint* indices,
                             MPI_Datatype old_type, MPI_Datatype* newtype));
@@ -291,6 +355,9 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Type_create_hvector,
 MPI_CALL(XBT_PUBLIC(int), MPI_Type_indexed,
                             (int count, int* blocklens, int* indices,
                              MPI_Datatype old_type, MPI_Datatype* newtype));
+MPI_CALL(XBT_PUBLIC(int), MPI_Type_create_indexed,
+                            (int count, int* blocklens, int* indices,
+                             MPI_Datatype old_type, MPI_Datatype* newtype));
 MPI_CALL(XBT_PUBLIC(int), MPI_Type_create_indexed_block,
                             (int count, int blocklength, int* indices,
                              MPI_Datatype old_type, MPI_Datatype* newtype));
@@ -500,11 +567,26 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Get_library_version,
 MPI_CALL(XBT_PUBLIC(int), MPI_Reduce_local,(void *inbuf, void *inoutbuf, int count,
     MPI_Datatype datatype, MPI_Op op));
 
+MPI_CALL(XBT_PUBLIC(int), MPI_Win_free,( MPI_Win* win));
+MPI_CALL(XBT_PUBLIC(int), MPI_Win_create,( void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, MPI_Win *win));
+MPI_CALL(XBT_PUBLIC(int), MPI_Win_set_name,(MPI_Win  win, char * name));
+MPI_CALL(XBT_PUBLIC(int), MPI_Win_get_name,(MPI_Win  win, char * name, int* len));
+MPI_CALL(XBT_PUBLIC(int), MPI_Win_fence,( int assert,  MPI_Win win));
+
+MPI_CALL(XBT_PUBLIC(int), MPI_Get,( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
+    MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win));
+MPI_CALL(XBT_PUBLIC(int), MPI_Put,( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
+    MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win));
+MPI_CALL(XBT_PUBLIC(int), MPI_Accumulate,( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
+    MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Win win));
+MPI_CALL(XBT_PUBLIC(int), MPI_Alloc_mem, (MPI_Aint size, MPI_Info info, void *baseptr));
+MPI_CALL(XBT_PUBLIC(int), MPI_Free_mem, (void *base));
+
+
 //FIXME: these are not yet implemented
 
 typedef void MPI_Handler_function(MPI_Comm*, int*, ...);
-typedef int MPI_Win;
-typedef int MPI_Info;
+
 typedef void* MPI_Errhandler;
 
 typedef int MPI_Copy_function(MPI_Comm oldcomm, int keyval, void* extra_state, void* attribute_val_in,
@@ -559,6 +641,7 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Errhandler_get, (MPI_Comm comm, MPI_Errhandler* er
 MPI_CALL(XBT_PUBLIC(int), MPI_Error_string, (int errorcode, char* string, int* resultlen));
 MPI_CALL(XBT_PUBLIC(int), MPI_Errhandler_set, (MPI_Comm comm, MPI_Errhandler errhandler));
 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_set_errhandler, (MPI_Comm comm, MPI_Errhandler errhandler));
+MPI_CALL(XBT_PUBLIC(int), MPI_Comm_get_errhandler, (MPI_Comm comm, MPI_Errhandler *errhandler));
 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_create_errhandler,( MPI_Comm_errhandler_fn *function, MPI_Errhandler *errhandler));
 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_call_errhandler,(MPI_Comm comm,int errorcode));
 MPI_CALL(XBT_PUBLIC(int), MPI_Add_error_class,( int *errorclass));
@@ -606,9 +689,7 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Get_elements, (MPI_Status* status, MPI_Datatype da
 MPI_CALL(XBT_PUBLIC(int), MPI_Dims_create, (int nnodes, int ndims, int* dims));
 MPI_CALL(XBT_PUBLIC(int), MPI_Initialized, (int* flag));
 MPI_CALL(XBT_PUBLIC(int), MPI_Pcontrol, (const int level ));
-MPI_CALL(XBT_PUBLIC(int), MPI_Win_fence,( int assert,  MPI_Win win));
-MPI_CALL(XBT_PUBLIC(int), MPI_Win_free,( MPI_Win* win));
-MPI_CALL(XBT_PUBLIC(int), MPI_Win_create,( void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, MPI_Win *win));
+
 MPI_CALL(XBT_PUBLIC(int), MPI_Info_create,( MPI_Info *info));
 MPI_CALL(XBT_PUBLIC(int), MPI_Info_set,( MPI_Info info, char *key, char *value));
 MPI_CALL(XBT_PUBLIC(int), MPI_Info_get,(MPI_Info info,char *key,int valuelen, char *value, int *flag));
@@ -619,8 +700,8 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Info_get_nkeys,( MPI_Info info, int *nkeys));
 MPI_CALL(XBT_PUBLIC(int), MPI_Info_get_nthkey,( MPI_Info info, int n, char *key));
 MPI_CALL(XBT_PUBLIC(int), MPI_Info_get_valuelen,( MPI_Info info, char *key, int *valuelen, int *flag));
 
-MPI_CALL(XBT_PUBLIC(int), MPI_Get,( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
-    MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win));
+
+MPI_CALL(XBT_PUBLIC(int), MPI_Win_set_errhandler, (MPI_Win win, MPI_Errhandler errhandler));
 MPI_CALL(XBT_PUBLIC(int), MPI_Type_get_envelope,(MPI_Datatype datatype,int *num_integers,int *num_addresses,int *num_datatypes, int *combiner));
 MPI_CALL(XBT_PUBLIC(int), MPI_Type_get_contents,(MPI_Datatype datatype, int max_integers, int max_addresses,
                             int max_datatypes, int* array_of_integers, MPI_Aint* array_of_addresses, 
@@ -663,13 +744,24 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Comm_get_parent,( MPI_Comm *parent));
 //FIXME: End of all the not yet implemented stuff
 
 // smpi functions
+XBT_PUBLIC(int) smpi_global_size(void);
 XBT_PUBLIC(MPI_Comm) smpi_process_comm_self(void);
 /*
 XBT_PUBLIC(void) smpi_exit(int);
 */
 
+XBT_PUBLIC(void) smpi_execute_flops(double flops);
+XBT_PUBLIC(void) smpi_execute(double duration);
+
+XBT_PUBLIC(double) smpi_get_host_power_peak_at(int pstate_index);
+XBT_PUBLIC(double) smpi_get_host_current_power_peak(void);
+XBT_PUBLIC(int) smpi_get_host_nb_pstates(void);
+XBT_PUBLIC(void) smpi_set_host_power_peak_at(int pstate_index);
+XBT_PUBLIC(double) smpi_get_host_consumed_energy(void);
+
+XBT_PUBLIC(int) smpi_usleep(useconds_t usecs);
 XBT_PUBLIC(unsigned int) smpi_sleep(unsigned int secs);
-XBT_PUBLIC(int) smpi_gettimeofday(struct timeval *tv);
+XBT_PUBLIC(int) smpi_gettimeofday(struct timeval *tv, void* tz);
 XBT_PUBLIC(unsigned long long) smpi_rastro_resolution (void);
 XBT_PUBLIC(unsigned long long) smpi_rastro_timestamp (void);
 XBT_PUBLIC(void) smpi_sample_1(int global, const char *file, int line,
@@ -709,11 +801,19 @@ XBT_PUBLIC(int) __attribute__((weak)) MAIN__(void);
 XBT_PUBLIC(int) smpi_main(int (*realmain) (int argc, char *argv[]),int argc, char *argv[]);
 XBT_PUBLIC(void) __attribute__((weak)) user_main_(void);
 XBT_PUBLIC(int) smpi_process_index(void);
+XBT_PUBLIC(void) smpi_process_init(int *argc, char ***argv);
 
 /* Trace replay specific stuff */
 XBT_PUBLIC(void) smpi_replay_init(int *argc, char***argv);
 XBT_PUBLIC(void) smpi_action_trace_run(char *);
 XBT_PUBLIC(int) smpi_replay_finalize(void);
 
+XBT_PUBLIC(void) SMPI_app_instance_register(const char *name, xbt_main_func_t code, int num_processes);
+XBT_PUBLIC(void) SMPI_init(void);
+XBT_PUBLIC(void) SMPI_finalize(void);
+
+
+
+
 SG_END_DECL()
 #endif