From 7ceed997fb32263068563740b53ea4b7231ef362 Mon Sep 17 00:00:00 2001 From: Takahiro Hirofuchi Date: Thu, 24 Oct 2013 12:13:49 +0200 Subject: [PATCH] Extend simcall_host_execute() for CPU affinity --- include/simgrid/simix.h | 2 +- src/simix/smx_host.c | 9 ++++++--- src/simix/smx_host_private.h | 4 ++-- src/simix/smx_process.c | 2 +- src/simix/smx_smurf_private.h | 2 +- src/simix/smx_user.c | 4 ++-- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index ea5725d6c1..a2624779de 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -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, diff --git a/src/simix/smx_host.c b/src/simix/smx_host.c index f88cf422fa..d984677b3d 100644 --- a/src/simix/smx_host.c +++ b/src/simix/smx_host.c @@ -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); diff --git a/src/simix/smx_host_private.h b/src/simix/smx_host_private.h index 52b663f410..2cb3c6ea11 100644 --- a/src/simix/smx_host_private.h +++ b/src/simix/smx_host_private.h @@ -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); diff --git a/src/simix/smx_process.c b/src/simix/smx_process.c index aa7434acc8..e5145b9825 100644 --- a/src/simix/smx_process.c +++ b/src/simix/smx_process.c @@ -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); } } diff --git a/src/simix/smx_smurf_private.h b/src/simix/smx_smurf_private.h index 81b4b1d0c3..1cd75fef8d 100644 --- a/src/simix/smx_smurf_private.h +++ b/src/simix/smx_smurf_private.h @@ -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 \ diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index fa53d95c7f..f46a90943f 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -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); } /** -- 2.20.1