Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
start snake_casing resource::Model
[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_tcp_gamma;
34 extern XBT_PRIVATE double sg_latency_factor;
35 extern XBT_PRIVATE double sg_bandwidth_factor;
36 extern XBT_PRIVATE double sg_weight_S_parameter;
37 extern XBT_PRIVATE int sg_network_crosstraffic;
38 extern XBT_PRIVATE std::vector<std::string> surf_path;
39 extern XBT_PRIVATE std::unordered_map<std::string, tmgr_trace_t> traces_set_list;
40 extern XBT_PRIVATE std::set<std::string> watched_hosts;
41
42 static inline void double_update(double* variable, double value, double precision)
43 {
44   // printf("Updating %g -= %g +- %g\n",*variable,value,precision);
45   // xbt_assert(value==0  || value>precision);
46   // Check that precision is higher than the machine-dependent size of the mantissa. If not, brutal rounding  may
47   // happen, and the precision mechanism is not active...
48   // xbt_assert(*variable< (2<<DBL_MANT_DIG)*precision && FLT_RADIX==2);
49   *variable -= value;
50   if (*variable < precision)
51     *variable = 0.0;
52 }
53
54 static inline int double_positive(double value, double precision)
55 {
56   return (value > precision);
57 }
58
59 static inline int double_equals(double value1, double value2, double precision)
60 {
61   return (fabs(value1 - value2) < precision);
62 }
63
64 extern "C" {
65 XBT_PUBLIC double surf_get_clock();
66 }
67 /** \ingroup SURF_simulation
68  *  \brief List of hosts that have just restarted and whose autorestart process should be restarted.
69  */
70 XBT_PUBLIC_DATA std::vector<sg_host_t> host_that_restart;
71
72 int XBT_PRIVATE __surf_is_absolute_file_path(const char *file_path);
73
74 /**********
75  * Action *
76  **********/
77
78 /** \ingroup SURF_models
79  *  \brief List of initialized models
80  */
81 XBT_PUBLIC_DATA std::vector<simgrid::kernel::resource::Model*>* all_existing_models;
82
83 #endif /* SURF_MODEL_H_ */