Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
83786e34c28105681aed17746b5793894ed612d5
[simgrid.git] / src / kernel / routing / DijkstraZone.hpp
1 /* Copyright (c) 2013-2016. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef SURF_ROUTING_DIJKSTRA_HPP_
7 #define SURF_ROUTING_DIJKSTRA_HPP_
8
9 #include "src/kernel/routing/RoutedZone.hpp"
10
11 typedef struct graph_node_data {
12   int id;
13   int graph_id; /* used for caching internal graph id's */
14 } s_graph_node_data_t, *graph_node_data_t;
15
16 typedef struct graph_node_map_element {
17   xbt_node_t node;
18 } s_graph_node_map_element_t, *graph_node_map_element_t;
19
20 typedef struct route_cache_element {
21   int* pred_arr;
22   int size;
23 } s_route_cache_element_t, *route_cache_element_t;
24
25 namespace simgrid {
26 namespace kernel {
27 namespace routing {
28
29 /***********
30  * Classes *
31  ***********/
32
33 /** @ingroup ROUTING_API
34  *  @brief NetZone with an explicit routing computed on need with Dijsktra
35  *
36  *  The path between components is computed each time you request it,
37  *  using the Dijkstra algorithm. A cache can be used to reduce the computation.
38  *
39  *  This result in rather small platform file, very fast initialization, and intermediate memory requirements
40  *  (somewhere between the one of @DijkstraZone and the one of @FullZone).
41  */
42 class XBT_PRIVATE DijkstraZone : public RoutedZone {
43 public:
44   DijkstraZone(NetZone* father, const char* name, bool cached);
45   void seal() override;
46
47   ~DijkstraZone() override;
48   xbt_node_t routeGraphNewNode(int id, int graph_id);
49   graph_node_map_element_t nodeMapSearch(int id);
50   void newRoute(int src_id, int dst_id, sg_platf_route_cbarg_t e_route);
51   /* For each vertex (node) already in the graph,
52    * make sure it also has a loopback link; this loopback
53    * can potentially already be in the graph, and in that
54    * case nothing will be done.
55    *
56    * If no loopback is specified for a node, we will use
57    * the loopback that is provided by the routing platform.
58    *
59    * After this function returns, any node in the graph
60    * will have a loopback attached to it.
61    */
62   void getLocalRoute(NetCard* src, NetCard* dst, sg_platf_route_cbarg_t route, double* lat) override;
63   void addRoute(sg_platf_route_cbarg_t route) override;
64
65   xbt_graph_t routeGraph_  = nullptr; /* xbt_graph */
66   xbt_dict_t graphNodeMap_ = nullptr; /* map */
67   xbt_dict_t routeCache_   = nullptr; /* use in cache mode */
68 };
69 }
70 }
71 } // namespaces
72
73 #endif /* SURF_ROUTING_DIJKSTRA_HPP_ */