Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'dev-get-hostname-faster' into 'master'
[simgrid.git] / include / simgrid / host.h
1 /* Copyright (c) 2013-2022. 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 XBT_PUBLIC size_t sg_host_extension_create(void (*deleter)(void*));
26 XBT_PUBLIC void* sg_host_extension_get(const_sg_host_t host, size_t rank);
27
28 /** Finds a host from its name */
29 XBT_PUBLIC sg_host_t sg_host_by_name(const char* name);
30 XBT_PUBLIC sg_vm_t sg_vm_by_name(sg_host_t host, const char* name);
31
32 /** @brief Return the name of the sg_host_t. */
33 XBT_PUBLIC const char* sg_host_get_name(const_sg_host_t host);
34
35 // ========== User Data ==============
36 /** @brief Return the user data of a #sg_host_t.
37  *
38  * This functions returns the user data associated to @a host if any.
39  */
40 XBT_PUBLIC void* sg_host_get_data(const_sg_host_t host);
41
42 /** @brief Set the user data of a #sg_host_t.
43  *
44  * This functions attach @a data to @a host.
45  */
46 XBT_PUBLIC void sg_host_set_data(sg_host_t host, void* userdata);
47
48 // ========= storage related functions ============
49 XBT_PUBLIC void sg_host_get_disks(const_sg_host_t host, unsigned int* disk_count, sg_disk_t** disks);
50
51 // =========== user-level functions ===============
52 /** @brief Return the speed of the processor (in flop/s), regardless of the current load on the machine. */
53 XBT_PUBLIC double sg_host_get_speed(const_sg_host_t host);
54 XBT_PUBLIC double sg_host_get_pstate_speed(const_sg_host_t host, unsigned long pstate_index);
55
56 XBT_PUBLIC double sg_host_get_available_speed(const_sg_host_t host);
57
58 XBT_PUBLIC int sg_host_core_count(const_sg_host_t host);
59
60 /** @brief Returns the current computation load (in flops per second).
61  * @param host a host
62  */
63 XBT_PUBLIC double sg_host_get_load(const_sg_host_t host);
64
65 /** @brief Return the location on which the current process is running. */
66 XBT_PUBLIC sg_host_t sg_host_self();
67
68 XBT_PUBLIC const char* sg_host_self_get_name();
69
70 /** @brief Return the total count of pstates defined for a host.
71  *
72  * @beginrst
73  * See also :ref:`plugin_host_energy`.
74  * @endrst
75  *
76  * @param  host host to test
77  */
78 XBT_PUBLIC unsigned long sg_host_get_nb_pstates(const_sg_host_t host);
79
80 XBT_PUBLIC unsigned long sg_host_get_pstate(const_sg_host_t host);
81 XBT_PUBLIC void sg_host_set_pstate(sg_host_t host, unsigned long pstate);
82
83 XBT_PUBLIC void sg_host_turn_on(sg_host_t host);
84 XBT_PUBLIC void sg_host_turn_off(sg_host_t host);
85 XBT_PUBLIC int sg_host_is_on(const_sg_host_t host);
86
87 /** @ingroup m_host_management
88  * @brief Returns a xbt_dict_t consisting of the list of properties assigned to this host
89  *
90  * @param host a host
91  * @return a dict containing the properties
92  */
93 XBT_PUBLIC xbt_dict_t sg_host_get_properties(const_sg_host_t host);
94
95 /** @ingroup m_host_management
96  * @brief Returns the value of a given host property
97  *
98  * @param host a host
99  * @param name a property name
100  * @return value of a property (or nullptr if property not set)
101  */
102 XBT_PUBLIC const char* sg_host_get_property_value(const_sg_host_t host, const char* name);
103
104 /** @ingroup m_host_management
105  * @brief Change the value of a given host property
106  *
107  * @param host a host
108  * @param name a property name
109  * @param value what to change the property to
110  */
111 XBT_PUBLIC void sg_host_set_property_value(sg_host_t host, const char* name, const char* value);
112
113 XBT_PUBLIC void sg_host_get_route(const_sg_host_t from, const_sg_host_t to, xbt_dynar_t links);
114 XBT_PUBLIC double sg_host_get_route_latency(const_sg_host_t from, const_sg_host_t to);
115 XBT_PUBLIC double sg_host_get_route_bandwidth(const_sg_host_t from, const_sg_host_t to);
116 XBT_PUBLIC void sg_host_sendto(sg_host_t from, sg_host_t to, double byte_amount);
117
118 XBT_ATTRIB_DEPRECATED_v335("Please manifest if you actually need this function") XBT_PUBLIC
119     void sg_host_dump(const_sg_host_t ws);
120
121 XBT_PUBLIC void sg_host_get_actor_list(const_sg_host_t host, xbt_dynar_t whereto);
122 SG_END_DECL
123
124 #endif /* SIMGRID_HOST_H_ */