Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
More coding style updates for sg_host.
[simgrid.git] / include / simgrid / host.h
1 /* Copyright (c) 2013-2020. 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 <xbt/dict.h>
10 #include <xbt/dynar.h>
11 #include <simgrid/forward.h>
12
13 SG_BEGIN_DECL
14 /** Returns an array of all existing hosts (use sg_host_count() to know the array size).
15  *
16  * @remark The host order in this array is generally different from the
17  * creation/declaration order in the XML platform (we use a hash table
18  * internally).
19  */
20 XBT_PUBLIC sg_host_t* sg_host_list();
21
22 /** Returns the amount of hosts existing in the platform. */
23 XBT_PUBLIC size_t sg_host_count();
24
25 /**
26  * @brief Return a dynar containing all the hosts declared at a given point of time (including VMs)
27  * @remark The host order in the returned array is generally different from the host creation/declaration order in the
28  *         XML platform (we use a hash table internally)
29  */
30 XBT_ATTRIB_DEPRECATED_v330("Please use sg_host_list()") XBT_PUBLIC xbt_dynar_t sg_hosts_as_dynar();
31
32 XBT_PUBLIC size_t sg_host_extension_create(void (*deleter)(void*));
33 XBT_PUBLIC void* sg_host_extension_get(const_sg_host_t host, size_t rank);
34
35 /** Finds a host from its name */
36 XBT_PUBLIC sg_host_t sg_host_by_name(const char* name);
37
38 /** @brief Return the name of the sg_host_t. */
39 XBT_PUBLIC const char* sg_host_get_name(const_sg_host_t host);
40
41 #ifndef DOXYGEN
42 // ========== User Data ==============
43 /** @brief Return the user data of a #sg_host_t.
44  *
45  * This functions returns the user data associated to @a host if any.
46  */
47 XBT_PUBLIC void* sg_host_get_data(const_sg_host_t host);
48 XBT_ATTRIB_DEPRECATED_v330("Please use sg_host_get_data()") XBT_PUBLIC void* sg_host_data(const_sg_host_t host);
49 XBT_ATTRIB_DEPRECATED_v328("Please use sg_host_get_data()") XBT_PUBLIC void* sg_host_user(sg_host_t host);
50 /** @brief Set the user data of a #sg_host_t.
51  *
52  * This functions attach @a data to @a host.
53  */
54 XBT_PUBLIC void sg_host_set_data(sg_host_t host, void* userdata);
55 XBT_ATTRIB_DEPRECATED_v330("Please use sg_host_set_data()") XBT_PUBLIC
56     void sg_host_data_set(sg_host_t host, void* userdata);
57 XBT_ATTRIB_DEPRECATED_v328("Please use sg_host_set_data()") XBT_PUBLIC
58     void sg_host_user_set(sg_host_t host, void* userdata);
59 XBT_ATTRIB_DEPRECATED_v328("Please use sg_host_set_data(h, NULL)") XBT_PUBLIC void sg_host_user_destroy(sg_host_t host);
60 #endif
61
62 // ========= storage related functions ============
63 /** @brief Return the list of mount point names on a host.
64  * @param host a host
65  * @return a dict containing all mount point on the host (mount_name => sg_storage_t)
66  */
67 XBT_PUBLIC xbt_dict_t sg_host_get_mounted_storage_list(sg_host_t host);
68
69 /** @brief Return the list of storages attached to a host.
70  * @param host a host
71  * @return a dynar containing all storages (name) attached to the host
72  */
73 XBT_PUBLIC xbt_dynar_t sg_host_get_attached_storage_list(const_sg_host_t host);
74 XBT_PUBLIC void sg_host_get_disks(const_sg_host_t host, unsigned int* disk_count, sg_disk_t** disks);
75 XBT_ATTRIB_DEPRECATED_v330("Please use sg_host_get_disks()") XBT_PUBLIC
76     void sg_host_disks(const_sg_host_t host, unsigned int* disk_count, sg_disk_t** disks);
77
78 // =========== user-level functions ===============
79 /** @brief Return the speed of the processor (in flop/s), regardless of the current load on the machine. */
80 XBT_PUBLIC double sg_host_get_speed(const_sg_host_t host);
81 XBT_ATTRIB_DEPRECATED_v330("Please use sg_host_get_speed()") XBT_PUBLIC double sg_host_speed(const_sg_host_t host);
82 XBT_PUBLIC double sg_host_get_pstate_speed(const_sg_host_t host, int pstate_index);
83
84 XBT_PUBLIC double sg_host_get_available_speed(const_sg_host_t host);
85
86 XBT_PUBLIC int sg_host_core_count(const_sg_host_t host);
87
88 /** @brief Returns the current computation load (in flops per second).
89  * @param host a host
90  */
91 XBT_PUBLIC double sg_host_get_load(const_sg_host_t host);
92 XBT_ATTRIB_DEPRECATED_v330("Please use sg_host_get_load()") XBT_PUBLIC double sg_host_load(const_sg_host_t host);
93
94 /** @brief Return the location on which the current process is running. */
95 XBT_PUBLIC sg_host_t sg_host_self();
96
97 XBT_PUBLIC const char* sg_host_self_get_name();
98
99 /** @brief Return the total count of pstates defined for a host.
100  *
101  * @beginrst
102  * See also :ref:`plugin_host_energy`.
103  * @endrst
104  *
105  * @param  host host to test
106  */
107 XBT_PUBLIC int sg_host_get_nb_pstates(const_sg_host_t host);
108
109 XBT_PUBLIC int sg_host_get_pstate(const_sg_host_t host);
110 XBT_PUBLIC void sg_host_set_pstate(sg_host_t host, int pstate);
111
112 XBT_PUBLIC void sg_host_turn_on(sg_host_t host);
113 XBT_PUBLIC void sg_host_turn_off(sg_host_t host);
114 XBT_PUBLIC int sg_host_is_on(const_sg_host_t host);
115
116 /** @ingroup m_host_management
117  * @brief Returns a xbt_dict_t consisting of the list of properties assigned to this host
118  *
119  * @param host a host
120  * @return a dict containing the properties
121  */
122 XBT_PUBLIC xbt_dict_t sg_host_get_properties(const_sg_host_t host);
123
124 /** @ingroup m_host_management
125  * @brief Returns the value of a given host property
126  *
127  * @param host a host
128  * @param name a property name
129  * @return value of a property (or nullptr if property not set)
130  */
131 XBT_PUBLIC const char* sg_host_get_property_value(const_sg_host_t host, const char* name);
132
133 /** @ingroup m_host_management
134  * @brief Change the value of a given host property
135  *
136  * @param host a host
137  * @param name a property name
138  * @param value what to change the property to
139  */
140 XBT_PUBLIC void sg_host_set_property_value(sg_host_t host, const char* name, const char* value);
141
142 XBT_PUBLIC void sg_host_get_route(const_sg_host_t from, const_sg_host_t to, xbt_dynar_t links);
143 XBT_PUBLIC double sg_host_get_route_latency(const_sg_host_t from, const_sg_host_t to);
144 XBT_PUBLIC double sg_host_get_route_bandwidth(const_sg_host_t from, const_sg_host_t to);
145 XBT_ATTRIB_DEPRECATED_v330("Please use sg_host_get_route()") XBT_PUBLIC
146     void sg_host_route(const_sg_host_t from, const_sg_host_t to, xbt_dynar_t links);
147 XBT_ATTRIB_DEPRECATED_v330("Please use sg_host_get_route_latency()") XBT_PUBLIC
148     double sg_host_route_latency(const_sg_host_t from, const_sg_host_t to);
149 XBT_ATTRIB_DEPRECATED_v330("Please use sg_host_get_route_bandwidth()") XBT_PUBLIC
150     double sg_host_route_bandwidth(const_sg_host_t from, const_sg_host_t to);
151 XBT_PUBLIC void sg_host_sendto(sg_host_t from, sg_host_t to, double byte_amount);
152
153 #ifndef DOXYGEN
154 XBT_ATTRIB_DEPRECATED_v330("Please use sg_host_sendto") inline void sg_host_send_to(sg_host_t from, sg_host_t to,
155                                                                                     double byte_amount)
156 {
157   sg_host_sendto(from, to, byte_amount);
158 }
159 #endif
160
161 XBT_PUBLIC void sg_host_dump(const_sg_host_t ws);
162
163 XBT_PUBLIC void sg_host_get_actor_list(const_sg_host_t host, xbt_dynar_t whereto);
164 SG_END_DECL
165
166 #endif /* SIMGRID_HOST_H_ */