Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update path.
[simgrid.git] / src / surf / surf_interface.hpp
1 /* Copyright (c) 2004-2023. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef SURF_MODEL_H_
7 #define SURF_MODEL_H_
8
9 #include "src/simgrid/module.hpp"
10 #include <xbt/asserts.h>
11 #include <xbt/function_types.h>
12
13 #include "src/internal_config.h"
14 #include "src/kernel/resource/profile/Profile.hpp"
15
16 #include <cfloat>
17 #include <cmath>
18 #include <functional>
19 #include <set>
20 #include <string>
21 #include <unordered_map>
22 #include <vector>
23
24 /*********
25  * Utils *
26  *********/
27
28 /* user-visible parameters */
29 XBT_PUBLIC_DATA double sg_precision_workamount;
30 XBT_PUBLIC_DATA double sg_precision_timing;
31 XBT_PUBLIC_DATA int sg_concurrency_limit;
32
33 extern XBT_PRIVATE std::unordered_map<std::string, simgrid::kernel::profile::Profile*> traces_set_list;
34
35 /** set of hosts for which one want to be notified if they ever restart */
36 inline auto& watched_hosts() // avoid static initialization order fiasco
37 {
38   static std::set<std::string, std::less<>> value;
39   return value;
40 }
41
42 static inline void double_update(double* variable, double value, double precision)
43 {
44   if (false) { // debug
45     fprintf(stderr, "Updating %g -= %g +- %g\n", *variable, value, precision);
46     xbt_assert(value == 0.0 || value > precision);
47     // Check that precision is higher than the machine-dependent size of the mantissa. If not, brutal rounding  may
48     // happen, and the precision mechanism is not active...
49     xbt_assert(FLT_RADIX == 2 && *variable < precision * exp2(DBL_MANT_DIG));
50   }
51   *variable -= value;
52   if (*variable < precision)
53     *variable = 0.0;
54 }
55
56 static inline int double_positive(double value, double precision)
57 {
58   return (value > precision);
59 }
60
61 static inline int double_equals(double value1, double value2, double precision)
62 {
63   return (fabs(value1 - value2) < precision);
64 }
65
66 XBT_PUBLIC void surf_vm_model_init_HL13();
67
68 #endif /* SURF_MODEL_H_ */