Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
2350923425d40b816291f41359acee6e87b05fc7
[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_available_speed(sg_host_t host);
97
98 XBT_PUBLIC int sg_host_core_count(sg_host_t host);
99 #define MSG_host_get_core_number(host) sg_host_core_count(host)
100
101 /** \ingroup m_process_management
102  * \brief Return the location on which a process is running.
103  * \param process a process (nullptr means the current one)
104  * \return the msg_host_t corresponding to the location on which \a process is running.
105  */
106 XBT_PUBLIC sg_host_t sg_host_self();
107 #define MSG_host_self() sg_host_self()
108
109 XBT_PUBLIC const char* sg_host_self_get_name();
110
111 /** \ingroup m_host_management
112  * \brief Return the total count of pstates defined for a host. See also @ref plugin_energy.
113  *
114  * \param  host host to test
115  */
116 XBT_PUBLIC int sg_host_get_nb_pstates(sg_host_t host);
117 #define MSG_host_get_nb_pstates(host) sg_host_get_nb_pstates(host)
118
119 XBT_PUBLIC int sg_host_get_pstate(sg_host_t host);
120 #define MSG_host_get_pstate(h) sg_host_get_pstate(h) /* users don't know that MSG is the C version of SimGrid */
121 XBT_PUBLIC void sg_host_set_pstate(sg_host_t host, int pstate);
122 #define MSG_host_set_pstate(h, pstate) sg_host_set_pstate(h, pstate) /* (same here) */
123
124 XBT_PUBLIC void sg_host_turn_on(sg_host_t host);
125 #define MSG_host_on(h) sg_host_turn_on(h)
126 XBT_PUBLIC void sg_host_turn_off(sg_host_t host);
127 #define MSG_host_off(h) sg_host_turn_off(h)
128 XBT_PUBLIC int sg_host_is_on(sg_host_t host);
129 #define MSG_host_is_on(h) sg_host_is_on(h)
130 XBT_PUBLIC int sg_host_is_off(sg_host_t host);
131 #define MSG_host_is_off(h) sg_host_is_off(h)
132
133 /** \ingroup m_host_management
134  * \brief Returns a xbt_dict_t consisting of the list of properties assigned to this host
135  *
136  * \param host a host
137  * \return a dict containing the properties
138  */
139 XBT_PUBLIC xbt_dict_t sg_host_get_properties(sg_host_t host);
140 #define MSG_host_get_properties(host) sg_host_get_properties(host)
141
142 /** \ingroup m_host_management
143  * \brief Returns the value of a given host property
144  *
145  * \param host a host
146  * \param name a property name
147  * \return value of a property (or nullptr if property not set)
148  */
149 XBT_PUBLIC const char* sg_host_get_property_value(sg_host_t host, const char* name);
150 #define MSG_host_get_property_value(host, name) sg_host_get_property_value(host, name)
151
152 /** \ingroup m_host_management
153  * \brief Change the value of a given host property
154  *
155  * \param host a host
156  * \param name a property name
157  * \param value what to change the property to
158  */
159 XBT_PUBLIC void sg_host_set_property_value(sg_host_t host, const char* name, const char* value);
160 #define MSG_host_set_property_value(host, name, value) sg_host_set_property_value(host, name, value)
161
162 XBT_PUBLIC void sg_host_route(sg_host_t from, sg_host_t to, xbt_dynar_t links);
163 XBT_PUBLIC double sg_host_route_latency(sg_host_t from, sg_host_t to);
164 XBT_PUBLIC double sg_host_route_bandwidth(sg_host_t from, sg_host_t to);
165 XBT_PUBLIC void sg_host_dump(sg_host_t ws);
166 SG_END_DECL()
167
168 #endif /* SIMGRID_HOST_H_ */