From: Takahiro Hirofuchi Date: Thu, 24 Oct 2013 10:08:34 +0000 (+0200) Subject: Add the simcall setting CPU affinity X-Git-Tag: v3_11_beta~297^2^2~12 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/9a62ed923b7a2e978ab066c1e82f92c46c7c26c3 Add the simcall setting CPU affinity --- diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 301adeded9..ea5725d6c1 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -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); diff --git a/src/simix/smx_host.c b/src/simix/smx_host.c index 177c4cdb35..f88cf422fa 100644 --- a/src/simix/smx_host.c +++ b/src/simix/smx_host.c @@ -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); diff --git a/src/simix/smx_host_private.h b/src/simix/smx_host_private.h index 7fd525e426..52b663f410 100644 --- a/src/simix/smx_host_private.h +++ b/src/simix/smx_host_private.h @@ -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); diff --git a/src/simix/smx_smurf_private.h b/src/simix/smx_smurf_private.h index ab94860b3c..81b4b1d0c3 100644 --- a/src/simix/smx_smurf_private.h +++ b/src/simix/smx_smurf_private.h @@ -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 \ diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index 9fc7d4c976..fa53d95c7f 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -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.