Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
3efd11cf4a903e1ab4b236e4efb65179f2beadbe
[simgrid.git] / include / simgrid / jedule / jedule_platform.hpp
1 /* Copyright (c) 2010-2012, 2014-2016. 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
7 #ifndef JED_SIMGRID_PLATFORM_H_
8 #define JED_SIMGRID_PLATFORM_H_
9
10 #include "simgrid_config.h"
11 #include "simgrid/forward.h"
12 #include "xbt/dynar.h"
13 #include <unordered_map>
14 #include <vector>
15 #include <string>
16
17 #if HAVE_JEDULE
18
19 namespace simgrid {
20 namespace jedule{
21 XBT_PUBLIC_CLASS Container {
22 public:
23   Container(std::string name);
24   virtual ~Container();
25 private:
26   int last_id;
27   int is_lowest = 0;
28 public:
29   std::string name;
30   std::unordered_map<const char*, int> name2id;
31   Container *parent = nullptr;
32   std::vector<Container*> children;
33   std::vector<sg_host_t> resource_list;
34   void addChild(Container* child);
35   void addResources(std::vector<sg_host_t> hosts);
36   void createHierarchy(AS_t from_as);
37   std::vector<int> getHierarchy();
38   std::string getHierarchyAsString();
39   void print(FILE *file);
40   void printResources(FILE *file);
41 };
42
43 }
44 }
45 SG_BEGIN_DECL()
46 typedef simgrid::jedule::Container * jed_container_t;
47
48 /* FIXME: jedule_container should be objectified too */
49 /** selection of a subset of resources from the original set */
50 struct jed_res_subset {
51   jed_container_t parent;
52   int start_idx; // start idx in resource_list of container
53   int nres;      // number of resources spanning starting at start_idx
54 };
55
56 typedef struct jed_res_subset s_jed_res_subset_t, *jed_res_subset_t;
57
58 /**
59  * it is assumed that the host_names in the entire system are unique that means that we don't need parent references
60  *
61  * subset_list must be allocated
62  * host_names is the list of host_names associated with an event
63  */
64 void jed_simgrid_get_resource_selection_by_hosts(xbt_dynar_t subset_list, std::vector<sg_host_t>* host_list);
65
66 /*
67   global:
68       hash host_id -> container
69   container:
70       hash host_id -> jed_host_id
71       list <- [ jed_host_ids ]
72       list <- sort( list )
73       list_chunks <- chunk( list )   -> [ 1, 3-5, 7-9 ]
74 */
75
76 SG_END_DECL()
77
78 #endif
79
80 #endif /* JED_SIMGRID_PLATFORM_H_ */