1 /* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved. */
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. */
6 #ifndef JED_SIMGRID_PLATFORM_H_
7 #define JED_SIMGRID_PLATFORM_H_
9 #include <simgrid/forward.h>
13 #include <unordered_map>
18 class XBT_PUBLIC Container {
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;
27 explicit Container(const std::string& name);
28 Container(const Container&) = delete;
29 Container& operator=(const Container&) = delete;
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); }
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);
46 class XBT_PUBLIC Subset {
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
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);
60 #endif /* JED_SIMGRID_PLATFORM_H_ */