Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add a solve() fun pointer to maxmin datatype (+minor cleanups)
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 2 Oct 2016 15:39:34 +0000 (17:39 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 2 Oct 2016 15:39:34 +0000 (17:39 +0200)
14 files changed:
src/smpi/smpi_bench.cpp
src/surf/cpu_interface.cpp
src/surf/cpu_interface.hpp
src/surf/maxmin.cpp
src/surf/maxmin_private.hpp
src/surf/network_cm02.cpp
src/surf/network_cm02.hpp
src/surf/network_interface.cpp
src/surf/network_ns3.cpp
src/surf/ptask_L07.cpp
src/surf/storage_interface.hpp
src/surf/storage_n11.cpp
src/surf/surf_interface.cpp
src/surf/surf_interface.hpp

index 2b0a99e..21671c6 100644 (file)
@@ -207,9 +207,8 @@ void smpi_execute_(double *duration)
 }
 
 void smpi_execute_flops(double flops) {
-  smx_activity_t action;
   XBT_DEBUG("Handle real computation time: %f flops", flops);
-  action = simcall_execution_start("computation", flops, 1, 0);
+  smx_activity_t action = simcall_execution_start("computation", flops, 1, 0);
   simcall_set_category (action, TRACE_internal_smpi_get_category());
   simcall_execution_wait(action);
   smpi_switch_data_segment(smpi_process_index());
@@ -225,6 +224,7 @@ void smpi_execute(double duration)
     extra->type=TRACING_COMPUTING;
     extra->comp_size=flops;
     TRACE_smpi_computing_in(rank, extra);
+
     smpi_execute_flops(flops);
 
     TRACE_smpi_computing_out(rank);
index 9f8e4bf..08cd7c4 100644 (file)
@@ -107,11 +107,6 @@ void CpuModel::updateActionsStateFull(double now, double delta)
   }
 }
 
-bool CpuModel::next_occuring_event_isIdempotent()
-{
-  return true;
-}
-
 /************
  * Resource *
  ************/
index 790e61c..22317b5 100644 (file)
@@ -51,7 +51,7 @@ public:
 
   void updateActionsStateLazy(double now, double delta) override;
   void updateActionsStateFull(double now, double delta) override;
