Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
this is C++
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 27 Dec 2015 21:12:58 +0000 (22:12 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 27 Dec 2015 21:34:20 +0000 (22:34 +0100)
include/simgrid/host.h
src/simgrid/host.cpp
src/surf/cpu_cas01.cpp
src/surf/cpu_ti.cpp
src/surf/host_ptask_L07.cpp
src/surf/surf_c_bindings.cpp
src/surf/vm_hl13.cpp
teshsuite/surf/surf_usage/CMakeLists.txt
teshsuite/surf/surf_usage/surf_usage.cpp [moved from teshsuite/surf/surf_usage/surf_usage.c with 89% similarity]
teshsuite/surf/surf_usage/surf_usage2.cpp [moved from teshsuite/surf/surf_usage/surf_usage2.c with 100% similarity]

index 1669159..d215f17 100644 (file)
@@ -51,11 +51,6 @@ XBT_PUBLIC(smx_host_priv_t) sg_host_simix(sg_host_t host);
 XBT_PUBLIC(void) sg_host_simix_set(sg_host_t host, smx_host_priv_t priv);
 XBT_PUBLIC(void) sg_host_simix_destroy(sg_host_t host);
 
 XBT_PUBLIC(void) sg_host_simix_set(sg_host_t host, smx_host_priv_t priv);
 XBT_PUBLIC(void) sg_host_simix_destroy(sg_host_t host);
 
-// ========== SURF CPU ============
-XBT_PUBLIC(surf_cpu_t) sg_host_surfcpu(sg_host_t host);
-XBT_PUBLIC(void) sg_host_surfcpu_set(sg_host_t host, surf_cpu_t cpu);
-XBT_PUBLIC(void) sg_host_surfcpu_destroy(sg_host_t host);
-
 // ========== RoutingEdge ============
 XBT_PUBLIC(routing_edge_t) sg_host_edge(sg_host_t host);
 XBT_PUBLIC(void) sg_host_edge_set(sg_host_t host, routing_edge_t edge);
 // ========== RoutingEdge ============
 XBT_PUBLIC(routing_edge_t) sg_host_edge(sg_host_t host);
 XBT_PUBLIC(void) sg_host_edge_set(sg_host_t host, routing_edge_t edge);
index fdcc132..233d081 100644 (file)
@@ -124,16 +124,6 @@ void sg_host_simix_destroy(sg_host_t host) {
   host->extension_set(SIMIX_HOST_LEVEL, nullptr);
 }
 
   host->extension_set(SIMIX_HOST_LEVEL, nullptr);
 }
 
