Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
b8e41a1d8a7ef11db93d9baf4b1995cb2e37ecba
[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 #define NO_MAX_DURATION -1.0
25
26 /*********
27  * Utils *
28  *********/
29
30 /* user-visible parameters */
31 XBT_PUBLIC_DATA(double) sg_maxmin_precision;
32 XBT_PUBLIC_DATA(double) sg_surf_precision;
33 XBT_PUBLIC_DATA(int) sg_concurrency_limit;
34
35 extern XBT_PRIVATE double sg_tcp_gamma;
36 extern XBT_PRIVATE double sg_latency_factor;
37 extern XBT_PRIVATE double sg_bandwidth_factor;
38 extern XBT_PRIVATE double sg_weight_S_parameter;
39 extern XBT_PRIVATE int sg_network_crosstraffic;
40 extern XBT_PRIVATE std::vector<std::string> surf_path;
41 extern XBT_PRIVATE std::unordered_map<std::string, tmgr_trace_t> traces_set_list;
42 extern XBT_PRIVATE std::set<std::string> watched_hosts;
43
44 static inline void double_update(double* variable, double value, double precision)
45 {
46   // printf("Updating %g -= %g +- %g\n",*variable,value,precision);
47   // xbt_assert(value==0  || value>precision);
48   // Check that precision is higher than the machine-dependent size of the mantissa. If not, brutal rounding  may
49   // happen, and the precision mechanism is not active...
50   // xbt_assert(*variable< (2<<DBL_MANT_DIG)*precision && FLT_RADIX==2);
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 extern "C" {
67 XBT_PUBLIC(double) surf_get_clock();
68 }
69 /** \ingroup SURF_simulation
70  *  \brief List of hosts that have just restarted and whose autorestart process should be restarted.
71  */
72 XBT_PUBLIC_DATA(std::vector<sg_host_t>) host_that_restart;
73
74 int XBT_PRIVATE __surf_is_absolute_file_path(const char *file_path);
75
76 /**********
77  * Action *
78  **********/
79
80 /** \ingroup SURF_models
81  *  \brief List of initialized models
82  */
83 XBT_PUBLIC_DATA(std::vector<surf_model_t>*) all_existing_models;
84
85 #endif /* SURF_MODEL_H_ */