Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move SIMCALL_HOST_EXECUTE to the new simcall architecture for initial testing.
authorCristian Rosa <cristian@rtfm.org.ar>
Fri, 7 Sep 2012 13:59:04 +0000 (10:59 -0300)
committershenshei <paul.bedaride@gmail.com>
Wed, 28 Nov 2012 08:14:34 +0000 (09:14 +0100)
src/simix/smx_host.c
src/simix/smx_host_private.h
src/simix/smx_process.c
src/simix/smx_smurf.c
src/simix/smx_smurf_private.h
src/simix/smx_user.c

index 2308f27..2c47e5c 100644 (file)
@@ -285,10 +285,13 @@ void SIMIX_host_set_data(smx_host_t host, void *data)
   host->data = data;
 }
 
   host->data = data;
 }
 
-smx_action_t SIMIX_host_execute(const char *name, smx_host_t host,
-                                double computation_amount,
-                                double priority)
+smx_action_t SIMIX_host_execute(u_smx_scalar_t args[])
 {
 {
+  const char *name = args[0].p;
+  smx_host_t host = args[1].p;
+  double computation_amount = args[2].d;
+  double priority = args[3].d;
+
   /* alloc structures and initialize */
   smx_action_t action = xbt_mallocator_get(simix_global->action_mallocator);
   action->type = SIMIX_ACTION_EXECUTE;
   /* alloc structures and initialize */
   smx_action_t action = xbt_mallocator_get(simix_global->action_mallocator);
   action->type = SIMIX_ACTION_EXECUTE;
index 7da4059..fb47a67 100644 (file)
@@ -37,8 +37,7 @@ xbt_dict_t SIMIX_host_get_properties(smx_host_t host);
 double SIMIX_host_get_speed(smx_host_t host);
 double SIMIX_host_get_available_speed(smx_host_t host);
 int SIMIX_host_get_state(smx_host_t host);
 double SIMIX_host_get_speed(smx_host_t host);
 double SIMIX_host_get_available_speed(smx_host_t host);
 int SIMIX_host_get_state(smx_host_t host);
-smx_action_t SIMIX_host_execute(const char *name,
-    smx_host_t host, double computation_amount, double priority);
+smx_action_t SIMIX_host_execute(u_smx_scalar_t args[]);
 smx_action_t SIMIX_host_parallel_execute(const char *name,
     int host_nb, smx_host_t *host_list,
     double *computation_amount, double *communication_amount,
 smx_action_t SIMIX_host_parallel_execute(const char *name,
     int host_nb, smx_host_t *host_list,
     double *computation_amount, double *communication_amount,
index e9418a4..8c26267 100644 (file)
@@ -444,7 +444,8 @@ smx_action_t SIMIX_process_suspend(smx_process_t process, smx_process_t issuer)
       return NULL;
     }
   } else {
       return NULL;
     }
   } else {
-    return SIMIX_host_execute("suspend", process->smx_host, 0.0, 1.0);
+    SIMIX_simcall(SIMCALL_HOST_EXECUTE, PTR("suspend"), PTR(process->smx_host), DOUBLE(0.0), DOUBLE(1.0));
+    return process->simcall.host_execute.result;
   }
 }
 
   }
 }
 
index 8118479..91c67a4 100644 (file)
@@ -272,11 +272,7 @@ void SIMIX_simcall_pre(smx_simcall_t simcall, int value)
       break;
 
     case SIMCALL_HOST_EXECUTE:
       break;
 
     case SIMCALL_HOST_EXECUTE:
-      simcall->host_execute.result = SIMIX_host_execute(
-    simcall->host_execute.name,
-    simcall->host_execute.host,
-    simcall->host_execute.computation_amount,
-    simcall->host_execute.priority);
+      simcall->host_execute.result = simcall_table[simcall->call](simcall->args);
       SIMIX_simcall_answer(simcall);
       break;
 
       SIMIX_simcall_answer(simcall);
       break;
 
@@ -625,10 +621,28 @@ void SIMIX_simcall_post(smx_action_t action)
 /* New Simcal interface */
 
 /* FIXME: add types for every simcall */
 /* New Simcal interface */
 
 /* FIXME: add types for every simcall */
-const char *simcall_types[NUM_SIMCALLS] = {"%d", "%d%f", "%l"};
+const char *simcall_types[NUM_SIMCALLS] = { [SIMCALL_HOST_EXECUTE] = "%s%p%f%f%p" };
+
+simcall_handler_t simcall_table[NUM_SIMCALLS] = {[SIMCALL_HOST_EXECUTE] = &SIMIX_host_execute};
 
 void SIMIX_simcall_typecheck(const char *fmt, ...)
 {
   return;
 }
 
 
 void SIMIX_simcall_typecheck(const char *fmt, ...)
 {
   return;
 }
 
