X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1632f396f414f85f50611cad05e13c47ad06387e..017cf40352819fcf7bbf2926cbbc7b6b5cbc66d5:/src/simix/smx_smurf_private.h diff --git a/src/simix/smx_smurf_private.h b/src/simix/smx_smurf_private.h index 30a1018ee5..91af60dd20 100644 --- a/src/simix/smx_smurf_private.h +++ b/src/simix/smx_smurf_private.h @@ -53,6 +53,8 @@ SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_DESTROY),\ SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_GEY_BY_NAME),\ SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_COMM_COUNT_BY_HOST),\ SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_GET_HEAD),\ +SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_SET_RECV),\ +SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_GET_RECV),\ SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_SEND),\ SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_ISEND),\ SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_RECV),\ @@ -63,6 +65,7 @@ SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_WAITANY),\ SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_WAIT),\ SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_TEST),\ SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_TESTANY),\ +SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_IPROBE),\ SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_REMAINS),\ SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_STATE),\ SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_SRC_DATA),\ @@ -92,8 +95,13 @@ SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_WRITE),\ SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_OPEN),\ SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_CLOSE),\ SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_STAT), \ -SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_UNLINK) - +SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_UNLINK),\ +SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_LS),\ +SIMCALL_ENUM_ELEMENT(SIMCALL_ASR_GET_PROPERTIES), \ +/* ****************************************************************************************** */ \ +/* TUTORIAL: New API */ \ +/* ****************************************************************************************** */ \ +SIMCALL_ENUM_ELEMENT(SIMCALL_NEW_API_INIT) /* SIMCALL_COMM_IS_LATENCY_BOUNDED and SIMCALL_SET_CATEGORY make things complicated * because they are not always present */ @@ -111,8 +119,16 @@ SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_UNLINK) #define SIMCALL_LIST3 #endif +#ifdef HAVE_MC +#define SIMCALL_LIST4 \ + ,SIMCALL_ENUM_ELEMENT(SIMCALL_MC_SNAPSHOT) \ + ,SIMCALL_ENUM_ELEMENT(SIMCALL_MC_COMPARE_SNAPSHOTS) +#else +#define SIMCALL_LIST4 +#endif + /* SIMCALL_LIST is the final macro to use */ -#define SIMCALL_LIST SIMCALL_LIST1 SIMCALL_LIST2 SIMCALL_LIST3 +#define SIMCALL_LIST SIMCALL_LIST1 SIMCALL_LIST2 SIMCALL_LIST3 SIMCALL_LIST4 /* you can redefine the following macro differently to generate something else * with the list of enumeration values (e.g. a table of strings or a table of function pointers) */ @@ -335,6 +351,16 @@ typedef struct s_smx_simcall { smx_action_t result; } rdv_get_head; + struct { + smx_rdv_t rdv; + smx_process_t receiver; + } rdv_set_rcv_proc; + + struct { + smx_rdv_t rdv; + smx_process_t result; + } rdv_get_rcv_proc; + struct { smx_rdv_t rdv; double task_size; @@ -377,6 +403,15 @@ typedef struct s_smx_simcall { smx_action_t result; } comm_irecv; + struct { + smx_rdv_t rdv; + int src; + int tag; + int (*match_fun)(void *, void *, smx_action_t); + void *data; + smx_action_t result; + } comm_iprobe; + struct { smx_action_t comm; } comm_destroy; @@ -568,6 +603,36 @@ typedef struct s_smx_simcall { int result; } file_unlink; + struct { + const char *mount; + const char *path; + xbt_dict_t result; + } file_ls; + + struct { + const char* name; + xbt_dict_t result; + } asr_get_properties; + + struct{ + void *s; + } mc_snapshot; + + struct{ + void *snapshot1; + void *snapshot2; + int result; + } mc_compare_snapshots; + + /* ****************************************************************************************** */ + /* TUTORIAL: New API */ + /* ****************************************************************************************** */ + struct { + const char* param1; + double param2; + int result; + } new_api; + }; } s_smx_simcall_t, *smx_simcall_t; @@ -580,5 +645,91 @@ void SIMIX_simcall_post(smx_action_t); smx_simcall_t SIMIX_simcall_mine(void); const char *SIMIX_simcall_name(e_smx_simcall_t kind); +/*************************** New simcall interface ****************************/ + +/* Pack all possible scalar types in an union */ +typedef union { + char c; + short s; + int i; + long l; + unsigned char uc; + unsigned short us; + unsigned int ui; + unsigned long ul; + float f; + double d; + void *p; +} u_smx_scalar_t; + +/* + * Define scalar type wrappers to ease the use of simcalls. + * These are used to wrap the arguments in SIMIX_simcall macro. + */ +#define CHAR(x) (c,x) +#define SHORT(x) (s,x) +#define INT(x) (i,x) +#define LONG(x) (l,x) +#define UCHAR(x) (uc,x) +#define USHORT(x) (us,x) +#define UINT(x) (ui,x) +#define ULONG(x) (ul,x) +#define FLOAT(x) (f,x) +#define DOUBLE(x) (d,x) +#define PTR(x) (p,x) + +/* + * Some macro machinery to get a MAP over the arguments of a variadic macro. + * It uses a FOLD to apply a macro to every argument, and because there is + * no recursion in the C preprocessor we must create a new macro for every + * depth of FOLD's recursion. + */ + +/* FOLD macro */ +#define FE_1(WHAT, X) WHAT(X) +#define FE_2(WHAT, X, ...) WHAT(X), FE_1(WHAT, __VA_ARGS__) +#define FE_3(WHAT, X, ...) WHAT(X), FE_2(WHAT, __VA_ARGS__) +#define FE_4(WHAT, X, ...) WHAT(X), FE_3(WHAT, __VA_ARGS__) +#define FE_5(WHAT, X, ...) WHAT(X), FE_4(WHAT, __VA_ARGS__) +/* NOTE: add as many FE_n as needed (maximum number of simcall arguments )*/ + +/* Make a MAP macro usgin FOLD (will apply 'action' to the arguments. + * GET_MACRO is a smart hack that counts the number of arguments passed to + * the variadic macro, and it is used to invoke the right FOLD depth. + */ +#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME +#define MAP(action,...) \ + GET_MACRO(__VA_ARGS__,FE_5,FE_4,FE_3,FE_2,FE_1) (action, __VA_ARGS__) + + +/* Generate code to initialize the field 'x' with value 'y' of an structure or union */ +#define INIT_FIELD_(x,y) {.x = y} +#define INIT_FIELD(t) INIT_FIELD t + +/* Project the second element of a tuple */ +#define SECOND_(x, y) y +#define SECOND(t) SECOND_ t + +/* + * \brief Simcall invocation macro + * It calls a dummy function that uses the format attribute to ensure typesafety (see + * gcc format attribute), then it invokes the real simcall function packing the + * user provided arguments in an array. + * \param id a simcall id (from the simcall enumeration ids) + * + */ +#define SIMIX_simcall(id, ...) \ + SIMIX_simcall_typecheck(simcall_types[id], MAP(SECOND, __VA_ARGS__)); \ + __SIMIX_simcall(id, (mytype_t[]){MAP(INIT_FIELD, __VA_ARGS__)}) + +void __SIMIX_simcall(e_smx_simcall_t simcall_id, u_smx_scalar_t *args); + +/* + * \biref Dummy variadic function used to typecheck the arguments of a simcall + * \param fmt A format string following printf style + */ +void SIMIX_simcall_typecheck(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); + + #endif