-  bool next_occuring_event_isIdempotent() override;
+  bool next_occuring_event_isIdempotent() {return true;};
 };
 
 /************
index a96e470..563a062 100644 (file)
@@ -102,6 +102,8 @@ lmm_system_t lmm_system_new(int selective_update)
                                               lmm_variable_mallocator_free_f,
                                               lmm_variable_mallocator_reset_f);
 
+  l->solve_fun = &lmm_solve;
+
   return l;
 }
 
index 5edd925..740b2c1 100644 (file)
@@ -121,6 +121,8 @@ typedef struct lmm_system {
   simgrid::surf::ActionLmmListPtr keep_track;
 
   xbt_mallocator_t variable_mallocator;
+
+  void (*solve_fun)(lmm_system_t self);
 } s_lmm_system_t;
 
 #define extract_variable(sys) xbt_swag_extract(&(sys->variable_set))
index 799a17c..d9057a4 100644 (file)
@@ -88,11 +88,10 @@ void surf_network_model_init_Reno()
   if (surf_network_model)
     return;
 
-  surf_network_model = new simgrid::surf::NetworkCm02Model();
+  surf_network_model = new simgrid::surf::NetworkCm02Model(lagrange_solve);
   all_existing_models->push_back(surf_network_model);
 
   lmm_set_default_protocol_function(func_reno_f, func_reno_fp, func_reno_fpi);
-  surf_network_model->f_networkSolve = lagrange_solve;
 
   xbt_cfg_setdefault_double("network/latency-factor",     10.4);
   xbt_cfg_setdefault_double("network/bandwidth-factor",    0.92);
@@ -105,11 +104,10 @@ void surf_network_model_init_Reno2()
   if (surf_network_model)
     return;
 
-  surf_network_model = new simgrid::surf::NetworkCm02Model();
+  surf_network_model = new simgrid::surf::NetworkCm02Model(lagrange_solve);
   all_existing_models->push_back(surf_network_model);
 
   lmm_set_default_protocol_function(func_reno2_f, func_reno2_fp, func_reno2_fpi);
-  surf_network_model->f_networkSolve = lagrange_solve;
 
   xbt_cfg_setdefault_double("network/latency-factor",    10.4);
   xbt_cfg_setdefault_double("network/bandwidth-factor",   0.92);
@@ -121,11 +119,10 @@ void surf_network_model_init_Vegas()
   if (surf_network_model)
     return;
 
-  surf_network_model = new simgrid::surf::NetworkCm02Model();
+  surf_network_model = new simgrid::surf::NetworkCm02Model(lagrange_solve);
   all_existing_models->push_back(surf_network_model);
 
   lmm_set_default_protocol_function(func_vegas_f, func_vegas_fp, func_vegas_fpi);
-  surf_network_model->f_networkSolve = lagrange_solve;
 
   xbt_cfg_setdefault_double("network/latency-factor",    10.4);
   xbt_cfg_setdefault_double("network/bandwidth-factor",   0.92);
@@ -165,6 +162,12 @@ NetworkCm02Model::NetworkCm02Model()
     maxminSystem_->keep_track = modifiedSet_;
   }
 }
+NetworkCm02Model::NetworkCm02Model(void (*specificSolveFun)(lmm_system_t self))
+  : NetworkCm02Model()
+{
+  maxminSystem_->solve_fun = specificSolveFun;
+}
+
 
 NetworkCm02Model::~NetworkCm02Model() {}
 
index 230c735..4a97f34 100644 (file)
@@ -39,6 +39,7 @@ namespace simgrid {
     class NetworkCm02Model : public NetworkModel {
     public:
       NetworkCm02Model();
+      NetworkCm02Model(void (*solve_fun)(lmm_system_t self));
       ~NetworkCm02Model();
       Link* createLink(const char *name, double bandwidth,  double latency, e_surf_link_sharing_policy_t policy,
           xbt_dict_t properties) override;
index 038b535..506c345 100644 (file)
@@ -132,7 +132,7 @@ namespace simgrid {
     double NetworkModel::next_occuring_event_full(double now)
     {
       ActionList *runningActions = surf_network_model->getRunningActionSet();
-      double minRes = shareResourcesMaxMin(runningActions, maxminSystem_, f_networkSolve);
+      double minRes = shareResourcesMaxMin(runningActions, maxminSystem_);
 
       for(auto it(runningActions->begin()), itend(runningActions->end()); it != itend ; ++it) {
         NetworkAction *action = static_cast<NetworkAction*>(&*it);
index ab8df9a..14cea53 100644 (file)
@@ -267,7 +267,7 @@ double NetworkNS3Model::next_occuring_event(double now)
   else
     do {
       ns3_simulator(now);
-      time_to_next_flow_completion = ns3::Simulator::Now().GetSeconds() - surf_get_clock();//FIXME: use now instead ?
+      time_to_next_flow_completion = ns3::Simulator::Now().GetSeconds() - surf_get_clock();
     } while(double_equals(time_to_next_flow_completion, 0, sg_surf_precision));
 
   XBT_DEBUG("min       : %f", now);
index 6fed9f2..a5116da 100644 (file)
@@ -36,6 +36,7 @@ namespace surf {
 
 HostL07Model::HostL07Model() : HostModel() {
   maxminSystem_ = lmm_system_new(1);
+  maxminSystem_->solve_fun = &bottleneck_solve;
   surf_network_model = new NetworkL07Model(this,maxminSystem_);
   surf_cpu_model_pm = new CpuL07Model(this,maxminSystem_);
 
@@ -74,7 +75,7 @@ NetworkL07Model::~NetworkL07Model()
 double HostL07Model::next_occuring_event(double /*now*/)
 {
   ActionList *runningActions = getRunningActionSet();
-  double min = shareResourcesMaxMin(runningActions, maxminSystem_, bottleneck_solve);
+  double min = shareResourcesMaxMin(runningActions, maxminSystem_);
 
   for (auto it(runningActions->begin()), itend(runningActions->end()); it != itend ; ++it) {
     L07Action *action = static_cast<L07Action*>(&*it);
index 0fcfd2b..46cbf19 100644 (file)
@@ -64,16 +64,6 @@ public:
   StorageModel();
   ~StorageModel();
 
-  /** @brief Create a Storage
-   *
-   * @param id [description]
-   * @param type_id [description]
-   * @param content_name [description]
-   * @param content_type [description]
-   * @param properties [description]
-   * @param attach [description]
-   * @return The created Storage
-   */
   virtual Storage *createStorage(const char* id, const char* type_id,
                                  const char* content_name, const char* content_type,
                                  xbt_dict_t properties, const char *attach) = 0;
index 2894740..5c262ba 100644 (file)
@@ -114,7 +114,7 @@ double StorageN11Model::next_occuring_event(double /*now*/)
 {
   XBT_DEBUG("storage_share_resources");
 
-  double min_completion = shareResourcesMaxMin(getRunningActionSet(), maxminSystem_, lmm_solve);
+  double min_completion = shareResourcesMaxMin(getRunningActionSet(), maxminSystem_);
 
   // Foreach disk
   for(auto storage: p_storageList) {
index 6a9c6b0..0edd2a6 100644 (file)
@@ -472,12 +472,12 @@ double Model::next_occuring_event_lazy(double now)
 }
 
 double Model::next_occuring_event_full(double /*now*/) {
-  return shareResourcesMaxMin(getRunningActionSet(), maxminSystem_, lmm_solve);
+  return shareResourcesMaxMin(getRunningActionSet(), maxminSystem_);
 }
 
-double shareResourcesMaxMin(ActionList *runningActions, lmm_system_t sys, void (*solve) (lmm_system_t))
+double shareResourcesMaxMin(ActionList *runningActions, lmm_system_t sys)
 {
-  solve(sys);
+  sys->solve_fun(sys);
 
   double min = -1;
   for(auto it(runningActions->begin()), itend(runningActions->end()); it != itend ; ++it) {
index c397b6b..3fda8ac 100644 (file)
@@ -281,7 +281,7 @@ typedef ActionLmmList* ActionLmmListPtr;
  * Helper functions *
  ********************/
 
-double shareResourcesMaxMin(ActionList* runningActions, lmm_system_t sys, void (*solve) (lmm_system_t));
+double shareResourcesMaxMin(ActionList* runningActions, lmm_system_t sys);
 
 
 /*********