Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
sanitizes host user_data: create a lib level
[simgrid.git] / include / simgrid / host.h
1 /* Copyright (c) 2013-2015. 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 <xbt/dict.h>
11 #include <xbt/dynar.h>
12 SG_BEGIN_DECL()
13
14 typedef xbt_dictelm_t sg_host_t;
15 XBT_PUBLIC(sg_host_t) sg_host_by_name(const char *name);
16 XBT_PUBLIC(sg_host_t) sg_host_by_name_or_create(const char *name);
17 static XBT_INLINE char *sg_host_get_name(sg_host_t host){
18         return host->key;
19 }
20 XBT_PUBLIC(xbt_dynar_t) sg_hosts_as_dynar(void);
21
22 #ifdef __cplusplus
23 #define DEFINE_EXTERNAL_CLASS(klass) class klass;
24 class Cpu;
25 #else
26 #define DEFINE_EXTERNAL_CLASS(klass) typedef struct klass klass;
27 #endif
28 // ========== User Data ==============
29 XBT_PUBLIC(void*) sg_host_user(sg_host_t host);
30 XBT_PUBLIC(void) sg_host_user_set(sg_host_t host, void* userdata);
31 XBT_PUBLIC(void) sg_host_user_destroy(sg_host_t host);
32
33 // ========== MSG Layer ==============
34 typedef struct s_msg_host_priv *msg_host_priv_t;
35 msg_host_priv_t sg_host_msg(sg_host_t host);
36 XBT_PUBLIC(void) sg_host_msg_set(sg_host_t host, msg_host_priv_t priv);
37 XBT_PUBLIC(void) sg_host_msg_destroy(sg_host_t host);
38
39 // ========== SD Layer ==============
40 typedef struct SD_workstation *SD_workstation_priv_t;
41 SD_workstation_priv_t sg_host_sd(sg_host_t host);
42 XBT_PUBLIC(void) sg_host_sd_set(sg_host_t host, SD_workstation_priv_t priv);
43 XBT_PUBLIC(void) sg_host_sd_destroy(sg_host_t host);
44
45 // ========== Simix layer =============
46 typedef struct s_smx_host_priv *smx_host_priv_t;
47 XBT_PUBLIC(smx_host_priv_t) sg_host_simix(sg_host_t host);
48 XBT_PUBLIC(void) sg_host_simix_set(sg_host_t host, smx_host_priv_t priv);
49 XBT_PUBLIC(void) sg_host_simix_destroy(sg_host_t host);
50
51 // ========== SURF CPU ============
52 DEFINE_EXTERNAL_CLASS(Cpu);
53 typedef Cpu *surf_cpu_t;
54 XBT_PUBLIC(surf_cpu_t) sg_host_surfcpu(sg_host_t host);
55 XBT_PUBLIC(void) sg_host_surfcpu_set(sg_host_t host, surf_cpu_t cpu);
56 XBT_PUBLIC(void) sg_host_surfcpu_destroy(sg_host_t host);
57
58 // ========== RoutingEdge ============
59 DEFINE_EXTERNAL_CLASS(RoutingEdge);
60 XBT_PUBLIC(RoutingEdge*) sg_host_edge(sg_host_t host);
61 XBT_PUBLIC(void) sg_host_edge_set(sg_host_t host, RoutingEdge* edge);
62 XBT_PUBLIC(void) sg_host_edge_destroy(sg_host_t host, int do_callback);
63
64
65 // Module initializer. Won't survive the conversion to C++. Hopefully.
66 XBT_PUBLIC(void) sg_host_init(void);
67
68 // =========== user-level functions ===============
69 XBT_PUBLIC(double) sg_host_get_speed(sg_host_t host);
70 XBT_PUBLIC(double) sg_host_get_available_speed(sg_host_t host);
71 XBT_PUBLIC(int) sg_host_get_core(sg_host_t host);
72 XBT_PUBLIC(int) sg_host_get_state(sg_host_t host);
73
74 XBT_PUBLIC(int) sg_host_get_nb_pstates(sg_host_t host);
75 XBT_PUBLIC(int) sg_host_get_pstate(sg_host_t host);
76 XBT_PUBLIC(double) sg_host_get_consumed_energy(sg_host_t host);
77
78
79 SG_END_DECL()
80
81 #endif /* SIMGRID_HOST_H_ */