* used, instead of malloced structures.
*/
-typedef struct s_surf_parsing_host_arg {
+typedef struct {
char* V_host_id; //id
double V_host_power_peak; //power
int V_host_core; //core
e_surf_resource_state_t V_host_state_initial; //state
tmgr_trace_t V_host_state_trace; //state file
const char* V_host_coord;
-} s_surf_parsing_host_arg_t, *surf_parsing_host_arg_t;
+} s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
-typedef struct s_surf_parsing_router_arg {
+typedef struct {
const char* V_router_id;
const char* V_router_coord;
-} s_surf_parsing_router_arg_t, *surf_parsing_router_arg_t;
+} s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
XBT_PUBLIC(void) sg_platf_new_AS_open(const char *id, const char *mode);
XBT_PUBLIC(void) sg_platf_new_AS_close(void);
-XBT_PUBLIC(void) sg_platf_new_host(surf_parsing_host_arg_t h);
-XBT_PUBLIC(void) sg_platf_new_router(surf_parsing_router_arg_t router);
+XBT_PUBLIC(void) sg_platf_new_host (sg_platf_host_cbarg_t host);
+XBT_PUBLIC(void) sg_platf_new_router(sg_platf_router_cbarg_t router);
#endif /* SG_PLATF_H */
/* Managing the parsing callbacks */
-typedef void (*surf_parse_host_fct_t)(surf_parsing_host_arg_t);
-typedef void (*surf_parse_router_fct_t)(surf_parsing_router_arg_t);
-void surf_parse_host_add_cb(surf_parse_host_fct_t);
-void surf_parse_router_add_cb(surf_parse_router_fct_t);
+typedef void (*sg_platf_host_cb_t)(sg_platf_host_cbarg_t);
+typedef void (*sg_platf_router_cb_t)(sg_platf_router_cbarg_t);
+void sg_platf_host_add_cb(sg_platf_host_cb_t);
+void sg_platf_router_add_cb(sg_platf_router_cb_t);
xbt_dynar_free (&links_to_create);
}
-static void instr_routing_parse_start_host (surf_parsing_host_arg_t host)
+static void instr_routing_parse_start_host (sg_platf_host_cbarg_t host)
{
container_t father = *(container_t*)xbt_dynar_get_ptr(currentContainer, xbt_dynar_length(currentContainer)-1);
container_t new = newContainer (host->V_host_id, INSTR_HOST, father);
}
}
-static void instr_routing_parse_start_router (surf_parsing_router_arg_t router)
+static void instr_routing_parse_start_router (sg_platf_router_cbarg_t router)
{
container_t father = *(container_t*)xbt_dynar_get_ptr(currentContainer, xbt_dynar_length(currentContainer)-1);
newContainer (router->V_router_id, INSTR_ROUTER, father);
surfxml_add_callback(ETag_surfxml_AS_cb_list, &instr_routing_parse_end_AS);
if (!TRACE_needs_platform()) return;
surfxml_add_callback(STag_surfxml_link_cb_list, &instr_routing_parse_start_link);
- surf_parse_host_add_cb(instr_routing_parse_start_host);
- surf_parse_router_add_cb(instr_routing_parse_start_router);
+ sg_platf_host_add_cb(instr_routing_parse_start_host);
+ sg_platf_router_add_cb(instr_routing_parse_start_router);
surfxml_add_callback(ETag_surfxml_platform_cb_list, &instr_routing_parse_end_platform);
}
}
-static void parse_cpu_init(surf_parsing_host_arg_t host)
+static void parse_cpu_init(sg_platf_host_cbarg_t host)
{
if(strcmp(host->V_host_coord,"")) xbt_die("Coordinates not implemented yet!");
static void cpu_define_callbacks(void)
{
- surf_parse_host_add_cb(parse_cpu_init);
+ sg_platf_host_add_cb(parse_cpu_init);
surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_traces_cpu);
}
}
-static void parse_cpu_im_init(surf_parsing_host_arg_t host)
+static void parse_cpu_im_init(sg_platf_host_cbarg_t host)
{
cpu_im_create_resource(host->V_host_id,
host->V_host_power_peak,
static void cpu_im_define_callbacks()
{
- surf_parse_host_add_cb(parse_cpu_im_init);
+ sg_platf_host_add_cb(parse_cpu_im_init);
surfxml_add_callback(ETag_surfxml_platform_cb_list,
&cpu_im_add_traces_cpu);
}
}
-static void parse_cpu_ti_init(surf_parsing_host_arg_t host)
+static void parse_cpu_ti_init(sg_platf_host_cbarg_t host)
{
cpu_ti_create_resource(host->V_host_id,
host->V_host_power_peak,
static void cpu_ti_define_callbacks()
{
- surf_parse_host_add_cb(parse_cpu_ti_init);
+ sg_platf_host_add_cb(parse_cpu_ti_init);
surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_traces_cpu_ti);
}
static random_data_t random_latency = NULL;
static int host_number_int = 0;
-static void netcste_count_hosts(surf_parsing_host_arg_t h)
+static void netcste_count_hosts(sg_platf_host_cbarg_t h)
{
host_number_int++;
}
static void netcste_define_callbacks(void)
{
- surf_parse_host_add_cb(netcste_count_hosts);
+ sg_platf_host_add_cb(netcste_count_hosts);
}
static int netcste_resource_used(void *resource_id)
#include "surf/surf_private.h"
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse);
-xbt_dynar_t surf_parse_host_cb_list = NULL; // of functions of type: surf_parsing_host_arg_t -> void
-xbt_dynar_t surf_parse_router_cb_list = NULL; // of functions of type: surf_parsing_router_arg_t -> void
+xbt_dynar_t sg_platf_host_cb_list = NULL; // of sg_platf_host_cb_t
+xbt_dynar_t sg_platf_router_cb_list = NULL; // of sg_platf_router_cb_t
/** Module management function: creates all internal data structures */
void sg_platf_init(void) {
- surf_parse_host_cb_list = xbt_dynar_new(sizeof(surf_parse_host_fct_t), NULL);
- surf_parse_router_cb_list = xbt_dynar_new(sizeof(surf_parse_host_fct_t), NULL);
+ sg_platf_host_cb_list = xbt_dynar_new(sizeof(sg_platf_host_cb_t), NULL);
+ sg_platf_router_cb_list = xbt_dynar_new(sizeof(sg_platf_host_cb_t), NULL);
}
/** Module management function: frees all internal data structures */
void sg_platf_exit(void) {
- xbt_dynar_free(&surf_parse_host_cb_list);
- xbt_dynar_free(&surf_parse_router_cb_list);
+ xbt_dynar_free(&sg_platf_host_cb_list);
+ xbt_dynar_free(&sg_platf_router_cb_list);
}
-void sg_platf_new_host(surf_parsing_host_arg_t h){
+void sg_platf_new_host(sg_platf_host_cbarg_t h){
unsigned int iterator;
- surf_parse_host_fct_t fun;
- xbt_dynar_foreach(surf_parse_host_cb_list, iterator, fun) {
+ sg_platf_host_cb_t fun;
+ xbt_dynar_foreach(sg_platf_host_cb_list, iterator, fun) {
if (fun) (*fun) (h);
}
}
-void sg_platf_new_router(surf_parsing_router_arg_t router) {
+void sg_platf_new_router(sg_platf_router_cbarg_t router) {
unsigned int iterator;
- surf_parse_router_fct_t fun;
- xbt_dynar_foreach(surf_parse_router_cb_list, iterator, fun) {
+ sg_platf_router_cb_t fun;
+ xbt_dynar_foreach(sg_platf_router_cb_list, iterator, fun) {
if (fun) (*fun) (router);
}
}
-void surf_parse_host_add_cb(surf_parse_host_fct_t fct) {
- xbt_dynar_push(surf_parse_host_cb_list, &fct);
+void sg_platf_host_add_cb(sg_platf_host_cb_t fct) {
+ xbt_dynar_push(sg_platf_host_cb_list, &fct);
}
-void surf_parse_router_add_cb(surf_parse_router_fct_t fct) {
- xbt_dynar_push(surf_parse_router_cb_list, &fct);
+void sg_platf_router_add_cb(sg_platf_router_cb_t fct) {
+ xbt_dynar_push(sg_platf_router_cb_list, &fct);
}
/*
* \brief Add a host to the network element list from XML
*/
-static void parse_S_host_XML(surf_parsing_host_arg_t h)
+static void parse_S_host_XML(sg_platf_host_cbarg_t h)
{
parse_S_host(h->V_host_id, h->V_host_coord);
}
/**
* \brief Add a "router" to the network element list
*/
-static void parse_S_router(surf_parsing_router_arg_t router)
+static void parse_S_router(sg_platf_router_cbarg_t router)
{
network_element_info_t info = NULL;
if (current_routing->hierarchy == SURF_ROUTING_NULL)
* brief Add a "router" to the network element list from XML description
*/
static void parse_S_router_lua(const char* router_id) {
- s_surf_parsing_router_arg_t router;
+ s_sg_platf_router_cbarg_t router;
memset(&router,0,sizeof(router));
router.V_router_id = router_id;
router.V_router_coord = "";
current_routing = NULL;
/* parse generic elements */
- surf_parse_host_add_cb(parse_S_host_XML);
+ sg_platf_host_add_cb(parse_S_host_XML);
surfxml_add_callback(ETag_surfxml_host_cb_list, &parse_E_host_XML);
- surf_parse_router_add_cb(parse_S_router);
+ sg_platf_router_add_cb(parse_S_router);
surfxml_add_callback(STag_surfxml_route_cb_list,
&parse_S_route_new_and_endpoints_XML);
static void parse_create_host_link(int i)
{
char *host_id, *link_id = NULL;
- s_surf_parsing_host_arg_t host;
+ s_sg_platf_host_cbarg_t host;
memset(&host,0,sizeof(host));
host_id = bprintf("%s%d%s", struct_cluster->V_cluster_prefix, i, struct_cluster->V_cluster_suffix);
static int AX_ptr = 0;
char *host_id, *groups, *link_id = NULL;
- s_surf_parsing_host_arg_t host;
+ s_sg_platf_host_cbarg_t host;
if( strcmp(struct_cluster->V_cluster_availability_file,"")
|| strcmp(struct_cluster->V_cluster_state_file,"") )
}
void STag_surfxml_host(void){
- s_surf_parsing_host_arg_t host;
+ s_sg_platf_host_cbarg_t host;
memset(&host,0,sizeof(host));
host.V_host_id = A_surfxml_host_id;
void STag_surfxml_router(void){
- s_surf_parsing_router_arg_t router;
+ s_sg_platf_router_cbarg_t router;
memset(&router, 0, sizeof(router));
router.V_router_id = xbt_strdup(A_surfxml_router_id);
* Pass arguments to parsing callback as structures to save some time (and allow callbacks to ignore some)
*/
-surf_parsing_router_arg_t struct_router = NULL;
+sg_platf_router_cbarg_t struct_router = NULL;
surf_parsing_cluster_arg_t struct_cluster = NULL;
surf_parsing_peer_arg_t struct_peer = NULL;
surf_parsing_link_arg_t struct_lnk = NULL;
return cpu;
}
-static void ptask_parse_cpu_init(surf_parsing_host_arg_t host)
+static void ptask_parse_cpu_init(sg_platf_host_cbarg_t host)
{
ptask_cpu_create_resource(
host->V_host_id,
static void ptask_define_callbacks()
{
/* Adding callback functions */
- surf_parse_host_add_cb(ptask_parse_cpu_init);
+ sg_platf_host_add_cb(ptask_parse_cpu_init);
surfxml_add_callback(ETag_surfxml_link_cb_list, &ptask_parse_link_init);
surfxml_add_callback(ETag_surfxml_platform_cb_list, &ptask_add_traces);
}