From: Martin Quinson Date: Sat, 18 Feb 2023 18:28:37 +0000 (+0100) Subject: Move some content of surf_interface to a new math_utils.h X-Git-Tag: v3.34~500 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/8e70d54a095cd7779a53c7a164f775f7a37b29e5 Move some content of surf_interface to a new math_utils.h --- diff --git a/MANIFEST.in b/MANIFEST.in index 51456755b5..ca7deaa6ec 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -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 index 0000000000..7978f16267 --- /dev/null +++ b/src/include/simgrid/math_utils.h @@ -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 +#include + +#include +#include + +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_ */ diff --git a/src/kernel/EngineImpl.cpp b/src/kernel/EngineImpl.cpp index 3564c35802..573b6994ed 100644 --- a/src/kernel/EngineImpl.cpp +++ b/src/kernel/EngineImpl.cpp @@ -11,13 +11,15 @@ #include #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 */ diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index c252e33cf3..4fb6bf5415 100644 --- a/src/kernel/actor/ActorImpl.cpp +++ b/src/kernel/actor/ActorImpl.cpp @@ -8,7 +8,9 @@ #include #include +#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 diff --git a/src/kernel/lmm/System.cpp b/src/kernel/lmm/System.cpp index 6664f3a385..3589190d08 100644 --- a/src/kernel/lmm/System.cpp +++ b/src/kernel/lmm/System.cpp @@ -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 #include diff --git a/src/kernel/lmm/System.hpp b/src/kernel/lmm/System.hpp index ab4684b837..d83ae01bad 100644 --- a/src/kernel/lmm/System.hpp +++ b/src/kernel/lmm/System.hpp @@ -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" @@ -21,6 +20,11 @@ #include #include +/* 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 diff --git a/src/kernel/lmm/bmf.cpp b/src/kernel/lmm/bmf.cpp index b46c8c741e..c7de003b3d 100644 --- a/src/kernel/lmm/bmf.cpp +++ b/src/kernel/lmm/bmf.cpp @@ -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 #include diff --git a/src/kernel/lmm/bmf.hpp b/src/kernel/lmm/bmf.hpp index fbefd2c511..3bebff17d9 100644 --- a/src/kernel/lmm/bmf.hpp +++ b/src/kernel/lmm/bmf.hpp @@ -9,6 +9,8 @@ #include "src/kernel/lmm/System.hpp" #include "xbt/config.hpp" +#include + #ifdef __clang__ // Ignore deprecation warnings with Eigen < 4.0 (see https://gitlab.com/libeigen/eigen/-/issues/1850) #pragma clang diagnostic push diff --git a/src/kernel/lmm/bmf_test.cpp b/src/kernel/lmm/bmf_test.cpp index d2600565f9..f13e83da62 100644 --- a/src/kernel/lmm/bmf_test.cpp +++ b/src/kernel/lmm/bmf_test.cpp @@ -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" diff --git a/src/kernel/lmm/fair_bottleneck.cpp b/src/kernel/lmm/fair_bottleneck.cpp index cb108db156..931a16b40a 100644 --- a/src/kernel/lmm/fair_bottleneck.cpp +++ b/src/kernel/lmm/fair_bottleneck.cpp @@ -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 diff --git a/src/kernel/lmm/maxmin.cpp b/src/kernel/lmm/maxmin.cpp index 574bef20cb..3bae1528da 100644 --- a/src/kernel/lmm/maxmin.cpp +++ b/src/kernel/lmm/maxmin.cpp @@ -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); diff --git a/src/kernel/lmm/maxmin_test.cpp b/src/kernel/lmm/maxmin_test.cpp index d1c3a895a3..6d0c27cfd6 100644 --- a/src/kernel/lmm/maxmin_test.cpp +++ b/src/kernel/lmm/maxmin_test.cpp @@ -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" diff --git a/src/kernel/resource/Action.cpp b/src/kernel/resource/Action.cpp index b74ac0961b..75294a3090 100644 --- a/src/kernel/resource/Action.cpp +++ b/src/kernel/resource/Action.cpp @@ -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" diff --git a/src/kernel/resource/CpuImpl.cpp b/src/kernel/resource/CpuImpl.cpp index 73ef40b6c9..77aa7a1f02 100644 --- a/src/kernel/resource/CpuImpl.cpp +++ b/src/kernel/resource/CpuImpl.cpp @@ -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" diff --git a/src/kernel/resource/VirtualMachineImpl.cpp b/src/kernel/resource/VirtualMachineImpl.cpp index 0999e44869..224c1bf74f 100644 --- a/src/kernel/resource/VirtualMachineImpl.cpp +++ b/src/kernel/resource/VirtualMachineImpl.cpp @@ -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 diff --git a/src/kernel/resource/models/cpu_cas01.cpp b/src/kernel/resource/models/cpu_cas01.cpp index 8c9bd969f6..cb8a40df95 100644 --- a/src/kernel/resource/models/cpu_cas01.cpp +++ b/src/kernel/resource/models/cpu_cas01.cpp @@ -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)"); diff --git a/src/kernel/resource/models/cpu_ti.cpp b/src/kernel/resource/models/cpu_ti.cpp index 1dc5eebf2c..8142ff882d 100644 --- a/src/kernel/resource/models/cpu_ti.cpp +++ b/src/kernel/resource/models/cpu_ti.cpp @@ -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" diff --git a/src/kernel/resource/models/disk_s19.cpp b/src/kernel/resource/models/disk_s19.cpp index c88d038a4d..7789d9f575 100644 --- a/src/kernel/resource/models/disk_s19.cpp +++ b/src/kernel/resource/models/disk_s19.cpp @@ -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); /*********** diff --git a/src/kernel/resource/models/host_clm03.cpp b/src/kernel/resource/models/host_clm03.cpp index dc3be67bf6..3a44e40317 100644 --- a/src/kernel/resource/models/host_clm03.cpp +++ b/src/kernel/resource/models/host_clm03.cpp @@ -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); diff --git a/src/kernel/resource/models/network_cm02.cpp b/src/kernel/resource/models/network_cm02.cpp index acae09d624..117f661e85 100644 --- a/src/kernel/resource/models/network_cm02.cpp +++ b/src/kernel/resource/models/network_cm02.cpp @@ -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 #include diff --git a/src/kernel/resource/models/network_constant.cpp b/src/kernel/resource/models/network_constant.cpp index 33c03673d8..23e7ebc4be 100644 --- a/src/kernel/resource/models/network_constant.cpp +++ b/src/kernel/resource/models/network_constant.cpp @@ -6,8 +6,10 @@ #include #include +#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); diff --git a/src/kernel/resource/models/network_ib.cpp b/src/kernel/resource/models/network_ib.cpp index 56dabbb514..5f90cc55e7 100644 --- a/src/kernel/resource/models/network_ib.cpp +++ b/src/kernel/resource/models/network_ib.cpp @@ -5,24 +5,22 @@ #include +#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 #include 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}, */ diff --git a/src/kernel/resource/models/network_ns3.cpp b/src/kernel/resource/models/network_ns3.cpp index dfce0f0121..6509ceeda2 100644 --- a/src/kernel/resource/models/network_ns3.cpp +++ b/src/kernel/resource/models/network_ns3.cpp @@ -9,6 +9,8 @@ #include #include +#include "src/include/simgrid/math_utils.h" +#include "src/simgrid/module.hpp" #include "xbt/config.hpp" #include "xbt/str.h" #include "xbt/string.hpp" diff --git a/src/kernel/resource/models/ptask_L07.cpp b/src/kernel/resource/models/ptask_L07.cpp index 54dc3e6777..6e3edf4789 100644 --- a/src/kernel/resource/models/ptask_L07.cpp +++ b/src/kernel/resource/models/ptask_L07.cpp @@ -9,7 +9,9 @@ #include #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 diff --git a/src/kernel/routing/NetZoneImpl.cpp b/src/kernel/routing/NetZoneImpl.cpp index 51bfe24e49..cb9ca40e87 100644 --- a/src/kernel/routing/NetZoneImpl.cpp +++ b/src/kernel/routing/NetZoneImpl.cpp @@ -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"); diff --git a/src/kernel/xml/sg_platf.cpp b/src/kernel/xml/sg_platf.cpp index 6d3b433fd1..95a9638bc7 100644 --- a/src/kernel/xml/sg_platf.cpp +++ b/src/kernel/xml/sg_platf.cpp @@ -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 #include diff --git a/src/plugins/host_dvfs.cpp b/src/plugins/host_dvfs.cpp index c152cc5a76..f89923311f 100644 --- a/src/plugins/host_dvfs.cpp +++ b/src/plugins/host_dvfs.cpp @@ -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" diff --git a/src/plugins/host_energy.cpp b/src/plugins/host_energy.cpp index 422ff2a6a9..2bf95b1065 100644 --- a/src/plugins/host_energy.cpp +++ b/src/plugins/host_energy.cpp @@ -12,6 +12,7 @@ #include #include "src/kernel/resource/CpuImpl.hpp" +#include "src/simgrid/module.hpp" #include #include diff --git a/src/plugins/link_energy_wifi.cpp b/src/plugins/link_energy_wifi.cpp index be74ee658c..481f1f2400 100644 --- a/src/plugins/link_energy_wifi.cpp +++ b/src/plugins/link_energy_wifi.cpp @@ -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 #include diff --git a/src/smpi/internals/smpi_bench.cpp b/src/smpi/internals/smpi_bench.cpp index 794fa3e9fc..82752a6e5f 100644 --- a/src/smpi/internals/smpi_bench.cpp +++ b/src/smpi/internals/smpi_bench.cpp @@ -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" diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index c9a23e9d22..45944a44c6 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -6,29 +6,10 @@ #ifndef SURF_MODEL_H_ #define SURF_MODEL_H_ -#include "src/simgrid/module.hpp" -#include -#include - -#include "src/internal_config.h" #include "src/kernel/resource/profile/Profile.hpp" -#include -#include -#include #include #include -#include -#include - -/********* - * 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 traces_set_list; @@ -38,29 +19,4 @@ inline auto& watched_hosts() // avoid static initialization order fiasco static std::set> 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_ */ diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 410426e1d4..78cb9a4a12 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -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