Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge remote-tracking branch 'upstream/master'
[simgrid.git] / include / simgrid / jedule / jedule_platform.hpp
1 /* Copyright (c) 2010-2018. 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 #include <xbt/dynar.h>
11
12 #include <unordered_map>
13 #include <vector>
14 #include <string>
15
16 namespace simgrid {
17 namespace jedule{
18 class XBT_PUBLIC Container {
19 public:
20   explicit Container(std::string name);
21   virtual ~Container();
22 private:
23   int last_id_;
24   int is_lowest_ = 0;
25
26 public:
27   std::string name;
28   std::unordered_map<const char*, unsigned int> name2id;
29   Container *parent = nullptr;
30   std::vector<Container*> children;
31   std::vector<sg_host_t> resource_list;
32   void add_child(Container* child);
33   void add_resources(std::vector<sg_host_t> hosts);
34   void create_hierarchy(sg_netzone_t from_as);
35   std::vector<int> get_hierarchy();
36   std::string get_hierarchy_as_string();
37   void print(FILE *file);
38   void print_resources(FILE* file);
39
40   // deprecated
41   XBT_ATTRIB_DEPRECATED_v323("Please use Container::add_child()") void addChild(Container* child) { add_child(child); }
42   XBT_ATTRIB_DEPRECATED_v323("Please use Container::add_resources()") void addResources(std::vector<sg_host_t> hosts)
43   {
44     add_resources(hosts);
45   }
46   XBT_ATTRIB_DEPRECATED_v323("Please use Container::create_hierarchy()") void createHierarchy(sg_netzone_t from_as)
47   {
48     create_hierarchy(from_as);
49   }
50   XBT_ATTRIB_DEPRECATED_v323("Please use Container::get_hierarchy()") std::vector<int> getHierarchy()
51   {
52     return get_hierarchy();
53   }
54   XBT_ATTRIB_DEPRECATED_v323("Please use Container::get_hierarchy_as_string()") std::string getHierarchyAsString()
55   {
56     return get_hierarchy_as_string();
57   }
58   XBT_ATTRIB_DEPRECATED_v323("Please use Container::print_resources()") void printResources(FILE* file)
59   {
60     print_resources(file);
61   }
62 };
63
64 class XBT_PUBLIC Subset {
65 public:
66   Subset(int s, int n, Container* p);
67   virtual ~Subset()=default;
68   int start_idx; // start idx in resource_list of container
69   int nres;      // number of resources spanning starting at start_idx
70   Container *parent;
71 };
72
73 }
74 }
75 typedef simgrid::jedule::Container * jed_container_t;
76 typedef simgrid::jedule::Subset * jed_subset_t;
77 void get_resource_selection_by_hosts(std::vector<jed_subset_t>* subset_list, std::vector<sg_host_t> *host_list);
78
79 #endif /* JED_SIMGRID_PLATFORM_H_ */