Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Extend simcall_host_execute() for CPU affinity
authorTakahiro Hirofuchi <t.hirofuchi+sg@aist.go.jp>
Thu, 24 Oct 2013 10:13:49 +0000 (12:13 +0200)
committerTakahiro Hirofuchi <t.hirofuchi+sg@aist.go.jp>
Thu, 24 Oct 2013 10:13:49 +0000 (12:13 +0200)
include/simgrid/simix.h
src/simix/smx_host.c
src/simix/smx_host_private.h
src/simix/smx_process.c
src/simix/smx_smurf_private.h
src/simix/smx_user.c

index ea5725d..a262477 100644 (file)
@@ -310,7 +310,7 @@ XBT_PUBLIC(void) simcall_host_set_data(smx_host_t host, void *data);
 
 XBT_PUBLIC(smx_action_t) simcall_host_execute(const char *name, smx_host_t host,
                                                 double computation_amount,
-                                                double priority, double bound);
+                                                double priority, double bound, unsigned long affinity_mask);
 XBT_PUBLIC(smx_action_t) simcall_host_parallel_execute(const char *name,
                                                      int host_nb,
                                                      smx_host_t *host_list,
index f88cf42..d984677 100644 (file)
@@ -400,11 +400,11 @@ void SIMIX_host_set_data(smx_host_t host, void *data){
 }
 
 smx_action_t SIMIX_pre_host_execute(smx_simcall_t simcall,const char *name,
-    smx_host_t host, double computation_amount, double priority, double bound){
-  return SIMIX_host_execute(name, host, computation_amount, priority, bound);
+    smx_host_t host, double computation_amount, double priority, double bound, unsigned long affinity_mask){
+  return SIMIX_host_execute(name, host, computation_amount, priority, bound, affinity_mask);
 }
 smx_action_t SIMIX_host_execute(const char *name,
-    smx_host_t host, double computation_amount, double priority, double bound){
+    smx_host_t host, double computation_amount, double priority, double bound, unsigned long affinity_mask){
 
   /* alloc structures and initialize */
   smx_action_t action = xbt_mallocator_get(simix_global->action_mallocator);
@@ -431,6 +431,9 @@ smx_action_t SIMIX_host_execute(const char *name,
       ws_model->set_bound(action->execution.surf_exec, SIMIX_host_get_speed(host));
     else
       ws_model->set_bound(action->execution.surf_exec, bound);
+
+    if (affinity_mask != 0)
+      ws_model->set_affinity(action->execution.surf_exec, host, affinity_mask);
   }
 
   XBT_DEBUG("Create execute action %p", action);
index 52b663f..2cb3c6e 100644 (file)
@@ -47,7 +47,7 @@ int SIMIX_host_get_state(smx_host_t host);
 void SIMIX_host_on(smx_host_t host);
 void SIMIX_host_off(smx_host_t host, smx_process_t issuer);
 smx_action_t SIMIX_host_execute(const char *name,
-    smx_host_t host, double computation_amount, double priority, double bound);
+    smx_host_t host, double computation_amount, double priority, double bound, unsigned long affinity_mask);
 smx_action_t SIMIX_host_parallel_execute(const char *name,
     int host_nb, smx_host_t *host_list,
     double *computation_amount, double *communication_amount,
@@ -75,7 +75,7 @@ int SIMIX_pre_host_get_state(smx_simcall_t, smx_host_t);
 void* SIMIX_pre_host_self_get_data(smx_simcall_t);
 void* SIMIX_pre_host_get_data(smx_simcall_t, smx_host_t);
 void SIMIX_pre_host_set_data(smx_simcall_t, smx_host_t, void*);
-smx_action_t SIMIX_pre_host_execute(smx_simcall_t, const char*, smx_host_t, double, double, double);
+smx_action_t SIMIX_pre_host_execute(smx_simcall_t, const char*, smx_host_t, double, double, double, unsigned long);
 smx_action_t SIMIX_pre_host_parallel_execute(smx_simcall_t, const char*, int, smx_host_t*,
                                              double*, double*, double, double);
 void SIMIX_pre_host_execution_destroy(smx_simcall_t, smx_action_t);
index aa7434a..e5145b9 100644 (file)
@@ -488,7 +488,7 @@ smx_action_t SIMIX_process_suspend(smx_process_t process, smx_process_t issuer)
     }
   } else {
     /* FIXME: computation size is zero. Is it okay that bound is zero ? */
-    return SIMIX_host_execute("suspend", process->smx_host, 0.0, 1.0, 0.0);
+    return SIMIX_host_execute("suspend", process->smx_host, 0.0, 1.0, 0.0, 0);
   }
 }
 
index 81b4b1d..1cd75fe 100644 (file)
@@ -270,7 +270,7 @@ ACTION(SIMCALL_HOST_GET_AVAILABLE_SPEED, host_get_available_speed, WITH_ANSWER,
 ACTION(SIMCALL_HOST_GET_STATE, host_get_state, WITH_ANSWER, TINT(result), TSPEC(host, smx_host_t)) sep \
 ACTION(SIMCALL_HOST_GET_DATA, host_get_data, WITH_ANSWER, TPTR(result), TSPEC(host, smx_host_t)) sep \
 ACTION(SIMCALL_HOST_SET_DATA, host_set_data, WITH_ANSWER, TVOID(result), TSPEC(host, smx_host_t), TPTR(data)) sep \
-ACTION(SIMCALL_HOST_EXECUTE, host_execute, WITH_ANSWER, TSPEC(result, smx_action_t), TSTRING(name), TSPEC(host, smx_host_t), TDOUBLE(computation_amount), TDOUBLE(priority), TDOUBLE(bound)) sep \
+ACTION(SIMCALL_HOST_EXECUTE, host_execute, WITH_ANSWER, TSPEC(result, smx_action_t), TSTRING(name), TSPEC(host, smx_host_t), TDOUBLE(computation_amount), TDOUBLE(priority), TDOUBLE(bound), TULONG(affinity_mask)) sep \
 ACTION(SIMCALL_HOST_PARALLEL_EXECUTE, host_parallel_execute, WITH_ANSWER, TSPEC(result, smx_action_t), TSTRING(name), TINT(host_nb), TSPEC(host_list, smx_host_t*), TSPEC(computation_amount, double*), TSPEC(communication_amount, double*), TDOUBLE(amount), TDOUBLE(rate)) sep \
 ACTION(SIMCALL_HOST_EXECUTION_DESTROY, host_execution_destroy, WITH_ANSWER, TVOID(result), TSPEC(execution, smx_action_t)) sep \
 ACTION(SIMCALL_HOST_EXECUTION_CANCEL, host_execution_cancel, WITH_ANSWER, TVOID(result), TSPEC(execution, smx_action_t)) sep \
index fa53d95..f46a909 100644 (file)
@@ -183,13 +183,13 @@ void simcall_host_set_data(smx_host_t host, void *data)
 
 smx_action_t simcall_host_execute(const char *name, smx_host_t host,
                                     double computation_amount,
-                                    double priority, double bound)
+                                    double priority, double bound, unsigned long affinity_mask)
 {
   /* checking for infinite values */
   xbt_assert(isfinite(computation_amount), "computation_amount is not finite!");
   xbt_assert(isfinite(priority), "priority is not finite!");
   
-  return simcall_BODY_host_execute(name, host, computation_amount, priority, bound);
+  return simcall_BODY_host_execute(name, host, computation_amount, priority, bound, affinity_mask);
 }
 
 /**