Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
make option 'network/crosstraffic' clean and nice
[simgrid.git] / src / surf / surf_interface.hpp
1 /* Copyright (c) 2004-2018. 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 "xbt/signal.hpp"
10 #include "xbt/utility.hpp"
11
12 #include "src/surf/surf_private.hpp"
13 #include "surf/surf.hpp"
14 #include "xbt/str.h"
15
16 #include <boost/heap/pairing_heap.hpp>
17 #include <boost/intrusive/list.hpp>
18 #include <boost/optional.hpp>
19 #include <cmath>
20 #include <set>
21 #include <string>
22 #include <unordered_map>
23
24 /*********
25  * Utils *
26  *********/
27
28 /* user-visible parameters */
29 XBT_PUBLIC_DATA double sg_maxmin_precision;
30 XBT_PUBLIC_DATA double sg_surf_precision;
31 XBT_PUBLIC_DATA int sg_concurrency_limit;
32
33 extern XBT_PRIVATE double sg_latency_factor;
34 extern XBT_PRIVATE double sg_bandwidth_factor;
35 extern XBT_PRIVATE double sg_weight_S_parameter;
36 extern XBT_PRIVATE std::vector<std::string> surf_path;
37 extern XBT_PRIVATE std::unordered_map<std::string, tmgr_trace_t> traces_set_list;
38 extern XBT_PRIVATE std::set<std::string> watched_hosts;
39
40 static inline void double_update(double* variable, double value, double precision)
41 {
42   // printf("Updating %g -= %g +- %g\n",*variable,value,precision);
43   // xbt_assert(value==0  || value>precision);
44   // Check that precision is higher than the machine-dependent size of the mantissa. If not, brutal rounding  may
45   // happen, and the precision mechanism is not active...
46   // xbt_assert(*variable< (2<<DBL_MANT_DIG)*precision && FLT_RADIX==2);
47   *variable -= value;
48   if (*variable < precision)
49     *variable = 0.0;
50 }
51
52 static inline int double_positive(double value, double precision)
53 {
54   return (value > precision);
55 }
56
57 static inline int double_equals(double value1, double value2, double precision)
58 {
59   return (fabs(value1 - value2) < precision);
60 }
61
62 /** \ingroup SURF_simulation
63  *  \brief List of hosts that have just restarted and whose autorestart process should be restarted.
64  */
65 XBT_PUBLIC_DATA std::vector<sg_host_t> host_that_restart;
66
67 int XBT_PRIVATE __surf_is_absolute_file_path(const char *file_path);
68
69 /**********
70  * Action *
71  **********/
72
73 /** \ingroup SURF_models
74  *  \brief List of initialized models
75  */
76 XBT_PUBLIC_DATA std::vector<simgrid::kernel::resource::Model*>* all_existing_models;
77
78 #endif /* SURF_MODEL_H_ */