Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[surf] Move some code in a simgrid::surf namespace
[simgrid.git] / src / surf / network_cm02.cpp
index ff820b2..2002616 100644 (file)
@@ -4,6 +4,8 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include <algorithm>
+
 #include "network_cm02.hpp"
 #include "maxmin_private.hpp"
 #include "simgrid/sg_config.h"
@@ -52,9 +54,9 @@ void surf_network_model_init_LegrandVelho(void)
   if (surf_network_model)
     return;
 
-  surf_network_model = new NetworkCm02Model();
+  surf_network_model = new simgrid::surf::NetworkCm02Model();
   net_define_callbacks();
-  Model *model = surf_network_model;
+  simgrid::surf::Model *model = surf_network_model;
   xbt_dynar_push(all_existing_models, &model);
 
   xbt_cfg_setdefault_double(_sg_cfg_set, "network/latency_factor",
@@ -81,9 +83,9 @@ void surf_network_model_init_CM02(void)
   if (surf_network_model)
     return;
 
-  surf_network_model = new NetworkCm02Model();
+  surf_network_model = new simgrid::surf::NetworkCm02Model();
   net_define_callbacks();
-  Model *model = surf_network_model;
+  simgrid::surf::Model *model = surf_network_model;
   xbt_dynar_push(all_existing_models, &model);
 
   xbt_cfg_setdefault_double(_sg_cfg_set, "network/latency_factor", 1.0);
@@ -107,9 +109,9 @@ void surf_network_model_init_Reno(void)
   if (surf_network_model)
     return;
 
-  surf_network_model = new NetworkCm02Model();
+  surf_network_model = new simgrid::surf::NetworkCm02Model();
   net_define_callbacks();
-  Model *model = surf_network_model;
+  simgrid::surf::Model *model = surf_network_model;
   xbt_dynar_push(all_existing_models, &model);
   lmm_set_default_protocol_function(func_reno_f, func_reno_fp,
                                     func_reno_fpi);
@@ -127,9 +129,9 @@ void surf_network_model_init_Reno2(void)
   if (surf_network_model)
     return;
 
-  surf_network_model = new NetworkCm02Model();
+  surf_network_model = new simgrid::surf::NetworkCm02Model();
   net_define_callbacks();
-  Model *model = surf_network_model;
+  simgrid::surf::Model *model = surf_network_model;
   xbt_dynar_push(all_existing_models, &model);
   lmm_set_default_protocol_function(func_reno2_f, func_reno2_fp,
                                     func_reno2_fpi);
@@ -147,9 +149,9 @@ void surf_network_model_init_Vegas(void)
   if (surf_network_model)
     return;
 
-  surf_network_model = new NetworkCm02Model();
+  surf_network_model = new simgrid::surf::NetworkCm02Model();
   net_define_callbacks();
-  Model *model = surf_network_model;
+  simgrid::surf::Model *model = surf_network_model;
   xbt_dynar_push(all_existing_models, &model);
   lmm_set_default_protocol_function(func_vegas_f, func_vegas_fp,
                                     func_vegas_fpi);
@@ -161,6 +163,9 @@ void surf_network_model_init_Vegas(void)
   xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S", 8775);
 }
 
+namespace simgrid {
+namespace surf {
+
 NetworkCm02Model::NetworkCm02Model()
        :NetworkModel()
 {
@@ -406,7 +411,7 @@ Action *NetworkCm02Model::communicate(RoutingEdge *src, RoutingEdge *dst,
        link = static_cast<NetworkCm02Link*>(_link);
     double bb = bandwidthFactor(size) * link->getBandwidth();
     bandwidth_bound =
-        (bandwidth_bound < 0.0) ? bb : min(bandwidth_bound, bb);
+        (bandwidth_bound < 0.0) ? bb : std::min(bandwidth_bound, bb);
   }
 
   action->m_latCurrent = action->m_latency;
@@ -442,7 +447,7 @@ Action *NetworkCm02Model::communicate(RoutingEdge *src, RoutingEdge *dst,
   if (action->m_rate < 0) {
     lmm_update_variable_bound(p_maxminSystem, action->getVariable(), (action->m_latCurrent > 0) ? sg_tcp_gamma / (2.0 * action->m_latCurrent) : -1.0);
   } else {
-    lmm_update_variable_bound(p_maxminSystem, action->getVariable(), (action->m_latCurrent > 0) ? min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent)) : action->m_rate);
+    lmm_update_variable_bound(p_maxminSystem, action->getVariable(), (action->m_latCurrent > 0) ? std::min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent)) : action->m_rate);
   }
 
   xbt_dynar_foreach(route, i, _link) {
@@ -640,7 +645,7 @@ void NetworkCm02Link::updateLatency(double value, double date){
       lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(), sg_tcp_gamma / (2.0 * action->m_latCurrent));
     else {
       lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(),
-                                min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent)));
+                                std::min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent)));
 
       if (action->m_rate < sg_tcp_gamma / (2.0 * action->m_latCurrent)) {
         XBT_INFO("Flow is limited BYBANDWIDTH");
@@ -693,3 +698,5 @@ void NetworkCm02Action::updateRemainingLazy(double now)
   m_lastValue = lmm_variable_getvalue(getVariable());
 }
 
+}
+}