Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move last functions in msg_host.cpp to the S4U C interface
[simgrid.git] / include / simgrid / host.h
1 /* Copyright (c) 2013-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 SIMGRID_HOST_H_
7 #define SIMGRID_HOST_H_
8
9 #include <stddef.h>
10
11 #include <xbt/dict.h>
12 #include <xbt/dynar.h>
13
14 #include <simgrid/forward.h>
15
16 SG_BEGIN_DECL()
17
18 XBT_PUBLIC sg_host_t* sg_host_list();
19
20 /** \ingroup m_host_management
21  * \brief Return the current number MSG hosts.
22  */
23 XBT_PUBLIC size_t sg_host_count();
24 #define MSG_get_host_number() sg_host_count()
25
26 /** \ingroup m_host_management
27  * \brief Return a dynar containing all the hosts declared at a given point of time (including VMs)
28  * \remark The host order in the returned array is generally different from the host creation/declaration order in the
29  *         XML platform (we use a hash table internally)
30  */
31 XBT_PUBLIC xbt_dynar_t sg_hosts_as_dynar();
32 #define MSG_hosts_as_dynar() sg_hosts_as_dynar()
33
34 XBT_PUBLIC size_t sg_host_extension_create(void (*deleter)(void*));
35 XBT_PUBLIC void* sg_host_extension_get(sg_host_t host, size_t rank);
36
37 /** \ingroup m_host_management
38  * \brief Finds a msg_host_t using its name.
39  *
40  * This is a name directory service
41  * \param name the name of an host.
42  * \return the corresponding host
43  */
44 XBT_PUBLIC sg_host_t sg_host_by_name(const char* name);
45 #define MSG_host_by_name(name) sg_host_by_name(name)
46 #define MSG_get_host_by_name(n) sg_host_by_name(n) /* Rewrite the old name into the new one transparently */
47
48 /** \ingroup m_host_management
49  *
50  * \brief Return the name of the #msg_host_t. */
51 XBT_PUBLIC const char* sg_host_get_name(sg_host_t host);
52 #define MSG_host_get_name(host) sg_host_get_name(host)
53
54 // ========== User Data ==============
55 /** \ingroup m_host_management
56  *
57  * \brief Return the user data of a #msg_host_t.
58  *
59  * This functions returns the user data associated to \a host if it is possible.
60  */
61 XBT_PUBLIC void* sg_host_user(sg_host_t host);
62 #define MSG_host_get_data(host) sg_host_user(host)
63 /** \ingroup m_host_management
64  *
65  * \brief Set the user data of a #msg_host_t.
66  *
67  * This functions attach \a data to \a host if it is possible.
68  */
69 XBT_PUBLIC void sg_host_user_set(sg_host_t host, void* userdata);
70 #define MSG_host_set_data(host, data) sg_host_user_set(host, data)
71 XBT_PUBLIC void sg_host_user_destroy(sg_host_t host);
72
73 // ========= storage related functions ============
74 /** \ingroup m_host_management
75  * \brief Return the list of mount point names on an host.
76  * \param host a host
77  * \return a dict containing all mount point on the host (mount_name => msg_storage_t)
78  */
79 XBT_PUBLIC xbt_dict_t sg_host_get_mounted_storage_list(sg_host_t host);
80 #define MSG_host_get_mounted_storage_list(host) sg_host_get_mounted_storage_list(host)
81
82 /** \ingroup m_host_management
83  * \brief Return the list of storages attached to an host.
84  * \param host a host
85  * \return a dynar containing all storages (name) attached to the host
86  */
87 XBT_PUBLIC xbt_dynar_t sg_host_get_attached_storage_list(sg_host_t host);
88 #define MSG_host_get_attached_storage_list(host) host_get_attached_storage_list(host)
89
90 // =========== user-level functions ===============
91 /** \ingroup m_host_management
92  * \brief Return the speed of the processor (in flop/s), regardless of the current load on the machine.
93  */
94 XBT_PUBLIC double sg_host_speed(sg_host_t host);
95 #define MSG_host_get_speed(host) sg_host_speed(host)
96 XBT_PUBLIC double sg_host_get_pstate_speed(sg_host_t host, int pstate_index);
97 #define MSG_host_get_power_peak_at(host, pstate_index) sg_host_get_pstate_speed(host, pstate_index)
98
99 XBT_PUBLIC double sg_host_get_available_speed(sg_host_t host);
100
101 XBT_PUBLIC int sg_host_core_count(sg_host_t host);
102 #define MSG_host_get_core_number(host) sg_host_core_count(host)
103
104 /** \ingroup m_process_management
105  * \brief Return the location on which a process is running.
106  * \param process a process (nullptr means the current one)
107  * \return the msg_host_t corresponding to the location on which \a process is running.
108  */
109 XBT_PUBLIC sg_host_t sg_host_self();
110 #define MSG_host_self() sg_host_self()
111
112 XBT_PUBLIC const char* sg_host_self_get_name();
113
114 /** \ingroup m_host_management
115  * \brief Return the total count of pstates defined for a host. See also @ref plugin_energy.
116  *
117  * \param  host host to test
118  */
119 XBT_PUBLIC int sg_host_get_nb_pstates(sg_host_t host);
120 #define MSG_host_get_nb_pstates(host) sg_host_get_nb_pstates(host)
121
122 XBT_PUBLIC int sg_host_get_pstate(sg_host_t host);
123 #define MSG_host_get_pstate(h) sg_host_get_pstate(h) /* users don't know that MSG is the C version of SimGrid */
124 XBT_PUBLIC void sg_host_set_pstate(sg_host_t host, int pstate);
125 #define MSG_host_set_pstate(h, pstate) sg_host_set_pstate(h, pstate) /* (same here) */
126
127 XBT_PUBLIC void sg_host_turn_on(sg_host_t host);
128 #define MSG_host_on(h) sg_host_turn_on(h)
129 XBT_PUBLIC void sg_host_turn_off(sg_host_t host);
130 #define MSG_host_off(h) sg_host_turn_off(h)
131 XBT_PUBLIC int sg_host_is_on(sg_host_t host);
132 #define MSG_host_is_on(h) sg_host_is_on(h)
133 XBT_PUBLIC int sg_host_is_off(sg_host_t host);
134 #define MSG_host_is_off(h) sg_host_is_off(h)
135
136 /** \ingroup m_host_management
137  * \brief Returns a xbt_dict_t consisting of the list of properties assigned to this host
138  *
139  * \param host a host
140  * \return a dict containing the properties
141  */
142 XBT_PUBLIC xbt_dict_t sg_host_get_properties(sg_host_t host);
143 #define MSG_host_get_properties(host) sg_host_get_properties(host)
144
145 /** \ingroup m_host_management
146  * \brief Returns the value of a given host property
147  *
148  * \param host a host
149  * \param name a property name
150  * \return value of a property (or nullptr if property not set)
151  */
152 XBT_PUBLIC const char* sg_host_get_property_value(sg_host_t host, const char* name);
153 #define MSG_host_get_property_value(host, name) sg_host_get_property_value(host, name)
154
155 /** \ingroup m_host_management
156  * \brief Change the value of a given host property
157  *
158  * \param host a host
159  * \param name a property name
160  * \param value what to change the property to
161  */
162 XBT_PUBLIC void sg_host_set_property_value(sg_host_t host, const char* name, const char* value);
163 #define MSG_host_set_property_value(host, name, value) sg_host_set_property_value(host, name, value)
164
165 XBT_PUBLIC void sg_host_route(sg_host_t from, sg_host_t to, xbt_dynar_t links);
166 XBT_PUBLIC double sg_host_route_latency(sg_host_t from, sg_host_t to);
167 XBT_PUBLIC double sg_host_route_bandwidth(sg_host_t from, sg_host_t to);
168 XBT_PUBLIC void sg_host_dump(sg_host_t ws);
169
170 XBT_PUBLIC void sg_host_get_actor_list(sg_host_t host, xbt_dynar_t whereto);
171 #define MSG_host_get_process_list(host, whereto) sg_host_get_actor_list(host, whereto)
172 SG_END_DECL()
173
174 #endif /* SIMGRID_HOST_H_ */