Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
8e76b051d8a13bbd2ac42584e11b5656d44dad6d
[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 XBT_PUBLIC(const char*) sg_host_get_name(sg_host_t host);
50
51 // ========== User Data ==============
52 XBT_PUBLIC(void*) sg_host_user(sg_host_t host);
53 XBT_PUBLIC(void) sg_host_user_set(sg_host_t host, void* userdata);
54 XBT_PUBLIC(void) sg_host_user_destroy(sg_host_t host);
55
56 // ========= storage related functions ============
57 /** \ingroup m_host_management
58  * \brief Return the list of mount point names on an host.
59  * \param host a host
60  * \return a dict containing all mount point on the host (mount_name => msg_storage_t)
61  */
62 XBT_PUBLIC(xbt_dict_t) sg_host_get_mounted_storage_list(sg_host_t host);
63 #define MSG_host_get_mounted_storage_list(host) sg_host_get_mounted_storage_list(host)
64
65 /** \ingroup m_host_management
66  * \brief Return the list of storages attached to an host.
67  * \param host a host
68  * \return a dynar containing all storages (name) attached to the host
69  */
70 XBT_PUBLIC(xbt_dynar_t) sg_host_get_attached_storage_list(sg_host_t host);
71 #define MSG_host_get_attached_storage_list(host) host_get_attached_storage_list(host)
72
73 // =========== user-level functions ===============
74 /** \ingroup m_host_management
75  * \brief Return the speed of the processor (in flop/s), regardless of the current load on the machine.
76  */
77 XBT_PUBLIC(double) sg_host_speed(sg_host_t host);
78 #define MSG_host_get_speed(host) sg_host_speed(host)
79 XBT_PUBLIC(double) sg_host_get_available_speed(sg_host_t host);
80
81 /** \ingroup m_process_management
82  * \brief Return the location on which a process is running.
83  * \param process a process (nullptr means the current one)
84  * \return the msg_host_t corresponding to the location on which \a process is running.
85  */
86 XBT_PUBLIC(sg_host_t) sg_host_self();
87 #define MSG_host_self() sg_host_self()
88
89 XBT_PUBLIC(const char*) sg_host_self_get_name();
90
91 /** \ingroup m_host_management
92  * \brief Return the total count of pstates defined for a host. See also @ref plugin_energy.
93  *
94  * \param  host host to test
95  */
96 XBT_PUBLIC(int) sg_host_get_nb_pstates(sg_host_t host);
97 #define MSG_host_get_nb_pstates(host) sg_host_get_nb_pstates(host)
98
99 XBT_PUBLIC(int) sg_host_get_pstate(sg_host_t host);
100 #define MSG_host_get_pstate(h) sg_host_get_pstate(h) /* users don't know that MSG is the C version of SimGrid */
101 XBT_PUBLIC(void) sg_host_set_pstate(sg_host_t host,int pstate);
102 #define MSG_host_set_pstate(h, pstate) sg_host_set_pstate(h, pstate) /* (same here) */
103
104 /** \ingroup m_host_management
105  * \brief Returns a xbt_dict_t consisting of the list of properties assigned to this host
106  *
107  * \param host a host
108  * \return a dict containing the properties
109  */
110 XBT_PUBLIC(xbt_dict_t) sg_host_get_properties(sg_host_t host);
111 #define MSG_host_get_properties(host) sg_host_get_properties(host)
112
113 /** \ingroup m_host_management
114  * \brief Returns the value of a given host property
115  *
116  * \param host a host
117  * \param name a property name
118  * \return value of a property (or nullptr if property not set)
119  */
120 XBT_PUBLIC(const char*) sg_host_get_property_value(sg_host_t host, const char* name);
121 #define MSG_host_get_property_value(host, name) sg_host_get_property_value(host, name)
122
123 /** \ingroup m_host_management
124  * \brief Change the value of a given host property
125  *
126  * \param host a host
127  * \param name a property name
128  * \param value what to change the property to
129  */
130 XBT_PUBLIC(void) sg_host_set_property_value(sg_host_t host, const char* name, const char* value);
131 #define MSG_host_set_property_value(host, name, value) sg_host_set_property_value(host, name, value)
132
133 XBT_PUBLIC(void) sg_host_route(sg_host_t from, sg_host_t to, xbt_dynar_t links);
134 XBT_PUBLIC(double) sg_host_route_latency(sg_host_t from, sg_host_t to);
135 XBT_PUBLIC(double) sg_host_route_bandwidth(sg_host_t from, sg_host_t to);
136 XBT_PUBLIC(void) sg_host_dump(sg_host_t ws);
137 SG_END_DECL()
138
139 #endif /* SIMGRID_HOST_H_ */