Logo AND Algorithmique Numérique Distribuée

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