Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
SIMIX call + MSG function + Java binding for get_core
authorJonathan Rouzaud-Cornabas <jonathan.rouzaud-cornabas@ens-lyon.fr>
Thu, 13 Jun 2013 13:52:48 +0000 (15:52 +0200)
committerJonathan Rouzaud-Cornabas <jonathan.rouzaud-cornabas@ens-lyon.fr>
Thu, 13 Jun 2013 13:52:48 +0000 (15:52 +0200)
12 files changed:
include/simgrid/simix.h
src/bindings/java/jmsg_host.c
src/bindings/java/jmsg_host.h
src/bindings/java/org/simgrid/msg/Host.java
src/include/surf/surf.h
src/msg/msg_host.c
src/simix/smx_host.c
src/simix/smx_host_private.h
src/simix/smx_smurf_private.h
src/simix/smx_user.c
src/surf/cpu_cas01.c
src/surf/workstation.c

index b3305ca..510bade 100644 (file)
@@ -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 */
index 230ad16..b32b9b5 100644 (file)
@@ -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);
index a689fda..401d53b 100644 (file)
@@ -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
index 82a4753..3b7f41f 100644 (file)
@@ -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. 
         */
index ae2e61d..3b684fe 100644 (file)
@@ -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 */
index a767553..6f01ec9 100644 (file)
@@ -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
  *
index 5bd6088..72da17a 100644 (file)
@@ -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);
 }
index 6b03c17..adb53b8 100644 (file)
@@ -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);
index 5fccaac..1f5f540 100644 (file)
 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 \
index 544f97b..d42275c 100644 (file)
@@ -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.
index 43bb124..f704612 100644 (file)
@@ -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;
index 3b3b9df..aec832a 100644 (file)
@@ -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;