Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of github.com:simgrid/simgrid
[simgrid.git] / include / simgrid / jedule / jedule_platform.hpp
1 /* Copyright (c) 2010-2020. 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 JED_SIMGRID_PLATFORM_H_
7 #define JED_SIMGRID_PLATFORM_H_
8
9 #include <simgrid/forward.h>
10
11 #include <memory>
12 #include <string>
13 #include <unordered_map>
14 #include <vector>
15
16 namespace simgrid {
17 namespace jedule{
18 class XBT_PUBLIC Container {
19   int last_id_ = 0;
20   std::string name;
21   std::unordered_map<const char*, unsigned int> name2id;
22   Container* parent_ = nullptr;
23   std::vector<std::unique_ptr<Container>> children_;
24   std::vector<sg_host_t> resource_list;
25
26 public:
27   explicit Container(const std::string& name);
28   Container(const Container&) = delete;
29   Container& operator=(const Container&) = delete;
30
31   const char* get_cname() const { return name.c_str(); }
32   void set_parent(Container* parent) { parent_ = parent; }
33   bool has_children() const { return not children_.empty(); }
34   int get_child_position(const Container* child) const;
35   unsigned int get_id_by_name(const char* name) const { return name2id.at(name); }
36
37   void add_child(Container* child);
38   void add_resources(std::vector<sg_host_t> hosts);
39   void create_hierarchy(const_sg_netzone_t from_as);
40   std::vector<int> get_hierarchy();
41   std::string get_hierarchy_as_string();
42   void print(FILE *file);
43   void print_resources(FILE* file);
44 };
45
46 class XBT_PUBLIC Subset {
47 public:
48   Subset(int s, int n, Container* p);
49   int start_idx; // start idx in resource_list of container
50   int nres;      // number of resources spanning starting at start_idx
51   Container *parent;
52 };
53
54 } // namespace jedule
55 } // namespace simgrid
56 using jed_container_t = simgrid::jedule::Container*;
57 void get_resource_selection_by_hosts(std::vector<simgrid::jedule::Subset>& subset_list,
58                                      const std::vector<sg_host_t>& host_list);
59
60 #endif /* JED_SIMGRID_PLATFORM_H_ */