Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a936a3b7f1482aaea51648f1fa0f8098aeefb272
[simgrid.git] / src / include / surf / surf.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_SURF_H
7 #define SURF_SURF_H
8
9 #include "simgrid/forward.h"
10 #include "xbt/graph.h"
11
12 /***************************/
13 /* Generic model object */
14 /***************************/
15
16 /** @{ @ingroup SURF_c_bindings */
17
18 /**
19  * @brief Pop an action from the done actions set
20  *
21  * @param model The model from which the action is extracted
22  * @return An action in done state
23  */
24 XBT_PUBLIC simgrid::kernel::resource::Action*
25 surf_model_extract_done_action_set(simgrid::kernel::resource::Model* model);
26
27 /**
28  * @brief Pop an action from the failed actions set
29  *
30  * @param model The model from which the action is extracted
31  * @return An action in failed state
32  */
33 XBT_PUBLIC simgrid::kernel::resource::Action*
34 surf_model_extract_failed_action_set(simgrid::kernel::resource::Model* model);
35
36 /**
37  * @brief Get the size of the running action set of a model
38  *
39  * @param model The model
40  * @return The size of the running action set
41  */
42 XBT_PUBLIC int surf_model_running_action_set_size(simgrid::kernel::resource::Model* model);
43
44 /**
45  * @brief [brief description]
46  * @details [long description]
47  *
48  * @param action The surf cpu action
49  * @param bound [description]
50  */
51 XBT_PUBLIC void surf_cpu_action_set_bound(simgrid::kernel::resource::Action* action, double bound);
52
53 /** @} */
54
55 /**************************************/
56 /* Implementations of model object */
57 /**************************************/
58
59 /** \ingroup SURF_models
60  *  \brief The CPU model object for the physical machine layer
61  */
62 XBT_PUBLIC_DATA simgrid::surf::CpuModel* surf_cpu_model_pm;
63
64 /** \ingroup SURF_models
65  *  \brief The CPU model object for the virtual machine layer
66  */
67 XBT_PUBLIC_DATA simgrid::surf::CpuModel* surf_cpu_model_vm;
68
69 XBT_PUBLIC_DATA simgrid::surf::StorageModel* surf_storage_model;
70
71 /** \ingroup SURF_models
72  *  \brief The host model
73  *
74  *  Note that when you create an API on top of SURF, the host model should be the only one you use
75  *  because depending on the platform model, the network model and the CPU model may not exist.
76  */
77 XBT_PUBLIC_DATA simgrid::surf::HostModel* surf_host_model;
78
79
80 /*** SURF Globals **************************/
81
82 /** \ingroup SURF_simulation
83  *  \brief Initialize SURF
84  *  \param argc argument number
85  *  \param argv arguments
86  *
87  *  This function has to be called to initialize the common structures. Then you will have to create the environment by
88  *  calling  e.g. surf_host_model_init_CM02()
89  *
90  *  \see surf_host_model_init_CM02(), surf_host_model_init_compound(), surf_exit()
91  */
92 XBT_PUBLIC void surf_init(int* argc, char** argv); /* initialize common structures */
93
94 /** \ingroup SURF_simulation
95  *  \brief Finish simulation initialization
96  *
97  *  This function must be called before the first call to surf_solve()
98  */
99 XBT_PUBLIC void surf_presolve();
100
101 /** \ingroup SURF_simulation
102  *  \brief Performs a part of the simulation
103  *  \param max_date Maximum date to update the simulation to, or -1
104  *  \return the elapsed time, or -1.0 if no event could be executed
105  *
106  *  This function execute all possible events, update the action states  and returns the time elapsed.
107  *  When you call execute or communicate on a model, the corresponding actions are not executed immediately but only
108  *  when you call surf_solve.
109  *  Note that the returned elapsed time can be zero.
110  */
111 XBT_PUBLIC double surf_solve(double max_date);
112
113 /** \ingroup SURF_simulation
114  *  \brief Return the current time
115  *
116  *  Return the current time in millisecond.
117  */
118 XBT_PUBLIC double surf_get_clock();
119
120 /** \ingroup SURF_simulation
121  *  \brief Exit SURF
122  *
123  *  Clean everything.
124  *
125  *  \see surf_init()
126  */
127 XBT_PUBLIC void surf_exit();
128
129 /* surf parse file related (public because called from a test suite) */
130 XBT_PUBLIC void parse_platform_file(const char* file);
131
132 /********** Tracing **********/
133
134 /* instr_routing.c */
135 xbt_graph_t instr_routing_platform_graph();
136 void instr_routing_platform_graph_export_graphviz(xbt_graph_t g, const char* filename);
137
138 #endif