Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove misleading comment
[simgrid.git] / src / surf / surf_routing_cluster.c
1 /* Copyright (c) 2009, 2010, 2011. 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 #include "surf_routing_private.h"
7
8 /* Global vars */
9
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster, surf, "Routing part of surf");
11
12 /* This routing is specifically setup to represent clusters, aka homogeneous sets of machines
13  * Note that a router is created, easing the interconnexion with the rest of the world.
14  */
15
16 typedef struct {
17   s_as_t generic_routing;
18   void *backbone;
19 } s_as_cluster_t, *as_cluster_t;
20
21
22 static xbt_dict_t cluster_host_link = NULL;
23
24 /* Business methods */
25 static void cluster_get_route_and_latency(AS_t as,
26                                           const char *src, const char *dst,
27                                           route_t route, double *lat) {
28
29           surf_parsing_link_up_down_t info;
30
31           info = xbt_dict_get_or_null(cluster_host_link,src);
32           if(info) { // link up
33             xbt_dynar_push_as(route->link_list,void*,info->link_up);
34       if (lat)
35         *lat += surf_network_model->extension.network.get_link_latency(info->link_up);
36           }
37
38           if ( ((as_cluster_t)as)->backbone ) {
39             xbt_dynar_push_as(route->link_list,void*, ((as_cluster_t)as)->backbone) ;
40       if (lat)
41         *lat += surf_network_model->extension.network.get_link_latency(((as_cluster_t)as)->backbone);
42           }
43
44           info = xbt_dict_get_or_null(cluster_host_link,dst);
45           if(info) { // link down
46             xbt_dynar_push_as(route->link_list,void*,info->link_down);
47       if (lat)
48         *lat += surf_network_model->extension.network.get_link_latency(info->link_down);
49           }
50 }
51
52 static void model_cluster_finalize(AS_t as) {
53   xbt_dict_free(&cluster_host_link);
54   model_none_finalize(as);
55 }
56 /* Creation routing model functions */
57 AS_t model_cluster_create(void)
58 {
59   AS_t result = model_none_create_sized(sizeof(s_as_cluster_t));
60   result->get_route_and_latency = cluster_get_route_and_latency;
61   result->finalize = model_cluster_finalize;
62
63   return (AS_t) result;
64 }
65
66 void surf_routing_cluster_add_link(const char* host_id,surf_parsing_link_up_down_t info) {
67   if(!cluster_host_link)
68     cluster_host_link = xbt_dict_new_homogeneous(xbt_free);
69
70  xbt_dict_set(cluster_host_link,host_id,info,NULL);
71 }
72
73 void surf_routing_cluster_add_backbone(AS_t as, void* bb) {
74   ((as_cluster_t)as)->backbone = bb;
75 }