+void __SIMIX_simcall(e_smx_simcall_t simcall_id, u_smx_scalar_t *args)
+{
+  smx_process_t self = SIMIX_process_self();
+  self->simcall.call = simcall_id;
+  self->simcall.args = args;
+
+  if (self != simix_global->maestro_process) {
+    XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
+              SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
+
+    SIMIX_process_yield(self);
+  } else {
+
+    SIMIX_simcall_pre(&self->simcall, 0);
+  }
+}
index 91af60d..7ba6aec 100644 (file)
@@ -147,6 +147,8 @@ SIMCALL_LIST
 typedef struct s_smx_simcall {
   e_smx_simcall_t call;
   smx_process_t issuer;
 typedef struct s_smx_simcall {
   e_smx_simcall_t call;
   smx_process_t issuer;
+  union u_smx_scalar *args;
+  //FIXME: union u_smx_scalar retval;
 
   union {
 
 
   union {
 
@@ -648,7 +650,7 @@ const char *SIMIX_simcall_name(e_smx_simcall_t kind);
 /*************************** New simcall interface ****************************/
 
 /* Pack all possible scalar types in an union */
 /*************************** New simcall interface ****************************/
 
 /* Pack all possible scalar types in an union */
-typedef union {
+typedef union u_smx_scalar {
   char            c;
   short           s;
   int             i;
   char            c;
   short           s;
   int             i;
@@ -678,6 +680,8 @@ typedef union {
 #define DOUBLE(x) (d,x)
 #define PTR(x)  (p,x)
 
 #define DOUBLE(x) (d,x)
 #define PTR(x)  (p,x)
 
+#define MYMACRO(...)
+
 /*
  * 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
 /*
  * 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
@@ -704,7 +708,7 @@ typedef union {
 
 /* Generate code to initialize the field 'x' with value 'y' of an structure or union */
 #define INIT_FIELD_(x,y) {.x = y}
 
 /* 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
+#define INIT_FIELD(t) INIT_FIELD_ t
 
 /* Project the second element of a tuple */
 #define SECOND_(x, y) y
 
 /* Project the second element of a tuple */
 #define SECOND_(x, y) y
@@ -720,7 +724,7 @@ typedef union {
  */
 #define SIMIX_simcall(id, ...) \
   SIMIX_simcall_typecheck(simcall_types[id], MAP(SECOND, __VA_ARGS__)); \
  */
 #define SIMIX_simcall(id, ...) \
   SIMIX_simcall_typecheck(simcall_types[id], MAP(SECOND, __VA_ARGS__)); \
-  __SIMIX_simcall(id, (mytype_t[]){MAP(INIT_FIELD, __VA_ARGS__)})
+  __SIMIX_simcall(id, (u_smx_scalar_t[]){MAP(INIT_FIELD, __VA_ARGS__)})
 
 void __SIMIX_simcall(e_smx_simcall_t simcall_id, u_smx_scalar_t *args);
 
 
 void __SIMIX_simcall(e_smx_simcall_t simcall_id, u_smx_scalar_t *args);
 
@@ -730,6 +734,10 @@ void __SIMIX_simcall(e_smx_simcall_t simcall_id, u_smx_scalar_t *args);
  */
 void SIMIX_simcall_typecheck(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
 
  */
 void SIMIX_simcall_typecheck(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
 
+typedef smx_action_t (*simcall_handler_t)(u_smx_scalar_t *);
+
+extern const char *simcall_types[];
+extern simcall_handler_t simcall_table[];
 
 #endif
 
 
 #endif
 
index cf09a36..db657c1 100644 (file)
@@ -204,6 +204,7 @@ void simcall_host_set_data(smx_host_t host, void *data)
  * \param priority computation priority
  * \return A new SIMIX execution action
  */
  * \param priority computation priority
  * \return A new SIMIX execution action
  */
+
 smx_action_t simcall_host_execute(const char *name, smx_host_t host,
                                     double computation_amount,
                                     double priority)
 smx_action_t simcall_host_execute(const char *name, smx_host_t host,
                                     double computation_amount,
                                     double priority)
@@ -219,9 +220,12 @@ smx_action_t simcall_host_execute(const char *name, smx_host_t host,
   simcall->host_execute.host = host;
   simcall->host_execute.computation_amount = computation_amount;
   simcall->host_execute.priority = priority;
   simcall->host_execute.host = host;
   simcall->host_execute.computation_amount = computation_amount;
   simcall->host_execute.priority = priority;
+
   if(MC_is_active()) /* Initialize result to NULL for snapshot comparison done during simcall */
     simcall->host_execute.result = NULL;
   if(MC_is_active()) /* Initialize result to NULL for snapshot comparison done during simcall */
     simcall->host_execute.result = NULL;
-  SIMIX_simcall_push(simcall->issuer);
+
+  SIMIX_simcall(SIMCALL_HOST_EXECUTE, PTR(name), PTR(host), DOUBLE(computation_amount), DOUBLE(priority));
+
   return simcall->host_execute.result;
 }
 
   return simcall->host_execute.result;
 }