Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
c9c0ede46191407ac4765494cb29900047439f30
[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>                /* our toolbox */
13
14 typedef struct tmgr_trace *tmgr_trace_t; /**< Opaque structure defining an availability trace */
15
16 /** Defines whether a given resource is working or not */
17 typedef enum {
18   SURF_RESOURCE_ON = 1,                   /**< Up & ready        */
19   SURF_RESOURCE_OFF = 0                   /**< Down & broken     */
20 } e_surf_resource_state_t;
21
22 typedef enum {
23   SURF_LINK_FULLDUPLEX = 2,
24   SURF_LINK_SHARED = 1,
25   SURF_LINK_FATPIPE = 0
26 } e_surf_link_sharing_policy_t;
27
28 /*
29  * Platform creation functions. Instead of passing 123 arguments to the creation functions
30  * (one for each possible XML attribute), we pass structures containing them all. It removes the
31  * chances of switching arguments by error, and reduce the burden when we add a new attribute:
32  * old models can just continue to ignore it without having to update their headers.
33  *
34  * It shouldn't be too costly at runtime, provided that structures living on the stack are
35  * used, instead of malloced structures.
36  */
37
38 typedef struct {
39   const char* id;
40   double power_peak;
41   int core_amount;
42   double power_scale;
43   tmgr_trace_t power_trace;
44   e_surf_resource_state_t initial_state;
45   tmgr_trace_t state_trace;
46   const char* coord;
47   xbt_dict_t properties;
48 } s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
49
50 typedef struct {
51   const char* id;
52   const char* coord;
53 } s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
54
55 typedef struct {
56   const char* id;
57   double bandwidth;
58   tmgr_trace_t bandwidth_trace;
59   double latency;
60   tmgr_trace_t latency_trace;
61   e_surf_resource_state_t state;
62   tmgr_trace_t state_trace;
63   e_surf_link_sharing_policy_t policy;
64   xbt_dict_t properties;
65 } s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t;
66
67
68 XBT_PUBLIC(void) sg_platf_open(void);  // Start a new platform
69 XBT_PUBLIC(void) sg_platf_close(void); // Finish the creation of the platform
70
71 XBT_PUBLIC(void) sg_platf_new_AS_open(const char *id, const char *mode); // Begin description of new AS
72 XBT_PUBLIC(void) sg_platf_new_AS_close(void);                            // That AS is fully described
73
74 XBT_PUBLIC(void) sg_platf_new_host  (sg_platf_host_cbarg_t   host);   // Add an host  to the currently described AS
75 XBT_PUBLIC(void) sg_platf_new_router(sg_platf_router_cbarg_t router); // Add a router to the currently described AS
76 XBT_PUBLIC(void) sg_platf_new_link  (sg_platf_link_cbarg_t link);     // Add a link   to the currently described AS
77
78
79 #endif                          /* SG_PLATF_H */