Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move some content of surf_interface to a new math_utils.h
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sat, 18 Feb 2023 18:28:37 +0000 (19:28 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sat, 18 Feb 2023 18:34:59 +0000 (19:34 +0100)
32 files changed:
MANIFEST.in
src/include/simgrid/math_utils.h [new file with mode: 0644]
src/kernel/EngineImpl.cpp
src/kernel/actor/ActorImpl.cpp
src/kernel/lmm/System.cpp
src/kernel/lmm/System.hpp
src/kernel/lmm/bmf.cpp
src/kernel/lmm/bmf.hpp
src/kernel/lmm/bmf_test.cpp
src/kernel/lmm/fair_bottleneck.cpp
src/kernel/lmm/maxmin.cpp
src/kernel/lmm/maxmin_test.cpp
src/kernel/resource/Action.cpp
src/kernel/resource/CpuImpl.cpp
src/kernel/resource/VirtualMachineImpl.cpp
src/kernel/resource/models/cpu_cas01.cpp
src/kernel/resource/models/cpu_ti.cpp
src/kernel/resource/models/disk_s19.cpp
src/kernel/resource/models/host_clm03.cpp
src/kernel/resource/models/network_cm02.cpp
src/kernel/resource/models/network_constant.cpp
src/kernel/resource/models/network_ib.cpp
src/kernel/resource/models/network_ns3.cpp
src/kernel/resource/models/ptask_L07.cpp
src/kernel/routing/NetZoneImpl.cpp
src/kernel/xml/sg_platf.cpp
src/plugins/host_dvfs.cpp
src/plugins/host_energy.cpp
src/plugins/link_energy_wifi.cpp
src/smpi/internals/smpi_bench.cpp
src/surf/surf_interface.hpp
tools/cmake/DefinePackages.cmake

index 5145675..ca7deaa 100644 (file)
@@ -1969,6 +1969,7 @@ include src/dag/loaders.cpp
 include src/include/catch.hpp
 include src/include/mc/datatypes.h
 include src/include/mc/mc.h
+include src/include/simgrid/math_utils.h
 include src/include/simgrid/sg_config.hpp
 include src/include/xbt/coverage.h
 include src/include/xbt/mmalloc.h
@@ -2127,6 +2128,7 @@ include src/kernel/routing/WifiZone.cpp
 include src/kernel/timer/Timer.cpp
 include src/kernel/xml/platf.hpp
 include src/kernel/xml/platf_private.hpp
+include src/kernel/xml/sg_platf.cpp
 include src/kernel/xml/simgrid.dtd
 include src/kernel/xml/simgrid_dtd.c
 include src/kernel/xml/simgrid_dtd.h
@@ -2442,7 +2444,6 @@ include src/smpi/smpitools.sh
 include src/sthread/sthread.c
 include src/sthread/sthread.h
 include src/sthread/sthread_impl.cpp
-include src/surf/sg_platf.cpp
 include src/surf/surf_interface.hpp
 include src/xbt/OsSemaphore.hpp
 include src/xbt/PropertyHolder.cpp
diff --git a/src/include/simgrid/math_utils.h b/src/include/simgrid/math_utils.h
new file mode 100644 (file)
index 0000000..7978f16
--- /dev/null
@@ -0,0 +1,39 @@
+/* Copyright (c) 2004-2023. The SimGrid Team. All rights reserved.          */
+
+/* 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. */
+
+#ifndef SIMGRID_MATH_UTILS_H_
+#define SIMGRID_MATH_UTILS_H_
+
+#include <xbt/asserts.h>
+#include <xbt/function_types.h>
+
+#include <cfloat>
+#include <math.h>
+
+static inline void double_update(double* variable, double value, double precision)
+{
+  if (false) { // debug
+    fprintf(stderr, "Updating %g -= %g +- %g\n", *variable, value, precision);
+    xbt_assert(value == 0.0 || value > precision);
+    // Check that precision is higher than the machine-dependent size of the mantissa. If not, brutal rounding  may
+    // happen, and the precision mechanism is not active...
+    xbt_assert(FLT_RADIX == 2 && *variable < precision * exp2(DBL_MANT_DIG));
+  }
+  *variable -= value;
+  if (*variable < precision)
+    *variable = 0.0;
+}
+
+static inline int double_positive(double value, double precision)
+{
+  return (value > precision);
+}
+
+static inline int double_equals(double value1, double value2, double precision)
+{
+  return (fabs(value1 - value2) < precision);
+}
+
+#endif /* SURF_MODEL_H_ */
index 3564c35..573b699 100644 (file)
 #include <simgrid/sg_config.hpp>
 
 #include "mc/mc.h"
+#include "simgrid/math_utils.h"
 #include "src/kernel/EngineImpl.hpp"
 #include "src/kernel/resource/StandardLinkImpl.hpp"
 #include "src/kernel/resource/profile/Profile.hpp"
+#include "src/kernel/xml/platf.hpp"
 #include "src/mc/mc_record.hpp"
 #include "src/mc/mc_replay.hpp"
 #include "src/smpi/include/smpi_actor.hpp"
-#include "src/kernel/xml/platf.hpp"
+#include "src/surf/surf_interface.hpp"
 #include "xbt/module.h"
 #include "xbt/xbt_modinter.h" /* whether initialization was already done */
 
index c252e33..4fb6bf5 100644 (file)
@@ -8,7 +8,9 @@
 #include <simgrid/s4u/Actor.hpp>
 #include <simgrid/s4u/Host.hpp>
 
+#include "src/internal_config.h"
 #include "src/kernel/EngineImpl.hpp"
+#include "src/surf/surf_interface.hpp"
 #if HAVE_SMPI
 #include "src/smpi/include/private.hpp"
 #endif
index 6664f3a..3589190 100644 (file)
@@ -3,11 +3,14 @@
 /* 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 "simgrid/math_utils.h"
+#include "src/internal_config.h"
 #include "src/kernel/lmm/fair_bottleneck.hpp"
 #include "src/kernel/lmm/maxmin.hpp"
 #if SIMGRID_HAVE_EIGEN3
 #include "src/kernel/lmm/bmf.hpp"
 #endif
+
 #include <boost/core/demangle.hpp>
 #include <typeinfo>
 
index ab4684b..d83ae01 100644 (file)
@@ -9,7 +9,6 @@
 #include "simgrid/kernel/resource/Action.hpp"
 #include "simgrid/kernel/resource/Model.hpp"
 #include "simgrid/s4u/Link.hpp"
-#include "src/surf/surf_interface.hpp"
 #include "xbt/asserts.h"
 #include "xbt/ex.h"
 #include "xbt/mallocator.h"
 #include <string_view>
 #include <vector>
 
+/* user-visible parameters */
+XBT_PUBLIC_DATA double sg_precision_workamount;
+XBT_PUBLIC_DATA double sg_precision_timing;
+XBT_PUBLIC_DATA int sg_concurrency_limit;
+
 namespace simgrid::kernel::lmm {
 
 /** @addtogroup SURF_lmm
index b46c8c7..c7de003 100644 (file)
@@ -4,6 +4,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "src/kernel/lmm/bmf.hpp"
+#include "simgrid/math_utils.h"
 
 #include <Eigen/LU>
 #include <iostream>
index fbefd2c..3bebff1 100644 (file)
@@ -9,6 +9,8 @@
 #include "src/kernel/lmm/System.hpp"
 #include "xbt/config.hpp"
 
+#include <set>
+
 #ifdef __clang__
 // Ignore deprecation warnings with Eigen < 4.0 (see https://gitlab.com/libeigen/eigen/-/issues/1850)
 #pragma clang diagnostic push
index d260056..f13e83d 100644 (file)
@@ -3,6 +3,7 @@
 /* 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 "simgrid/math_utils.h"
 #include "src/include/catch.hpp"
 #include "src/kernel/lmm/bmf.hpp"
 #include "xbt/log.h"
index cb108db..931a16b 100644 (file)
@@ -4,6 +4,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "src/kernel/lmm/fair_bottleneck.hpp"
+#include "simgrid/math_utils.h"
 #include "xbt/sysdep.h"
 
 #include <algorithm>
index 574bef2..3bae152 100644 (file)
@@ -4,6 +4,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "src/kernel/lmm/maxmin.hpp"
+#include "simgrid/math_utils.h"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ker_lmm);
 
index d1c3a89..6d0c27c 100644 (file)
@@ -3,6 +3,7 @@
 /* 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 "simgrid/math_utils.h"
 #include "src/include/catch.hpp"
 #include "src/kernel/lmm/maxmin.hpp"
 #include "xbt/log.h"
index b74ac09..75294a3 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "simgrid/kernel/resource/Action.hpp"
 #include "simgrid/kernel/resource/Model.hpp"
+#include "simgrid/math_utils.h"
 #include "src/kernel/EngineImpl.hpp"
 #include "src/kernel/lmm/maxmin.hpp"
 
index 73ef40b..77aa7a1 100644 (file)
@@ -4,6 +4,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "src/kernel/resource/CpuImpl.hpp"
+#include "simgrid/math_utils.h"
 #include "src/kernel/resource/models/cpu_ti.hpp"
 #include "src/kernel/resource/profile/Profile.hpp"
 
index 0999e44..224c1bf 100644 (file)
@@ -14,6 +14,7 @@
 #include "src/kernel/resource/VirtualMachineImpl.hpp"
 #include "src/kernel/resource/models/cpu_cas01.hpp"
 #include "src/kernel/resource/models/cpu_ti.hpp"
+#include "src/simgrid/module.hpp"
 
 #include <numeric>
 
index 8c9bd96..cb8a40d 100644 (file)
@@ -11,6 +11,7 @@
 #include "src/kernel/resource/models/cpu_cas01.hpp"
 #include "src/kernel/resource/models/cpu_ti.hpp"
 #include "src/kernel/resource/profile/Event.hpp"
+#include "src/simgrid/module.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(cpu_cas, res_cpu, "CPU resource, CAS01 model (used by default)");
 
index 1dc5eeb..8142ff8 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "cpu_ti.hpp"
 #include "simgrid/kernel/routing/NetZoneImpl.hpp"
+#include "simgrid/math_utils.h"
 #include "simgrid/s4u/Engine.hpp"
 #include "src/kernel/EngineImpl.hpp"
 #include "src/kernel/resource/profile/Event.hpp"
index c88d038..7789d9f 100644 (file)
@@ -13,6 +13,7 @@
 #include "src/kernel/lmm/maxmin.hpp"
 #include "src/kernel/resource/models/disk_s19.hpp"
 #include "src/kernel/resource/profile/Event.hpp"
+#include "src/simgrid/module.hpp"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_disk);
 /***********
index dc3be67..3a44e40 100644 (file)
@@ -11,6 +11,7 @@
 #include "src/kernel/EngineImpl.hpp"
 #include "src/kernel/resource/NetworkModel.hpp"
 #include "src/kernel/resource/models/host_clm03.hpp"
+#include "src/simgrid/module.hpp"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_host);
 
index acae09d..117f661 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "src/kernel/resource/models/network_cm02.hpp"
 #include "simgrid/kernel/routing/NetZoneImpl.hpp"
+#include "simgrid/math_utils.h"
 #include "simgrid/s4u/Engine.hpp"
 #include "simgrid/s4u/Host.hpp"
 #include "simgrid/sg_config.hpp"
@@ -12,6 +13,7 @@
 #include "src/kernel/resource/StandardLinkImpl.hpp"
 #include "src/kernel/resource/WifiLinkImpl.hpp"
 #include "src/kernel/resource/profile/Event.hpp"
+#include "src/simgrid/module.hpp"
 
 #include <algorithm>
 #include <numeric>
index 33c0367..23e7ebc 100644 (file)
@@ -6,8 +6,10 @@
 #include <simgrid/kernel/routing/NetZoneImpl.hpp>
 #include <simgrid/s4u/Engine.hpp>
 
+#include "simgrid/math_utils.h"
 #include "src/kernel/EngineImpl.hpp"
 #include "src/kernel/resource/models/network_constant.hpp"
+#include "src/simgrid/module.hpp"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_network);
 
index 56dabbb..5f90cc5 100644 (file)
@@ -5,24 +5,22 @@
 
 #include <simgrid/kernel/routing/NetPoint.hpp>
 
+#include "simgrid/math_utils.h"
 #include "simgrid/sg_config.hpp"
 #include "src/kernel/EngineImpl.hpp"
 #include "src/kernel/activity/CommImpl.hpp"
 #include "src/kernel/resource/HostImpl.hpp"
 #include "src/kernel/resource/models/network_ib.hpp"
+#include "src/simgrid/module.hpp"
 
 #include <boost/algorithm/string/classification.hpp>
 #include <boost/algorithm/string/split.hpp>
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_network);
 
-/*********
- * Model *
- *********/
-
-/************************************************************************/
-/* New model based on MPI contention model for Infiniband platforms */
-/************************************************************************/
+/****************************************************************/
+/* Model based on MPI contention model for Infiniband platforms */
+/****************************************************************/
 /* @Inproceedings{mescal_vienne_phd, */
 /*  author={Jérôme Vienne}, */
 /*  title={prédiction de performances d’applications de calcul haute performance sur réseau Infiniband}, */
index dfce0f0..6509cee 100644 (file)
@@ -9,6 +9,8 @@
 #include <string>
 #include <unordered_set>
 
+#include "src/include/simgrid/math_utils.h"
+#include "src/simgrid/module.hpp"
 #include "xbt/config.hpp"
 #include "xbt/str.h"
 #include "xbt/string.hpp"
index 54dc3e6..6e3edf4 100644 (file)
@@ -9,7 +9,9 @@
 #include <xbt/config.hpp>
 
 #include "simgrid/config.h"
+#include "simgrid/math_utils.h"
 #include "src/kernel/EngineImpl.hpp"
+#include "src/simgrid/module.hpp"
 #if SIMGRID_HAVE_EIGEN3
 #include "src/kernel/lmm/bmf.hpp"
 #endif
index 51bfe24..cb9ca40 100644 (file)
@@ -18,6 +18,7 @@
 #include "src/kernel/resource/SplitDuplexLinkImpl.hpp"
 #include "src/kernel/resource/StandardLinkImpl.hpp"
 #include "src/kernel/resource/VirtualMachineImpl.hpp"
+#include "src/simgrid/module.hpp"
 #include "xbt/asserts.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_platform, kernel, "Kernel platform-related information");
index 6d3b433..95a9638 100644 (file)
@@ -25,6 +25,7 @@
 #include "src/kernel/resource/profile/Profile.hpp"
 #include "src/kernel/xml/platf.hpp"
 #include "src/kernel/xml/platf_private.hpp"
+#include "src/surf/surf_interface.hpp"
 
 #include <algorithm>
 #include <string>
index c152cc5..f899233 100644 (file)
@@ -14,6 +14,7 @@
 #include "src/internal_config.h" // HAVE_SMPI
 #include "src/kernel/activity/CommImpl.hpp"
 #include "src/kernel/resource/NetworkModel.hpp"
+#include "src/simgrid/module.hpp"
 #if HAVE_SMPI
 #include "src/smpi/include/smpi_request.hpp"
 #include "src/smpi/plugins/ampi/ampi.hpp"
index 422ff2a..2bf95b1 100644 (file)
@@ -12,6 +12,7 @@
 #include <simgrid/simix.hpp>
 
 #include "src/kernel/resource/CpuImpl.hpp"
+#include "src/simgrid/module.hpp"
 
 #include <boost/algorithm/string/classification.hpp>
 #include <boost/algorithm/string/split.hpp>
index be74ee6..481f1f2 100644 (file)
@@ -10,6 +10,7 @@
 #include "src/kernel/activity/CommImpl.hpp"
 #include "src/kernel/resource/StandardLinkImpl.hpp"
 #include "src/kernel/resource/WifiLinkImpl.hpp"
+#include "src/simgrid/module.hpp"
 
 #include <boost/algorithm/string/classification.hpp>
 #include <boost/algorithm/string/split.hpp>
index 794fa3e..82752a6 100644 (file)
@@ -12,8 +12,8 @@
 #include "smpi_comm.hpp"
 #include "smpi_utils.hpp"
 #include "src/internal_config.h"
+#include "src/kernel/lmm/System.hpp" // sg_precision_timing
 #include "src/mc/mc_replay.hpp"
-#include "src/surf/surf_interface.hpp" // sg_precision_timing
 #include "xbt/config.hpp"
 #include "xbt/file.hpp"
 
index c9a23e9..45944a4 100644 (file)
@@ -6,29 +6,10 @@
 #ifndef SURF_MODEL_H_
 #define SURF_MODEL_H_
 
-#include "src/simgrid/module.hpp"
-#include <xbt/asserts.h>
-#include <xbt/function_types.h>
-
-#include "src/internal_config.h"
 #include "src/kernel/resource/profile/Profile.hpp"
 
-#include <cfloat>
-#include <cmath>
-#include <functional>
 #include <set>
 #include <string>
-#include <unordered_map>
-#include <vector>
-
-/*********
- * Utils *
- *********/
-
-/* user-visible parameters */
-XBT_PUBLIC_DATA double sg_precision_workamount;
-XBT_PUBLIC_DATA double sg_precision_timing;
-XBT_PUBLIC_DATA int sg_concurrency_limit;
 
 extern XBT_PRIVATE std::unordered_map<std::string, simgrid::kernel::profile::Profile*> traces_set_list;
 
@@ -38,29 +19,4 @@ inline auto& watched_hosts() // avoid static initialization order fiasco
   static std::set<std::string, std::less<>> value;
   return value;
 }
-
-static inline void double_update(double* variable, double value, double precision)
-{
-  if (false) { // debug
-    fprintf(stderr, "Updating %g -= %g +- %g\n", *variable, value, precision);
-    xbt_assert(value == 0.0 || value > precision);
-    // Check that precision is higher than the machine-dependent size of the mantissa. If not, brutal rounding  may
-    // happen, and the precision mechanism is not active...
-    xbt_assert(FLT_RADIX == 2 && *variable < precision * exp2(DBL_MANT_DIG));
-  }
-  *variable -= value;
-  if (*variable < precision)
-    *variable = 0.0;
-}
-
-static inline int double_positive(double value, double precision)
-{
-  return (value > precision);
-}
-
-static inline int double_equals(double value1, double value2, double precision)
-{
-  return (fabs(value1 - value2) < precision);
-}
-
 #endif /* SURF_MODEL_H_ */
index 410426e..78cb9a4 100644 (file)
@@ -9,6 +9,7 @@ set(EXTRA_DIST
   src/include/mc/datatypes.h
   src/include/mc/mc.h
   src/include/simgrid/sg_config.hpp
+  src/include/simgrid/math_utils.h
   src/include/xbt/coverage.h
   src/include/xbt/mmalloc.h
   src/include/xbt/parmap.hpp