Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
I finally understood what this function is good for
[simgrid.git] / include / simgrid / platf.h
1 /* platf.h - Public interface to the SimGrid platforms                      */
2
3 /* Copyright (c) 2004, 2005, 2006, 2007, 2009, 2010, 2011. The SimGrid Team.
4  * All rights reserved.                                                     */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 #ifndef SG_PLATF_H
10 #define SG_PLATF_H
11
12 #include <xbt.h>
13
14 typedef struct tmgr_trace *tmgr_trace_t; /**< Opaque structure defining an availability trace */
15 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new(const char *filename);
16 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_string(const char *id,
17                                                     const char *input,
18                                                     double periodicity);
19
20 /** Defines whether a given resource is working or not */
21 typedef enum {
22   SURF_RESOURCE_ON = 1,                   /**< Up & ready        */
23   SURF_RESOURCE_OFF = 0                   /**< Down & broken     */
24 } e_surf_resource_state_t;
25
26 typedef enum {
27   SURF_LINK_FULLDUPLEX = 2,
28   SURF_LINK_SHARED = 1,
29   SURF_LINK_FATPIPE = 0
30 } e_surf_link_sharing_policy_t;
31
32 /*
33  * Platform creation functions. Instead of passing 123 arguments to the creation functions
34  * (one for each possible XML attribute), we pass structures containing them all. It removes the
35  * chances of switching arguments by error, and reduce the burden when we add a new attribute:
36  * old models can just continue to ignore it without having to update their headers.
37  *
38  * It shouldn't be too costly at runtime, provided that structures living on the stack are
39  * used, instead of malloced structures.
40  */
41
42 typedef struct {
43   const char* id;
44   double power_peak;
45   int core_amount;
46   double power_scale;
47   tmgr_trace_t power_trace;
48   e_surf_resource_state_t initial_state;
49   tmgr_trace_t state_trace;
50   const char* coord;
51   xbt_dict_t properties;
52 } s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
53
54 typedef struct {
55   const char* id;
56   const char* coord;
57 } s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
58
59 typedef struct {
60   const char* id;
61   double bandwidth;
62   tmgr_trace_t bandwidth_trace;
63   double latency;
64   tmgr_trace_t latency_trace;
65   e_surf_resource_state_t state;
66   tmgr_trace_t state_trace;
67   e_surf_link_sharing_policy_t policy;
68   xbt_dict_t properties;
69 } s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t;
70
71 typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
72 typedef struct s_sg_platf_peer_cbarg {
73   const char* id;
74   double power;
75   double bw_in;
76   double bw_out;
77   double lat;
78   const char* coord;
79   tmgr_trace_t availability_trace;
80   tmgr_trace_t state_trace;
81 } s_sg_platf_peer_cbarg_t;
82
83 typedef struct s_sg_platf_linkctn_cbarg *sg_platf_linkctn_cbarg_t;
84 typedef struct s_sg_platf_linkctn_cbarg {
85   const char *id;
86   const char *direction;
87 } s_sg_platf_linkctn_cbarg_t;
88
89 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
90 typedef struct s_sg_platf_cluster_cbarg {
91   const char* id;
92   const char* prefix;
93   const char* suffix;
94   const char* radical;
95   double power;
96   int core_amount;
97   double bw;
98   double lat;
99   double bb_bw;
100   double bb_lat;
101   const char* router_id;
102   e_surf_link_sharing_policy_t sharing_policy;
103   e_surf_link_sharing_policy_t bb_sharing_policy;
104   const char* availability_trace; //don't convert to tmgr_trace_t since there is a trace per host and some rewriting is needed
105   const char* state_trace;
106 } s_sg_platf_cluster_cbarg_t;
107
108
109
110 XBT_PUBLIC(void) sg_platf_begin(void);  // Start a new platform
111 XBT_PUBLIC(void) sg_platf_end(void); // Finish the creation of the platform
112
113 XBT_PUBLIC(void) sg_platf_new_AS_begin(const char *id, const char *mode); // Begin description of new AS
114 XBT_PUBLIC(void) sg_platf_new_AS_end(void);                            // That AS is fully described
115
116 XBT_PUBLIC(void) sg_platf_new_host   (sg_platf_host_cbarg_t   host);   // Add an host   to the currently described AS
117 XBT_PUBLIC(void) sg_platf_new_router (sg_platf_router_cbarg_t router); // Add a router  to the currently described AS
118 XBT_PUBLIC(void) sg_platf_new_link   (sg_platf_link_cbarg_t link);     // Add a link    to the currently described AS
119 XBT_PUBLIC(void) sg_platf_new_peer   (sg_platf_peer_cbarg_t peer);     // Add a peer    to the currently described AS
120 XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
121
122
123 #endif                          /* SG_PLATF_H */