From: Jonathan Rouzaud-Cornabas Date: Thu, 13 Jun 2013 13:52:57 +0000 (+0200) Subject: Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid X-Git-Tag: v3_9_90~272 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/076aada113aa0566c059211416cd9214a54d763d?hp=3bf293f0c23fc59535f99e17ee43531cb9a9fdb6 Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid --- diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index b3305caee3..510bade279 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -293,6 +293,7 @@ XBT_PUBLIC(void) SIMIX_comm_finish(smx_action_t action); XBT_PUBLIC(smx_host_t) simcall_host_get_by_name(const char *name); XBT_PUBLIC(const char *) simcall_host_get_name(smx_host_t host); XBT_PUBLIC(xbt_dict_t) simcall_host_get_properties(smx_host_t host); +XBT_PUBLIC(int) simcall_host_get_core(smx_host_t host); XBT_PUBLIC(double) simcall_host_get_speed(smx_host_t host); XBT_PUBLIC(double) simcall_host_get_available_speed(smx_host_t host); /* Two possible states, 1 - CPU ON and 0 CPU OFF */ diff --git a/src/bindings/java/jmsg_host.c b/src/bindings/java/jmsg_host.c index 230ad1601d..b32b9b5d7d 100644 --- a/src/bindings/java/jmsg_host.c +++ b/src/bindings/java/jmsg_host.c @@ -174,6 +174,20 @@ Java_org_simgrid_msg_Host_getSpeed(JNIEnv * env, return (jdouble) MSG_get_host_speed(host); } + +JNIEXPORT jdouble JNICALL +Java_org_simgrid_msg_Host_getCore(JNIEnv * env, + jobject jhost) { + msg_host_t host = jhost_get_native(env, jhost); + + if (!host) { + jxbt_throw_notbound(env, "host", jhost); + return -1; + } + + return (jdouble) MSG_get_host_core(host); +} + JNIEXPORT jint JNICALL Java_org_simgrid_msg_Host_getLoad(JNIEnv * env, jobject jhost) { msg_host_t host = jhost_get_native(env, jhost); diff --git a/src/bindings/java/jmsg_host.h b/src/bindings/java/jmsg_host.h index a689fda735..401d53b9c3 100644 --- a/src/bindings/java/jmsg_host.h +++ b/src/bindings/java/jmsg_host.h @@ -134,6 +134,13 @@ JNIEXPORT jint JNICALL Java_org_simgrid_msg_Host_getCount */ JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getSpeed (JNIEnv *, jobject); +/* + * Class org_simgrid_msg_Host + * Method getCore + * Signature ()D + */ +JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getCore + (JNIEnv *, jobject); /* * Class org_simgrid_msg_Host * Method getLoad diff --git a/src/bindings/java/org/simgrid/msg/Host.java b/src/bindings/java/org/simgrid/msg/Host.java index 82a4753615..3b7f41fb67 100644 --- a/src/bindings/java/org/simgrid/msg/Host.java +++ b/src/bindings/java/org/simgrid/msg/Host.java @@ -164,6 +164,15 @@ public class Host { * */ public native double getSpeed(); + + /** + * This method returns the number of core of a host. + * + * @return The speed of the processor of the host in flops. + * + */ + public native double getCore(); + /** * Returns the value of a given host property. */ diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index ae2e61dd1a..3b684fed50 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -193,6 +193,7 @@ typedef struct surf_cpu_model_extension_public { surf_action_t(*execute) (void *cpu, double size); surf_action_t(*sleep) (void *cpu, double duration); e_surf_resource_state_t(*get_state) (void *cpu); + int (*get_core) (void *cpu); double (*get_speed) (void *cpu, double load); double (*get_available_speed) (void *cpu); void (*add_traces) (void); @@ -245,6 +246,7 @@ typedef struct surf_workstation_model_extension_public { and create the corresponding action */ surf_action_t(*sleep) (void *workstation, double duration); /**< Make a workstation sleep during a given duration */ e_surf_resource_state_t(*get_state) (void *workstation); /**< Return the CPU state of a workstation */ + int (*get_core) (void *workstation); double (*get_speed) (void *workstation, double load); /**< Return the speed of a workstation */ double (*get_available_speed) (void *workstation); /**< Return tha available speed of a workstation */ surf_action_t(*communicate) (void *workstation_src, /**< Execute a communication amount between two workstations */ diff --git a/src/msg/msg_host.c b/src/msg/msg_host.c index a767553db3..6f01ec97b7 100644 --- a/src/msg/msg_host.c +++ b/src/msg/msg_host.c @@ -202,6 +202,17 @@ double MSG_get_host_speed(msg_host_t h) return (simcall_host_get_speed(h)); } + +/** \ingroup m_host_management + * \brief Return the number of core. + */ +int MSG_get_host_core(msg_host_t h) +{ + xbt_assert((h != NULL), "Invalid parameters"); + + return (simcall_host_get_core(h)); +} + /** \ingroup m_host_management * \brief Returns the value of a given host property * diff --git a/src/simix/smx_host.c b/src/simix/smx_host.c index 5bd6088b96..72da17a23c 100644 --- a/src/simix/smx_host.c +++ b/src/simix/smx_host.c @@ -148,6 +148,18 @@ double SIMIX_host_get_speed(smx_host_t host){ get_speed(host, 1.0); } +int SIMIX_pre_host_get_core(smx_simcall_t simcall, smx_host_t host){ + return SIMIX_host_get_core(host); +} +int SIMIX_host_get_core(smx_host_t host){ + xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)"); + + return surf_workstation_model->extension.workstation. + get_core(host); +} + + + double SIMIX_pre_host_get_available_speed(smx_simcall_t simcall, smx_host_t host){ return SIMIX_host_get_available_speed(host); } diff --git a/src/simix/smx_host_private.h b/src/simix/smx_host_private.h index 6b03c1708e..adb53b8cef 100644 --- a/src/simix/smx_host_private.h +++ b/src/simix/smx_host_private.h @@ -38,6 +38,7 @@ void SIMIX_host_add_auto_restart_process(smx_host_t host, void SIMIX_host_restart_processes(smx_host_t host); void SIMIX_host_autorestart(smx_host_t host); xbt_dict_t SIMIX_host_get_properties(smx_host_t host); +int SIMIX_host_get_core(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); @@ -59,6 +60,7 @@ smx_host_t SIMIX_pre_host_get_by_name(smx_simcall_t, const char*); const char* SIMIX_pre_host_self_get_name(smx_simcall_t); const char* SIMIX_pre_host_get_name(smx_simcall_t, smx_host_t); xbt_dict_t SIMIX_pre_host_get_properties(smx_simcall_t, smx_host_t); +int SIMIX_pre_host_get_core(smx_simcall_t, smx_host_t); double SIMIX_pre_host_get_speed(smx_simcall_t, smx_host_t); double SIMIX_pre_host_get_available_speed(smx_simcall_t, smx_host_t); int SIMIX_pre_host_get_state(smx_simcall_t, smx_host_t); diff --git a/src/simix/smx_smurf_private.h b/src/simix/smx_smurf_private.h index 5fccaace60..1f5f540af2 100644 --- a/src/simix/smx_smurf_private.h +++ b/src/simix/smx_smurf_private.h @@ -262,6 +262,7 @@ ACTION(SIMCALL_HOST_GET_BY_NAME, host_get_by_name, WITH_ANSWER, TSPEC(result, smx_host_t), TSTRING(name)) sep \ ACTION(SIMCALL_HOST_GET_NAME, host_get_name, WITH_ANSWER, TSTRING(result), TSPEC(host, smx_host_t)) sep \ ACTION(SIMCALL_HOST_GET_PROPERTIES, host_get_properties, WITH_ANSWER, TSPEC(result, xbt_dict_t), TSPEC(host, smx_host_t)) sep \ +ACTION(SIMCALL_HOST_GET_CORE, host_get_core, WITH_ANSWER, TINT(result), TSPEC(host, smx_host_t)) sep \ ACTION(SIMCALL_HOST_GET_SPEED, host_get_speed, WITH_ANSWER, TDOUBLE(result), TSPEC(host, smx_host_t)) sep \ ACTION(SIMCALL_HOST_GET_AVAILABLE_SPEED, host_get_available_speed, WITH_ANSWER, TDOUBLE(result), TSPEC(host, smx_host_t)) sep \ ACTION(SIMCALL_HOST_GET_STATE, host_get_state, WITH_ANSWER, TINT(result), TSPEC(host, smx_host_t)) sep \ diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index 544f97b8c0..d42275c9f9 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -82,6 +82,20 @@ double simcall_host_get_speed(smx_host_t host) return simcall_BODY_host_get_speed(host); } +/** + * \ingroup simix_host_management + * \brief Returns the number of core of the processor. + * + * \param host A SIMIX host + * \return The number of core + */ +int simcall_host_get_core(smx_host_t host) +{ + return simcall_BODY_host_get_core(host); +} + + + /** * \ingroup simix_host_management * \brief Returns the available speed of the processor. diff --git a/src/surf/cpu_cas01.c b/src/surf/cpu_cas01.c index 43bb124c96..f704612a5c 100644 --- a/src/surf/cpu_cas01.c +++ b/src/surf/cpu_cas01.c @@ -298,6 +298,12 @@ static double cpu_get_speed(void *cpu, double load) return load * ((cpu_Cas01_t)surf_cpu_resource_priv(cpu))->power_peak; } +static int cpu_get_core(void *cpu) +{ + return ((cpu_Cas01_t)surf_cpu_resource_priv(cpu))->core; +} + + static double cpu_get_available_speed(void *cpu) { /* number between 0 and 1 */ @@ -388,6 +394,7 @@ static void surf_cpu_model_init_internal() surf_cpu_model->extension.cpu.sleep = cpu_action_sleep; surf_cpu_model->extension.cpu.get_state = cpu_get_state; + surf_cpu_model->extension.cpu.get_core = cpu_get_core; surf_cpu_model->extension.cpu.get_speed = cpu_get_speed; surf_cpu_model->extension.cpu.get_available_speed = cpu_get_available_speed; diff --git a/src/surf/workstation.c b/src/surf/workstation.c index 3b3b9df090..aec832a014 100644 --- a/src/surf/workstation.c +++ b/src/surf/workstation.c @@ -227,6 +227,14 @@ static double ws_get_speed(void *workstation, double load) get_speed(workstation, load); } +static int ws_get_core(void *workstation) +{ + return surf_cpu_model->extension.cpu. + get_core(workstation); +} + + + static double ws_get_available_speed(void *workstation) { return surf_cpu_model->extension.cpu. @@ -438,6 +446,7 @@ static void surf_workstation_model_init_internal(void) surf_workstation_model->extension.workstation.execute = ws_execute; surf_workstation_model->extension.workstation.sleep = ws_action_sleep; surf_workstation_model->extension.workstation.get_state = ws_get_state; + surf_workstation_model->extension.workstation.get_core = ws_get_core; surf_workstation_model->extension.workstation.get_speed = ws_get_speed; surf_workstation_model->extension.workstation.get_available_speed = ws_get_available_speed;