Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add the simcall setting CPU affinity
authorTakahiro Hirofuchi <t.hirofuchi+sg@aist.go.jp>
Thu, 24 Oct 2013 10:08:34 +0000 (12:08 +0200)
committerTakahiro Hirofuchi <t.hirofuchi+sg@aist.go.jp>
Thu, 24 Oct 2013 10:08:34 +0000 (12:08 +0200)
include/simgrid/simix.h
src/simix/smx_host.c
src/simix/smx_host_private.h
src/simix/smx_smurf_private.h
src/simix/smx_user.c

index 301aded..ea5725d 100644 (file)
@@ -324,6 +324,7 @@ XBT_PUBLIC(double) simcall_host_execution_get_remains(smx_action_t execution);
 XBT_PUBLIC(e_smx_state_t) simcall_host_execution_get_state(smx_action_t execution);
 XBT_PUBLIC(void) simcall_host_execution_set_priority(smx_action_t execution, double priority);
 XBT_PUBLIC(void) simcall_host_execution_set_bound(smx_action_t execution, double bound);
+XBT_PUBLIC(void) simcall_host_execution_set_affinity(smx_action_t execution, smx_host_t host, unsigned long mask);
 XBT_PUBLIC(e_smx_state_t) simcall_host_execution_wait(smx_action_t execution);
 XBT_PUBLIC(void) simcall_host_get_params(smx_host_t vm, ws_params_t param);
 XBT_PUBLIC(void) simcall_host_set_params(smx_host_t vm, ws_params_t param);
index 177c4cd..f88cf42 100644 (file)
@@ -577,6 +577,17 @@ void SIMIX_host_execution_set_bound(smx_action_t action, double bound){
     ws_model->set_bound(action->execution.surf_exec, bound);
 }
 
+void SIMIX_pre_host_execution_set_affinity(smx_simcall_t simcall,
+    smx_action_t action, smx_host_t host, unsigned long mask){
+  SIMIX_host_execution_set_affinity(action, host, mask);
+}
+void SIMIX_host_execution_set_affinity(smx_action_t action, smx_host_t host, unsigned long mask){
+  surf_model_t ws_model = get_ws_model_from_action(action);
+
+  if(action->execution.surf_exec)
+    ws_model->set_affinity(action->execution.surf_exec, host, mask);
+}
+
 void SIMIX_pre_host_execution_wait(smx_simcall_t simcall, smx_action_t action){
 
   XBT_DEBUG("Wait for execution of action %p, state %d", action, (int)action->state);
index 7fd525e..52b663f 100644 (file)
@@ -58,6 +58,7 @@ double SIMIX_host_execution_get_remains(smx_action_t action);
 e_smx_state_t SIMIX_host_execution_get_state(smx_action_t action);
 void SIMIX_host_execution_set_priority(smx_action_t action, double priority);
 void SIMIX_host_execution_set_bound(smx_action_t action, double bound);
+void SIMIX_host_execution_set_affinity(smx_action_t action, smx_host_t host, unsigned long mask);
 void SIMIX_pre_host_execution_wait(smx_simcall_t simcall, smx_action_t action);
 
 // pre prototypes
@@ -83,6 +84,7 @@ double SIMIX_pre_host_execution_get_remains(smx_simcall_t, smx_action_t);
 e_smx_state_t SIMIX_pre_host_execution_get_state(smx_simcall_t, smx_action_t);
 void SIMIX_pre_host_execution_set_priority(smx_simcall_t, smx_action_t, double);
 void SIMIX_pre_host_execution_set_bound(smx_simcall_t simcall, smx_action_t action, double bound);
+void SIMIX_pre_host_execution_set_affinity(smx_simcall_t simcall, smx_action_t action, smx_host_t host, unsigned long mask);
 
 void SIMIX_host_execution_suspend(smx_action_t action);
 void SIMIX_host_execution_resume(smx_action_t action);
index ab94860..81b4b1d 100644 (file)
@@ -278,6 +278,7 @@ ACTION(SIMCALL_HOST_EXECUTION_GET_REMAINS, host_execution_get_remains, WITH_ANSW
 ACTION(SIMCALL_HOST_EXECUTION_GET_STATE, host_execution_get_state, WITH_ANSWER, TINT(result), TSPEC(execution, smx_action_t)) sep \
 ACTION(SIMCALL_HOST_EXECUTION_SET_PRIORITY, host_execution_set_priority, WITH_ANSWER, TVOID(result), TSPEC(execution, smx_action_t), TDOUBLE(priority)) sep \
 ACTION(SIMCALL_HOST_EXECUTION_SET_BOUND, host_execution_set_bound, WITHOUT_ANSWER, TVOID(result), TSPEC(execution, smx_action_t), TDOUBLE(bound)) sep \
+ACTION(SIMCALL_HOST_EXECUTION_SET_AFFINITY, host_execution_set_affinity, WITH_ANSWER, TVOID(result), TSPEC(execution, smx_action_t), TSPEC(ws, smx_host_t), TULONG(mask)) sep \
 ACTION(SIMCALL_HOST_EXECUTION_WAIT, host_execution_wait, WITHOUT_ANSWER, TINT(result), TSPEC(execution, smx_action_t)) sep \
 ACTION(SIMCALL_HOST_GET_PARAMS, host_get_params, WITHOUT_ANSWER, TVOID(result), TSPEC(ind_vm, smx_host_t), TSPEC(params, ws_params_t)) sep \
 ACTION(SIMCALL_HOST_SET_PARAMS, host_set_params, WITHOUT_ANSWER, TVOID(result), TSPEC(ind_vm, smx_host_t), TSPEC(params, ws_params_t)) sep \
index 9fc7d4c..fa53d95 100644 (file)
@@ -312,6 +312,20 @@ void simcall_host_execution_set_bound(smx_action_t execution, double bound)
   simcall_BODY_host_execution_set_bound(execution, bound);
 }
 
+/**
+ * \ingroup simix_host_management
+ * \brief Changes the CPU affinity of an execution action.
+ *
+ * This functions changes the CPU affinity of an execution action. See taskset(1) on Linux.
+ * \param execution The execution action
+ * \param host Host
+ * \param mask Affinity mask
+ */
+void simcall_host_execution_set_affinity(smx_action_t execution, smx_host_t host, unsigned long mask)
+{
+  simcall_BODY_host_execution_set_affinity(execution, host, mask);
+}
+
 /**
  * \ingroup simix_host_management
  * \brief Waits for the completion of an execution action and destroy it.