-// ========== SURF CPU ============
-surf_cpu_t sg_host_surfcpu(sg_host_t host) {
-       return host->p_cpu;
-}
-void sg_host_surfcpu_set(sg_host_t host, surf_cpu_t cpu) {
-  host->p_cpu = cpu;
-}
-void sg_host_surfcpu_destroy(sg_host_t host) {
-  host->p_cpu = nullptr;
-}
 // ========== RoutingEdge ============
 surf_RoutingEdge *sg_host_edge(sg_host_t host) {
        return (surf_RoutingEdge*) host->extension(ROUTING_HOST_LEVEL);
 // ========== RoutingEdge ============
 surf_RoutingEdge *sg_host_edge(sg_host_t host) {
        return (surf_RoutingEdge*) host->extension(ROUTING_HOST_LEVEL);
index 46bec97..26df06f 100644 (file)
@@ -130,7 +130,7 @@ void CpuCas01Model::addTraces()
   /* connect all traces relative to hosts */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
   /* connect all traces relative to hosts */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuCas01 *host = static_cast<CpuCas01*>(sg_host_surfcpu(sg_host_by_name(elm)));
+    CpuCas01 *host = static_cast<CpuCas01*>(sg_host_by_name(elm)->p_cpu);
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
@@ -140,7 +140,7 @@ void CpuCas01Model::addTraces()
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuCas01 *host = static_cast<CpuCas01*>(sg_host_surfcpu(sg_host_by_name(elm)));
+    CpuCas01 *host = static_cast<CpuCas01*>(sg_host_by_name(elm)->p_cpu);
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
index 6f77ebf..d6a976b 100644 (file)
@@ -502,7 +502,7 @@ void CpuTiModel::addTraces()
 /* connect all traces relative to hosts */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
 /* connect all traces relative to hosts */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuTi *cpu = static_cast<CpuTi*>(sg_host_surfcpu(sg_host_by_name(elm)));
+    CpuTi *cpu = static_cast<CpuTi*>(sg_host_by_name(elm)->p_cpu);
 
     xbt_assert(cpu, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     xbt_assert(cpu, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
@@ -518,7 +518,7 @@ void CpuTiModel::addTraces()
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuTi *cpu = static_cast<CpuTi*>(sg_host_surfcpu(sg_host_by_name(elm)));
+    CpuTi *cpu = static_cast<CpuTi*>(sg_host_by_name(elm)->p_cpu);
 
     xbt_assert(cpu, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     xbt_assert(cpu, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
index 23495da..6f3675a 100644 (file)
@@ -249,7 +249,7 @@ L07Action::L07Action(Model *model, int host_nb,
 
   for (int i = 0; i < host_nb; i++)
     lmm_expand(model->getMaxminSystem(),
 
   for (int i = 0; i < host_nb; i++)
     lmm_expand(model->getMaxminSystem(),
-              sg_host_surfcpu(host_list[i])->getConstraint(),
+              host_list[i]->p_cpu->getConstraint(),
                this->getVariable(), flops_amount[i]);
 
   for (int i = 0; i < host_nb; i++) {
                this->getVariable(), flops_amount[i]);
 
   for (int i = 0; i < host_nb; i++) {
@@ -341,7 +341,7 @@ void HostL07Model::addTraces()
   /* Connect traces relative to cpu */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
   /* Connect traces relative to cpu */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuL07 *host = static_cast<CpuL07*>(sg_host_surfcpu(sg_host_by_name(elm)));
+    CpuL07 *host = static_cast<CpuL07*>(sg_host_by_name(elm)->p_cpu);
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
@@ -351,7 +351,7 @@ void HostL07Model::addTraces()
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuL07 *host = static_cast<CpuL07*>(sg_host_surfcpu(sg_host_by_name(elm)));
+    CpuL07 *host = static_cast<CpuL07*>(sg_host_by_name(elm)->p_cpu);
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
index 80ad4c2..e557df9 100644 (file)
@@ -260,15 +260,15 @@ xbt_dict_t sg_host_get_properties(sg_host_t host) {
 }
 
 double surf_host_get_speed(sg_host_t host, double load){
 }
 
 double surf_host_get_speed(sg_host_t host, double load){
-  return sg_host_surfcpu(host)->getSpeed(load);
+  return host->p_cpu->getSpeed(load);
 }
 
 double surf_host_get_available_speed(sg_host_t host){
 }
 
 double surf_host_get_available_speed(sg_host_t host){
-  return sg_host_surfcpu(host)->getAvailableSpeed();
+  return host->p_cpu->getAvailableSpeed();
 }
 
 int surf_host_get_core(sg_host_t host){
 }
 
 int surf_host_get_core(sg_host_t host){
-  return sg_host_surfcpu(host)->getCore();
+  return host->p_cpu->getCore();
 }
 
 surf_action_t surf_host_execute(sg_host_t host, double size){
 }
 
 surf_action_t surf_host_execute(sg_host_t host, double size){
@@ -276,22 +276,22 @@ surf_action_t surf_host_execute(sg_host_t host, double size){
 }
 
 double surf_host_get_current_power_peak(sg_host_t host){
 }
 
 double surf_host_get_current_power_peak(sg_host_t host){
-  return sg_host_surfcpu(host)->getCurrentPowerPeak();
+  return host->p_cpu->getCurrentPowerPeak();
 }
 
 double surf_host_get_power_peak_at(sg_host_t host, int pstate_index){
 }
 
 double surf_host_get_power_peak_at(sg_host_t host, int pstate_index){
-  return sg_host_surfcpu(host)->getPowerPeakAt(pstate_index);
+  return host->p_cpu->getPowerPeakAt(pstate_index);
 }
 
 int surf_host_get_nb_pstates(sg_host_t host){
 }
 
 int surf_host_get_nb_pstates(sg_host_t host){
-  return sg_host_surfcpu(host)->getNbPStates();
+  return host->p_cpu->getNbPStates();
 }
 
 void surf_host_set_pstate(sg_host_t host, int pstate_index){
 }
 
 void surf_host_set_pstate(sg_host_t host, int pstate_index){
-       sg_host_surfcpu(host)->setPState(pstate_index);
+  host->p_cpu->setPState(pstate_index);
 }
 int surf_host_get_pstate(sg_host_t host){
 }
 int surf_host_get_pstate(sg_host_t host){
-  return sg_host_surfcpu(host)->getPState();
+  return host->p_cpu->getPState();
 }
 
 using simgrid::energy::HostEnergy;
 }
 
 using simgrid::energy::HostEnergy;
@@ -392,7 +392,7 @@ void surf_vm_destroy(sg_host_t resource){
    * Do not call xbt_lib_remove() here. It deletes all levels of the key,
    * including MSG_HOST_LEVEL and others. We should unregister only what we know.
    */
    * Do not call xbt_lib_remove() here. It deletes all levels of the key,
    * including MSG_HOST_LEVEL and others. We should unregister only what we know.
    */
-  sg_host_surfcpu_destroy(resource);
+  resource->p_cpu = nullptr; // FIXME: memleaking?
   sg_host_edge_destroy(resource,1);
   resource->extension_set<simgrid::surf::Host>(nullptr);
 
   sg_host_edge_destroy(resource,1);
   resource->extension_set<simgrid::surf::Host>(nullptr);
 
@@ -428,8 +428,8 @@ void surf_vm_set_bound(sg_host_t vm, double bound){
   return get_casted_vm(vm)->setBound(bound);
 }
 
   return get_casted_vm(vm)->setBound(bound);
 }
 
-void surf_vm_set_affinity(sg_host_t vm, sg_host_t cpu, unsigned long mask){
-  return get_casted_vm(vm)->setAffinity(sg_host_surfcpu(cpu), mask);
+void surf_vm_set_affinity(sg_host_t vm, sg_host_t host, unsigned long mask){
+  return get_casted_vm(vm)->setAffinity(host->p_cpu, mask);
 }
 
 xbt_dict_t surf_storage_get_content(surf_resource_t resource){
 }
 
 xbt_dict_t surf_storage_get_content(surf_resource_t resource){
@@ -456,12 +456,14 @@ const char* surf_storage_get_host(surf_resource_t resource){
   return static_cast<simgrid::surf::Storage*>(surf_storage_resource_priv(resource))->p_attach;
 }
 
   return static_cast<simgrid::surf::Storage*>(surf_storage_resource_priv(resource))->p_attach;
 }
 
-surf_action_t surf_cpu_execute(sg_host_t cpu, double size){
-  return sg_host_surfcpu(cpu)->execute(size);
+surf_action_t surf_cpu_execute(sg_host_t host, double size){
+       xbt_die("FIXME: DEADCODE");
+  return host->p_cpu->execute(size);
 }
 
 surf_action_t surf_cpu_sleep(sg_host_t host, double duration){
 }
 
 surf_action_t surf_cpu_sleep(sg_host_t host, double duration){
-  return sg_host_surfcpu(host)->sleep(duration);
+       xbt_die("FIXME: DEADCODE");
+  return host->p_cpu->sleep(duration);
 }
 
 double surf_action_get_start_time(surf_action_t action){
 }
 
 double surf_action_get_start_time(surf_action_t action){
@@ -516,8 +518,8 @@ double surf_action_get_cost(surf_action_t action){
   return action->getCost();
 }
 
   return action->getCost();
 }
 
-void surf_cpu_action_set_affinity(surf_action_t action, sg_host_t cpu, unsigned long mask) {
-  static_cast<simgrid::surf::CpuAction*>(action)->setAffinity(sg_host_surfcpu(cpu), mask);
+void surf_cpu_action_set_affinity(surf_action_t action, sg_host_t host, unsigned long mask) {
+  static_cast<simgrid::surf::CpuAction*>(action)->setAffinity(host->p_cpu, mask);
 }
 
 void surf_cpu_action_set_bound(surf_action_t action, double bound) {
 }
 
 void surf_cpu_action_set_bound(surf_action_t action, double bound) {
index e7b9a42..cf79554 100644 (file)
@@ -184,7 +184,7 @@ VMHL13::VMHL13(VMModel *model, const char* name, xbt_dict_t props, sg_host_t hos
 
   // //// CPU  RELATED STUFF ////
   // Roughly, create a vcpu resource by using the values of the sub_cpu one.
 
   // //// CPU  RELATED STUFF ////
   // Roughly, create a vcpu resource by using the values of the sub_cpu one.
-  CpuCas01 *sub_cpu = static_cast<CpuCas01*>(sg_host_surfcpu(host_PM));
+  CpuCas01 *sub_cpu = static_cast<CpuCas01*>(host_PM->p_cpu);
 
   p_cpu = surf_cpu_model_vm->createCpu(host, // the machine hosting the VM
       sub_cpu->getSpeedPeakList(),        // host->power_peak,
 
   p_cpu = surf_cpu_model_vm->createCpu(host, // the machine hosting the VM
       sub_cpu->getSpeedPeakList(),        // host->power_peak,
@@ -293,8 +293,7 @@ void VMHL13::migrate(sg_host_t host_dest)
    /* Update vcpu's action for the new pm */
    {
      /* create a cpu action bound to the pm model at the destination. */
    /* Update vcpu's action for the new pm */
    {
      /* create a cpu action bound to the pm model at the destination. */
-     CpuAction *new_cpu_action = static_cast<CpuAction*>(
-                                           static_cast<Cpu*>(sg_host_surfcpu(host_dest))->execute(0));
+     CpuAction *new_cpu_action = static_cast<CpuAction*>(host_dest->p_cpu->execute(0));
 
      e_surf_action_state_t state = p_action->getState();
      if (state != SURF_ACTION_DONE)
 
      e_surf_action_state_t state = p_action->getState();
      if (state != SURF_ACTION_DONE)
index 43a48bd..a066102 100644 (file)
@@ -1,7 +1,7 @@
 set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}")
 
 set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}")
 
-add_executable(surf_usage ${CMAKE_HOME_DIRECTORY}/teshsuite/surf/surf_usage/surf_usage.c)
-add_executable(surf_usage2 ${CMAKE_HOME_DIRECTORY}/teshsuite/surf/surf_usage/surf_usage2.c)
+add_executable(surf_usage ${CMAKE_HOME_DIRECTORY}/teshsuite/surf/surf_usage/surf_usage.cpp)
+add_executable(surf_usage2 ${CMAKE_HOME_DIRECTORY}/teshsuite/surf/surf_usage/surf_usage2.cpp)
 
 ### Add definitions for compile
 if(NOT WIN32)
 
 ### Add definitions for compile
 if(NOT WIN32)
@@ -23,8 +23,8 @@ set(xml_files
   )
 set(testsuite_src
   ${testsuite_src}
   )
 set(testsuite_src
   ${testsuite_src}
-  ${CMAKE_CURRENT_SOURCE_DIR}/surf_usage.c
-  ${CMAKE_CURRENT_SOURCE_DIR}/surf_usage2.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/surf_usage.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/surf_usage2.cpp
   PARENT_SCOPE
   )
 set(bin_files
   PARENT_SCOPE
   )
 set(bin_files
similarity index 89%
rename from teshsuite/surf/surf_usage/surf_usage.c
rename to teshsuite/surf/surf_usage/surf_usage.cpp
index 24285da..fe6b1d4 100644 (file)
@@ -37,8 +37,8 @@ const char *string_action(e_surf_action_state_t state)
 void test(char *platform);
 void test(char *platform)
 {
 void test(char *platform);
 void test(char *platform)
 {
-  sg_host_t cpuA = NULL;
-  sg_host_t cpuB = NULL;
+  sg_host_t hostA = NULL;
+  sg_host_t hostB = NULL;
   surf_action_t actionA = NULL;
   surf_action_t actionB = NULL;
   surf_action_t actionC = NULL;
   surf_action_t actionA = NULL;
   surf_action_t actionB = NULL;
   surf_action_t actionC = NULL;
@@ -52,17 +52,17 @@ void test(char *platform)
 
   /*********************** CPU ***********************************/
   XBT_DEBUG("%p", surf_cpu_model_pm);
 
   /*********************** CPU ***********************************/
   XBT_DEBUG("%p", surf_cpu_model_pm);
-  cpuA = sg_host_by_name("Cpu A");
-  cpuB = sg_host_by_name("Cpu B");
+  hostA = sg_host_by_name("Cpu A");
+  hostB = sg_host_by_name("Cpu B");
 
   /* Let's check that those two processors exist */
 
   /* Let's check that those two processors exist */
-  XBT_DEBUG("%s : %p", surf_cpu_name(sg_host_surfcpu(cpuA)), cpuA);
-  XBT_DEBUG("%s : %p", surf_cpu_name(sg_host_surfcpu(cpuB)), cpuB);
+  XBT_DEBUG("%s : %p", surf_cpu_name(hostA->p_cpu), hostA);
+  XBT_DEBUG("%s : %p", surf_cpu_name(hostB->p_cpu), hostB);
 
   /* Let's do something on it */
 
   /* Let's do something on it */
-  actionA = surf_cpu_execute(cpuA, 1000.0);
-  actionB = surf_cpu_execute(cpuB, 1000.0);
-  actionC = surf_cpu_sleep(cpuB, 7.32);
+  actionA = surf_host_execute(hostA, 1000.0);
+  actionB = surf_host_execute(hostB, 1000.0);
+  actionC = surf_host_sleep(hostB, 7.32);
 
   /* Use whatever calling style you want... */
   stateActionA = surf_action_get_state(actionA);     /* When you know actionA model type */
 
   /* Use whatever calling style you want... */
   stateActionA = surf_action_get_state(actionA);     /* When you know actionA model type */
@@ -78,7 +78,7 @@ void test(char *platform)
   XBT_DEBUG("%p", surf_network_model);
 
   /* Let's do something on it */
   XBT_DEBUG("%p", surf_network_model);
 
   /* Let's do something on it */
-  surf_network_model_communicate(surf_network_model, cpuA, cpuB, 150.0, -1.0);
+  surf_network_model_communicate(surf_network_model, hostA, hostB, 150.0, -1.0);
 
   surf_solve(-1.0);                 /* Takes traces into account. Returns 0.0 */
   do {
 
   surf_solve(-1.0);                 /* Takes traces into account. Returns 0.0 */
   do {