CGRA-ME
ClusteredMapper.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * The software programs comprising "CGRA-ME" and the documentation provided
3  * with them are copyright by its authors and the University of Toronto. Only
4  * non-commercial, not-for-profit use of this software is permitted without ex-
5  * plicit permission. This software is provided "as is" with no warranties or
6  * guarantees of support. See the LICENCE for more details. You should have re-
7  * ceived a copy of the full licence along with this software. If not, see
8  * <http://cgra-me.ece.utoronto.ca/license/>.
9  ******************************************************************************/
10 
11 #pragma once
12 
13 #include <CGRA/CGRA.h>
14 #include <CGRA/OpGraph.h>
15 #include <CGRA/Mapper.h>
16 #include <CGRA/Mapping.h>
17 #include <CGRA/OpScheduler.h>
19 
20 #include <map>
21 #include <memory>
22 #include <random>
23 #include <unordered_map>
24 #include <set>
25 #include <string>
26 #include <vector>
27 #include <queue>
28 #include <unordered_set>
29 #include <utility>
30 #include <bits/stdc++.h> // NOLINT
31 
32 using MRRGNodeDesc = MRRG::NodeDescriptor; // const MRRGNode*
33 using OpGraphOpDesc = OpGraph::OpDescriptor; // const OpGraphOp*
34 using OpGraphValDesc = OpGraph::ValDescriptor; // const OpGraphVal*
35 using Latency = int;
36 
41 struct ClusteredMapperDriver : public Mapper {
42  static constexpr Latency kUndefLatency = -1;
43 
44  ClusteredMapperDriver(std::shared_ptr<CGRA> cgra, int timelimit, const ConfigStore& args);
48  Mapping mapOpGraph(std::shared_ptr<OpGraph> opgraph,
49  const int II,
50  const MRRG& mrrg,
51  std::unordered_map<std::string, std::string> fix_port) override;
52 
53 
54  public:
55  const int l_print;
56 
57  protected:
58  Mapping mapStatic(std::shared_ptr<OpGraph> opgraph,
59  const int II,
60  const MRRG& mrrg,
61  std::unordered_map<std::string, std::string> fix_port,
63  Mapping mapElastic(std::shared_ptr<OpGraph> opgraph,
64  const int II,
65  const MRRG& mrrg,
66  std::unordered_map<std::string, std::string> fix_port,
69  bool isAllOpsSupported(const OpGraph& opgraph, const MRRG& mrrg);
70  void printPlacementNeato(int i, const OpGraph& opgraph, Mapping placed, std::unordered_map<OpGraphOpDesc, int> sched);
71  const int l_rand_seed;
72  const double l_p_factor_factor;
73  const double l_initial_pfactor;
74  const double l_initial_hfactor;
75  const double l_h_factor_factor;
76  const int l_swap_factor;
77  const int l_fanout_threshold;
78  const int l_ram_ports;
79  const int l_verbosity;
80  const bool l_cluster;
83  const std::string l_arch_name;
85  const int l_cost_func;
87  std::vector<std::vector<OpGraphOpDesc>> l_clusters;
88  std::map<OpGraphOpDesc, int> l_op_cluster_index;
89  std::unordered_map<OpGraphOpDesc, std::vector<std::string>> l_ops_to_node_names;
90  std::unordered_map<OpGraphOpDesc, int> l_schedule;
92 };
93 
94 
97  {}
98  int occupancy = 0;
99  double baseCost = 0.0;
100  double hCost = 0.0; // historical cost
101  std::vector<OpGraphValDesc> mapped_values {};
102 };
103 
104 struct BoundingBox {
105  int x_max = 0;
106  int x_min = 0;
107  int y_max = 0;
108  int y_min = 0;
109  int z_max = 0;
110  int z_min = 0;
111 };
112 
120  public:
121  static constexpr Latency kUndefLatency = -1;
122 
124  const OpGraph& opgraph,
125  const MRRG& mrrg,
126  bool isElastic = false,
127  const std::string placement_filename = "");
128  Mapping routeOpGraph(Mapping placement);
129 
130  struct UnmappableException : std::runtime_error { using runtime_error::runtime_error; };
131  //void printCriticalPath();
132  private:
133  void parsePlacementFile();
135 
136  bool routeVal(OpGraphValDesc);
137  std::vector<const MRRGNode*> dijkstraVisit(const MRRGNode*,
138  const MRRGNode* , OperandTag,
139  OpGraphValDesc, std::set<const MRRGNode*>, int, int);
140  void mapMRRGNode(OpGraphValDesc, const MRRGNode*);
141 
142  bool isOpgraphCovered();
143 
144  bool checkOveruse();
145 
146  double getCost(const MRRGNode*);
148 
149  void setMappingInto(Mapping& m) const { // NOLINT
150  for (const auto& op_and_mapping : l_mapping) {
151  std::vector<MRRGNodeDesc> as_mrrg;
152  for (const auto& n : op_and_mapping.second) as_mrrg.push_back(n);
153  m.setNodeMapping(op_and_mapping.first, std::move(as_mrrg));
154  }
155  }
156 
158  double l_p_factor;
159  double l_h_factor;
160  const MRRG& l_mrrg;
162  std::string l_placement_filename;
163  std::vector<MRRGNodeDesc> l_critical_path;
164  std::set<MRRGNodeDesc> l_used_rounting_function_nodes;
165  std::map<const OpGraphNode*, const MRRGNode*> l_placement;
166  std::unordered_map<const MRRGNode*, NodeAttributes> l_routing_nodes;
167  std::map<OpGraphValDesc, std::vector<const MRRGNode*>> l_mapping = {};
168 };
169 
171  public:
172  static constexpr Latency kUndefLatency = -1;
174  Module* topLevelModule,
175  std::shared_ptr<OpGraph> opgraph,
176  const MRRG& mrrg,
177  int rows, int cols,
178  int II, bool isElastic = false);
179 
180  using OpsNotToCluster = std::pair<OpGraphOpDesc, OpGraphOpDesc>;
181  // Sets clusters for memory operations that needs to be set to the same memory port
182  void clusterMemoryOperations(std::set<OpGraphOpDesc>*);
183 
184  // Gets the operations that have no inputs
185  void getFirstOps(std::queue<OpGraphOpDesc>& operations);
186 
187  bool clusterPEs(bool cluster);
188  void createSingleOpClusters();
189  bool checkIfOutputPortsNeeded(OpGraphValDesc val, std::vector<OpGraphOpDesc> &ops);
190  bool checkIfInputPortsNeeded(OpGraphOpDesc source_op, std::vector<OpGraphOpDesc> &ops);
191  bool checkPortConn(std::vector<std::pair<OpGraphOpDesc, OpGraphOpDesc>>& global_port_connection, int i,
192  std::set<MRRGNodeDesc> ports_used,
193  std::set<OpGraphOpDesc> out_port_found,
194  std::map<OpGraphOpDesc, std::set<MRRGNodeDesc>>& op_to_port_nodes,
195  std::string submodule, bool isInput);
196  bool checkPortsOfOperation(std::vector<std::pair<OpGraphOpDesc, OpGraphOpDesc>> global_port_connection, std::map<OpGraphOpDesc, std::vector<MRRGNodeDesc>>& ops_mrrg_nodes,
197  std::set<OpGraphOpDesc> exlusive_port_operation, std::string submodule, bool isInput);
198  bool checkConnectedOperations(std::pair<OpGraphOpDesc, OpGraphOpDesc>, std::map<OpGraphOpDesc, std::vector<MRRGNodeDesc>>& ops_mrrg_nodes,
199  std::string submodule);
200  /*bool checkInputsOfOperation(OpGraphOpDesc val, std::vector<OpGraphOpDesc> &ops, std::vector<MRRGNodeDesc>& source_op_nodes,
201  std::string submodule);
202  bool checkOutputsOfOperation(OpGraphOpDesc val, std::vector<OpGraphOpDesc> &ops, std::vector<MRRGNodeDesc>& source_op_nodes,
203  std::string submodule);
204  */
205  void setSourceOpNodes(std::vector<MRRGNodeDesc>& source_op_nodes, OpGraphOpDesc source_op, std::string submodule);
207  void getModulesToMapOp(OpGraphOpDesc op, std::map<std::string, MRRGNodeDesc>& modules_could_map_op);
208  void setReachesOutputPorts(std::map<MRRGNodeDesc, std::set<MRRGNodeDesc>>& connected_nodes,
209  std::vector<MRRGNodeDesc>& op_mrrg_nodes, std::string submodule);
210  void setReachesInputPorts(std::map<MRRGNodeDesc, std::set<MRRGNodeDesc>>& connected_nodes,
211  std::vector<MRRGNodeDesc>& op_mrrg_nodes, std::string submodule);
212  void addNextOps(std::vector<OpGraphOpDesc>* next_ops, OpGraphOpDesc op);
213  bool checkReachbitlity(std::vector<OpGraphOpDesc>&, std::string);
214  void setPortsForSubmodule(std::string);
215  bool isReachable(MRRGNodeDesc source, MRRGNodeDesc sink, std::string, Latency cycles = -1);
217  void opsCouldBeClustered(
218  std::vector<OpGraphOpDesc> nextOps, std::vector<MRRGNodeDesc> &used_nodes, //NOLINT
219  std::vector<OpGraphOpDesc> &used_ops, std::set<OpGraphOpDesc> &visitedOps, std::string subModule); //NOLINT
220 
221  // Getters and setters for different variables of the class
222  std::unordered_map<OpGraphOpDesc, std::vector<std::string>> getOpsNodeNames() {return l_ops_to_node_names;}
223  std::vector<std::vector<OpGraphOpDesc>> getClusters() {return l_clusters;}
224  std::map<OpGraphOpDesc, int> getOpClusterIndex() {return l_op_cluster_index;}
225  void printOps (std::vector<OpGraphOpDesc>& ops);
226  void printNodes (std::vector<MRRGNodeDesc>& mrrg_nodes);
227  void setSchedule(std::unordered_map<OpGraphOpDesc, int> s) {l_schedule = s;}
228  void unsetReschedule() {l_reschedule = false;}
229  using opPair = std::pair<OpGraphOp*, OpGraphOp*>;
230  std::unordered_map<opPair , int, pair_hash> extended_sched_const;
231 
232  private:
233  bool l_reschedule = false;
235  int l_II;
236  int l_rows;
237  int l_cols;
239  std::shared_ptr<OpGraph> l_opgraph;
240  const MRRG& l_mrrg;
241  std::set<OpsNotToCluster> l_ops_not_clustered;
242  std::map<std::string, MRRG*> l_subModule_MRRGs;
243  std::unordered_set<OpGraphOpDesc> l_clustered_ops;
244  std::map<std::string, std::vector<MRRGNodeDesc>> l_function_nodes;
245  std::map<std::string, std::vector<MRRGNodeDesc>> l_routing_nodes;
246  std::map<std::string, std::set<MRRGNodeDesc>> l_submodule_input_ports;
247  std::map<std::string, std::set<MRRGNodeDesc>> l_submodule_output_ports;
248  std::map<std::string, std::vector<std::vector<OpGraphOpDesc>>> l_mem_name_ops;
249 };
250 
258  public:
260  const OpGraph& opgraph,
261  const MRRG& mrrg,
262  std::unordered_map<std::string, std::string> fix_ports,
263  int rows,
264  int cols,
265  bool isElastic = false);
266  // ~AnnealPlacer();
267  Mapping placeOpGraph(float temp);
268 
269  struct UnmappableException : std::runtime_error { using runtime_error::runtime_error; };
270  void clearPlacement();
271  void setInitialPlacement();
272  float determineTemperature(float scale);
273 
274  private:
276  std::pair<bool, float> inner_place_and_route_loop(float temp);
277 
281  std::vector<MRRGNodeDesc> getRandomFUs(std::vector<OpGraphOpDesc> ops, bool occupied);
283 
285  void ripUpOp(OpGraphOpDesc op);
286  bool placeOp(OpGraphOpDesc op, MRRGNodeDesc n);
287 
291 
296  bool isClusterFixed(std::vector<OpGraphOpDesc> cluster);
297 
299  bool accept(float delta_cost, float temperature) const;
300  float nextTemperature(float t, float accept_rate) const;
301 
303  bool isOpgraphCovered() const;
304  bool checkOveruse();
306 
309  double getTotalCost();
310  void swap(OpGraphOpDesc op, MRRGNodeDesc node, std::map<OpGraphOpDesc, MRRGNodeDesc>& old_placement);
311 
312 
313  void setMappingInto(Mapping& m) const { // NOLINT
314  for (const auto& op_and_mapping : l_mapping) {
315  std::vector<MRRGNodeDesc> as_mrrg;
316  for (const auto& n : op_and_mapping.second) as_mrrg.push_back(n);
317  m.setNodeMapping(op_and_mapping.first, std::move(as_mrrg));
318  }
319  }
320  void printMapping() const { printMapping(std::cout); } // makes it easier to call from a debugger NOLINT
321  void printMapping(std::ostream& os) const {
322  auto cpy = l_empty_mapping_result;
323  setMappingInto(cpy);
324  cpy.outputMapping(os);
325  }
326 
327  int l_rows = 0;
328  int l_cols = 0;
329  int l_II;
331  const MRRG& l_mrrg;
333 
334  using OpCodeByCycle = std::pair<OpGraphOpCode, int>;
335 
336  std::set<MRRGNodeDesc> l_fixed_mrrg_nodes;
337  mutable std::minstd_rand l_randomInt;
338  std::unordered_map<std::string, std::string> l_fix_ports;
339  std::map<const MRRGNode*, NodeAttributes> l_function_nodes;
340  std::map<OpGraph::NodeDescriptor, std::vector<MRRGNodeDesc>> l_mapping = {};
341  std::map<OpGraphOpCode, std::vector<std::vector<MRRGNodeDesc>>> l_grid;
342  std::unordered_map<OpCodeByCycle, std::vector<MRRGNodeDesc>, pair_hash> l_op_to_nodes;
343 
344  std::size_t randomUintBelow(std::size_t past_end) const { return l_randomInt() % past_end; } // want speed
345  double randomRealBetween0And1() const { return l_randomInt() / static_cast<double>(l_randomInt.max()); } // want speed
346 };
AnnealPlacer::l_isElastic
bool l_isElastic
Definition: ClusteredMapper.h:330
AnnealPlacer::l_function_nodes
std::map< const MRRGNode *, NodeAttributes > l_function_nodes
Definition: ClusteredMapper.h:339
ClusteredMapperDriver::l_op_sched
OpScheduler * l_op_sched
Definition: ClusteredMapper.h:86
ClusteredMapperDriver::l_cost_func
const int l_cost_func
Definition: ClusteredMapper.h:85
TMPack::TMPack
TMPack(ClusteredMapperDriver &driver, Module *topLevelModule, std::shared_ptr< OpGraph > opgraph, const MRRG &mrrg, int rows, int cols, int II, bool isElastic=false)
Definition: TMPack.cpp:26
CodeProfiling.h
TMPack::getClusters
std::vector< std::vector< OpGraphOpDesc > > getClusters()
Definition: ClusteredMapper.h:223
ClusteredMapperDriver::ClusteredMapperDriver
ClusteredMapperDriver(std::shared_ptr< CGRA > cgra, int timelimit, const ConfigStore &args)
Definition: ClusteredMapper.cpp:52
ClusteredMapperDriver::printPlacementNeato
void printPlacementNeato(int i, const OpGraph &opgraph, Mapping placed, std::unordered_map< OpGraphOpDesc, int > sched)
Definition: ClusteredMapper.cpp:254
AnnealPlacer::l_rows
int l_rows
Definition: ClusteredMapper.h:327
OperandTag
std::string OperandTag
Definition: OpGraph.h:81
PathFinder::routeVal
bool routeVal(OpGraphValDesc)
Definition: Pathfinder.cpp:242
AnnealPlacer::placeOp
bool placeOp(OpGraphOpDesc op, MRRGNodeDesc n)
Definition: AnnealPlacer.cpp:233
PathFinder::l_p_factor
double l_p_factor
Definition: ClusteredMapper.h:158
OpGraph.h
AnnealPlacer::getTotalCost
double getTotalCost()
Definition: AnnealPlacer.cpp:73
TMPack::l_opgraph
std::shared_ptr< OpGraph > l_opgraph
Definition: ClusteredMapper.h:239
TMPack::extended_sched_const
std::unordered_map< opPair, int, pair_hash > extended_sched_const
Definition: ClusteredMapper.h:230
AnnealPlacer::printMapping
void printMapping(std::ostream &os) const
Definition: ClusteredMapper.h:321
MRRG
Definition: MRRG.h:216
AnnealPlacer::getRandomFUs
std::vector< MRRGNodeDesc > getRandomFUs(std::vector< OpGraphOpDesc > ops, bool occupied)
Definition: AnnealPlacer.cpp:577
ClusteredMapperDriver::l_schedule
std::unordered_map< OpGraphOpDesc, int > l_schedule
Definition: ClusteredMapper.h:90
MRRG::NodeDescriptor
const MRRGNode * NodeDescriptor
Definition: MRRG.h:219
OpGraph::ValDescriptor
const OpGraphVal * ValDescriptor
Definition: OpGraph.h:220
Location
Definition: Module.h:156
ClusteredMapperDriver
Proxy class that makes a new instance of the for ever call. Holds constant configuration info,...
Definition: ClusteredMapper.h:41
PathFinder::routeOpGraph
Mapping routeOpGraph(Mapping placement)
Definition: Pathfinder.cpp:51
ClusteredMapperDriver::isAllOpsSupported
bool isAllOpsSupported(const OpGraph &opgraph, const MRRG &mrrg)
Definition: ClusteredMapper.cpp:237
BoundingBox::y_min
int y_min
Definition: ClusteredMapper.h:108
PathFinder::printNumberOfResourcesUsed
void printNumberOfResourcesUsed()
Definition: Pathfinder.cpp:163
AnnealPlacer::l_mrrg
const MRRG & l_mrrg
Definition: ClusteredMapper.h:331
AnnealPlacer::setInitialPlacement
void setInitialPlacement()
Definition: AnnealPlacer.cpp:620
Latency
int Latency
Definition: ClusteredMapper.h:35
TMPack::l_mem_name_ops
std::map< std::string, std::vector< std::vector< OpGraphOpDesc > > > l_mem_name_ops
Definition: ClusteredMapper.h:248
AnnealPlacer::OpCodeByCycle
std::pair< OpGraphOpCode, int > OpCodeByCycle
Definition: ClusteredMapper.h:334
PathFinder::isOpgraphCovered
bool isOpgraphCovered()
Definition: Pathfinder.cpp:152
TMPack::l_ops_not_clustered
std::set< OpsNotToCluster > l_ops_not_clustered
Definition: ClusteredMapper.h:241
TMPack::getOpsNodeNames
std::unordered_map< OpGraphOpDesc, std::vector< std::string > > getOpsNodeNames()
Definition: ClusteredMapper.h:222
AnnealPlacer::l_op_to_nodes
std::unordered_map< OpCodeByCycle, std::vector< MRRGNodeDesc >, pair_hash > l_op_to_nodes
Definition: ClusteredMapper.h:342
PathFinder::setMappingInto
void setMappingInto(Mapping &m) const
Definition: ClusteredMapper.h:149
AnnealPlacer::l_grid
std::map< OpGraphOpCode, std::vector< std::vector< MRRGNodeDesc > > > l_grid
Definition: ClusteredMapper.h:341
NodeAttributes::NodeAttributes
NodeAttributes()
Definition: ClusteredMapper.h:96
TMPack::printNodes
void printNodes(std::vector< MRRGNodeDesc > &mrrg_nodes)
Definition: TMPack.cpp:826
AnnealPlacer::checkOveruse
bool checkOveruse()
Definition: AnnealPlacer.cpp:166
PathFinder::ripUpOpVal
void ripUpOpVal(OpGraphValDesc)
Definition: Pathfinder.cpp:199
BoundingBox::y_max
int y_max
Definition: ClusteredMapper.h:107
BoundingBox::z_min
int z_min
Definition: ClusteredMapper.h:110
TMPack::l_submodule_input_ports
std::map< std::string, std::set< MRRGNodeDesc > > l_submodule_input_ports
Definition: ClusteredMapper.h:246
AnnealPlacer::clearPlacement
void clearPlacement()
Definition: AnnealPlacer.cpp:633
ConfigStore
Definition: ConfigStore.h:76
ClusteredMapperDriver::l_arch_name
const std::string l_arch_name
Definition: ClusteredMapper.h:83
TMPack::localMRRG
MRRG * localMRRG
Definition: ClusteredMapper.h:234
TMPack::getFirstOps
void getFirstOps(std::queue< OpGraphOpDesc > &operations)
Definition: TMPack.cpp:194
Mapper
Common interface for mappers.
Definition: Mapper.h:28
pair_hash
Definition: Util.h:24
PathFinder::dijkstraVisit
std::vector< const MRRGNode * > dijkstraVisit(const MRRGNode *, const MRRGNode *, OperandTag, OpGraphValDesc, std::set< const MRRGNode * >, int, int)
Definition: Pathfinder.cpp:317
ClusteredMapperDriver::l_ram_ports
const int l_ram_ports
Definition: ClusteredMapper.h:78
TMPack::l_submodule_output_ports
std::map< std::string, std::set< MRRGNodeDesc > > l_submodule_output_ports
Definition: ClusteredMapper.h:247
AnnealPlacer::getOpMapedAt
OpGraphOpDesc getOpMapedAt(MRRGNodeDesc n)
Definition: AnnealPlacer.cpp:189
ClusteredMapperDriver::l_initial_hfactor
const double l_initial_hfactor
Definition: ClusteredMapper.h:74
AnnealPlacer::placeOpGraph
Mapping placeOpGraph(float temp)
Definition: AnnealPlacer.cpp:640
TMPack::checkIfAllOpsAreClustered
void checkIfAllOpsAreClustered()
Definition: TMPack.cpp:804
ClusteredMapperDriver::l_op_cluster_index
std::map< OpGraphOpDesc, int > l_op_cluster_index
Definition: ClusteredMapper.h:88
OpScheduler
Definition: OpScheduler.h:39
TMPack::l_II
int l_II
Definition: ClusteredMapper.h:235
Mapping::setNodeMapping
void setNodeMapping(OpGraph::NodeDescriptor, std::vector< MRRG::NodeDescriptor > mapping)
Definition: Mapping.cpp:91
AnnealPlacer::assertOccupancyLimit
void assertOccupancyLimit(MRRGNodeDesc fu)
Definition: AnnealPlacer.cpp:332
BoundingBox::x_max
int x_max
Definition: ClusteredMapper.h:105
TMPack::setSourceOpNodes
void setSourceOpNodes(std::vector< MRRGNodeDesc > &source_op_nodes, OpGraphOpDesc source_op, std::string submodule)
Definition: TMPack.cpp:267
PathFinder::mapMRRGNode
void mapMRRGNode(OpGraphValDesc, const MRRGNode *)
Definition: Pathfinder.cpp:236
AnnealPlacer::inner_place_and_route_loop
std::pair< bool, float > inner_place_and_route_loop(float temp)
The main body of one iteration.
Definition: AnnealPlacer.cpp:265
AnnealPlacer::l_fix_ports
std::unordered_map< std::string, std::string > l_fix_ports
Definition: ClusteredMapper.h:338
AnnealPlacer::l_fixed_mrrg_nodes
std::set< MRRGNodeDesc > l_fixed_mrrg_nodes
Definition: ClusteredMapper.h:336
Mapping
Definition: Mapping.h:31
TMPack::createSingleOpClusters
void createSingleOpClusters()
Definition: TMPack.cpp:671
TMPack::setSchedule
void setSchedule(std::unordered_map< OpGraphOpDesc, int > s)
Definition: ClusteredMapper.h:227
TMPack::setPortsForSubmodule
void setPortsForSubmodule(std::string)
Definition: TMPack.cpp:166
TMPack::clusterPEs
bool clusterPEs(bool cluster)
Definition: TMPack.cpp:683
TMPack::opPair
std::pair< OpGraphOp *, OpGraphOp * > opPair
Definition: ClusteredMapper.h:229
TMPack::l_mrrg
const MRRG & l_mrrg
Definition: ClusteredMapper.h:240
AnnealPlacer::l_opgraph
const OpGraph & l_opgraph
Definition: ClusteredMapper.h:332
ClusteredMapperDriver::mapElastic
Mapping mapElastic(std::shared_ptr< OpGraph > opgraph, const int II, const MRRG &mrrg, std::unordered_map< std::string, std::string > fix_port, PrintOnDestructionChronoSequence timing_seq)
Definition: ClusteredMapper.cpp:172
NodeAttributes::occupancy
int occupancy
Definition: ClusteredMapper.h:98
TMPack::l_routing_nodes
std::map< std::string, std::vector< MRRGNodeDesc > > l_routing_nodes
Definition: ClusteredMapper.h:245
TMPack::unsetReschedule
void unsetReschedule()
Definition: ClusteredMapper.h:228
AnnealPlacer::getRandomUnoccupiedFU
MRRGNodeDesc getRandomUnoccupiedFU(OpGraphOpDesc op)
gets the functional units to map the op
Definition: AnnealPlacer.cpp:356
PathFinder::checkOveruse
bool checkOveruse()
Definition: Pathfinder.cpp:176
ClusteredMapperDriver::mapOpGraph
Mapping mapOpGraph(std::shared_ptr< OpGraph > opgraph, const int II, const MRRG &mrrg, std::unordered_map< std::string, std::string > fix_port) override
main function to map the OpGraph to the device description
Definition: ClusteredMapper.cpp:71
NodeAttributes::baseCost
double baseCost
Definition: ClusteredMapper.h:99
ClusteredMapperDriver::l_ops_to_node_names
std::unordered_map< OpGraphOpDesc, std::vector< std::string > > l_ops_to_node_names
Definition: ClusteredMapper.h:89
PathFinder::l_h_factor
double l_h_factor
Definition: ClusteredMapper.h:159
AnnealPlacer::getBB
BoundingBox getBB(OpGraphValDesc)
does the costing of the fopgraph
Definition: AnnealPlacer.cpp:129
AnnealPlacer::l_II
int l_II
Definition: ClusteredMapper.h:329
PathFinder::getCost
double getCost(const MRRGNode *)
Definition: Pathfinder.cpp:225
PathFinder::PathFinder
PathFinder(ClusteredMapperDriver driver, const OpGraph &opgraph, const MRRG &mrrg, bool isElastic=false, const std::string placement_filename="")
Definition: Pathfinder.cpp:29
AnnealPlacer::l_randomInt
std::minstd_rand l_randomInt
Definition: ClusteredMapper.h:337
ClusteredMapperDriver::l_cluster
const bool l_cluster
Definition: ClusteredMapper.h:80
ClusteredMapperDriver::getCyclesToSink
const Latency getCyclesToSink(OpGraphOpDesc source, OpGraphOpDesc sink)
Definition: ClusteredMapper.cpp:217
PathFinder::l_critical_path
std::vector< MRRGNodeDesc > l_critical_path
Definition: ClusteredMapper.h:163
PathFinder::l_placement
std::map< const OpGraphNode *, const MRRGNode * > l_placement
Definition: ClusteredMapper.h:165
Module
Definition: Module.h:163
ClusteredMapperDriver::l_h_factor_factor
const double l_h_factor_factor
Definition: ClusteredMapper.h:75
ClusteredMapperDriver::l_isElastic
bool l_isElastic
Definition: ClusteredMapper.h:81
TMPack::OpsNotToCluster
std::pair< OpGraphOpDesc, OpGraphOpDesc > OpsNotToCluster
Definition: ClusteredMapper.h:180
ClusteredMapperDriver::l_empty_mapping_result
Mapping l_empty_mapping_result
Definition: ClusteredMapper.h:91
TMPack::checkConnectedOperations
bool checkConnectedOperations(std::pair< OpGraphOpDesc, OpGraphOpDesc >, std::map< OpGraphOpDesc, std::vector< MRRGNodeDesc >> &ops_mrrg_nodes, std::string submodule)
Definition: TMPack.cpp:426
AnnealPlacer::isOpgraphCovered
bool isOpgraphCovered() const
Checks if the opgraph mapping is valid.
Definition: AnnealPlacer.cpp:343
TMPack::checkPortsOfOperation
bool checkPortsOfOperation(std::vector< std::pair< OpGraphOpDesc, OpGraphOpDesc >> global_port_connection, std::map< OpGraphOpDesc, std::vector< MRRGNodeDesc >> &ops_mrrg_nodes, std::set< OpGraphOpDesc > exlusive_port_operation, std::string submodule, bool isInput)
Definition: TMPack.cpp:341
ClusteredMapperDriver::mapStatic
Mapping mapStatic(std::shared_ptr< OpGraph > opgraph, const int II, const MRRG &mrrg, std::unordered_map< std::string, std::string > fix_port, PrintOnDestructionChronoSequence &timing_seq)
Definition: ClusteredMapper.cpp:101
PrintOnDestructionChronoSequence
Definition: CodeProfiling.h:121
TMPack::resolveReachability
void resolveReachability(OpGraphOpDesc source, OpGraphOpDesc sink, OpGraphVal *val)
Definition: TMPack.cpp:553
AnnealPlacer::printMapping
void printMapping() const
Definition: ClusteredMapper.h:320
ClusteredMapperDriver::l_p_factor_factor
const double l_p_factor_factor
Definition: ClusteredMapper.h:72
TMPack::isReachable
bool isReachable(MRRGNodeDesc source, MRRGNodeDesc sink, std::string, Latency cycles=-1)
Definition: TMPack.cpp:595
TMPack::l_function_nodes
std::map< std::string, std::vector< MRRGNodeDesc > > l_function_nodes
Definition: ClusteredMapper.h:244
AnnealPlacer::accept
bool accept(float delta_cost, float temperature) const
Should a move with this delta_cost be accepted at this temperature?
Definition: AnnealPlacer.cpp:247
BoundingBox::z_max
int z_max
Definition: ClusteredMapper.h:109
AnnealPlacer::nextTemperature
float nextTemperature(float t, float accept_rate) const
Definition: AnnealPlacer.cpp:564
AnnealPlacer
Implementation of the Anneal Placer.
Definition: ClusteredMapper.h:257
ClusteredMapperDriver::l_mapper_args
const ConfigStore l_mapper_args
Definition: ClusteredMapper.h:84
CGRA.h
AnnealPlacer::randomUintBelow
std::size_t randomUintBelow(std::size_t past_end) const
Definition: ClusteredMapper.h:344
PathFinder::parsePlacementFile
void parsePlacementFile()
Definition: Pathfinder.cpp:474
TMPack::l_cols
int l_cols
Definition: ClusteredMapper.h:237
OpScheduler.h
Mapper::cgra
std::shared_ptr< CGRA > cgra
Definition: Mapper.h:45
OpGraphVal
Definition: OpGraph.h:178
NodeAttributes::mapped_values
std::vector< OpGraphValDesc > mapped_values
Definition: ClusteredMapper.h:101
TMPack::addNextOps
void addNextOps(std::vector< OpGraphOpDesc > *next_ops, OpGraphOpDesc op)
Definition: TMPack.cpp:579
AnnealPlacer::l_cols
int l_cols
Definition: ClusteredMapper.h:328
AnnealPlacer::getMappedMRRGNode
MRRGNodeDesc getMappedMRRGNode(OpGraphOpDesc op)
gets the mrrgnode associated with an op or the op associated with an mrrgnode
Definition: AnnealPlacer.cpp:208
OpGraphOp
Definition: OpGraph.h:131
MRRGNode
Definition: MRRG.h:60
PathFinder::l_placement_filename
std::string l_placement_filename
Definition: ClusteredMapper.h:162
TMPack::kUndefLatency
static constexpr Latency kUndefLatency
Definition: ClusteredMapper.h:172
PathFinder::l_mapping
std::map< OpGraphValDesc, std::vector< const MRRGNode * > > l_mapping
Definition: ClusteredMapper.h:167
PathFinder
Implementation of the.
Definition: ClusteredMapper.h:119
NodeAttributes::hCost
double hCost
Definition: ClusteredMapper.h:100
TMPack::printOps
void printOps(std::vector< OpGraphOpDesc > &ops)
Definition: TMPack.cpp:819
ClusteredMapperDriver::l_initial_pfactor
const double l_initial_pfactor
Definition: ClusteredMapper.h:73
TMPack::l_subModule_MRRGs
std::map< std::string, MRRG * > l_subModule_MRRGs
Definition: ClusteredMapper.h:242
TMPack
Definition: ClusteredMapper.h:170
AnnealPlacer::getRandomFU
MRRGNodeDesc getRandomFU(OpGraphOpDesc op)
Definition: AnnealPlacer.cpp:417
ClusteredMapperDriver::l_verbosity
const int l_verbosity
Definition: ClusteredMapper.h:79
Mapping.h
TMPack::setReachesOutputPorts
void setReachesOutputPorts(std::map< MRRGNodeDesc, std::set< MRRGNodeDesc >> &connected_nodes, std::vector< MRRGNodeDesc > &op_mrrg_nodes, std::string submodule)
Definition: TMPack.cpp:278
AnnealPlacer::swap
void swap(OpGraphOpDesc op, MRRGNodeDesc node, std::map< OpGraphOpDesc, MRRGNodeDesc > &old_placement)
Definition: AnnealPlacer.cpp:514
ClusteredMapperDriver::l_fanout_threshold
const int l_fanout_threshold
Definition: ClusteredMapper.h:77
AnnealPlacer::determineTemperature
float determineTemperature(float scale)
Definition: AnnealPlacer.cpp:454
TMPack::checkIfInputPortsNeeded
bool checkIfInputPortsNeeded(OpGraphOpDesc source_op, std::vector< OpGraphOpDesc > &ops)
Definition: TMPack.cpp:257
NodeAttributes
Definition: ClusteredMapper.h:95
TMPack::setReachesInputPorts
void setReachesInputPorts(std::map< MRRGNodeDesc, std::set< MRRGNodeDesc >> &connected_nodes, std::vector< MRRGNodeDesc > &op_mrrg_nodes, std::string submodule)
Definition: TMPack.cpp:296
PathFinder::UnmappableException
Definition: ClusteredMapper.h:130
AnnealPlacer::isClusterFixed
bool isClusterFixed(std::vector< OpGraphOpDesc > cluster)
Definition: AnnealPlacer.cpp:256
TMPack::l_clustered_ops
std::unordered_set< OpGraphOpDesc > l_clustered_ops
Definition: ClusteredMapper.h:243
ClusteredMapperDriver::l_rand_seed
const int l_rand_seed
Definition: ClusteredMapper.h:71
PathFinder::l_routing_nodes
std::unordered_map< const MRRGNode *, NodeAttributes > l_routing_nodes
Definition: ClusteredMapper.h:166
Mapper.h
TMPack::clusterMemoryOperations
void clusterMemoryOperations(std::set< OpGraphOpDesc > *)
Definition: TMPack.cpp:103
ClusteredMapperDriver::l_swap_factor
const int l_swap_factor
Definition: ClusteredMapper.h:76
AnnealPlacer::getFUForOpAtLoc
MRRGNodeDesc getFUForOpAtLoc(OpGraphOpDesc op, Location loc)
Definition: AnnealPlacer.cpp:386
TMPack::checkPortConn
bool checkPortConn(std::vector< std::pair< OpGraphOpDesc, OpGraphOpDesc >> &global_port_connection, int i, std::set< MRRGNodeDesc > ports_used, std::set< OpGraphOpDesc > out_port_found, std::map< OpGraphOpDesc, std::set< MRRGNodeDesc >> &op_to_port_nodes, std::string submodule, bool isInput)
Definition: TMPack.cpp:310
ClusteredMapperDriver::l_print
const int l_print
Definition: ClusteredMapper.h:55
PathFinder::l_opgraph
const OpGraph & l_opgraph
Definition: ClusteredMapper.h:161
BoundingBox::x_min
int x_min
Definition: ClusteredMapper.h:106
AnnealPlacer::setMappingInto
void setMappingInto(Mapping &m) const
Definition: ClusteredMapper.h:313
ClusteredMapperDriver::kUndefLatency
static constexpr Latency kUndefLatency
Definition: ClusteredMapper.h:42
TMPack::l_isElastic
bool l_isElastic
Definition: ClusteredMapper.h:238
ClusteredMapperDriver::l_iteration_interval
int l_iteration_interval
Definition: ClusteredMapper.h:82
PathFinder::l_used_rounting_function_nodes
std::set< MRRGNodeDesc > l_used_rounting_function_nodes
Definition: ClusteredMapper.h:164
PathFinder::l_isElastic
bool l_isElastic
Definition: ClusteredMapper.h:157
TMPack::l_rows
int l_rows
Definition: ClusteredMapper.h:236
OpGraph::OpDescriptor
const OpGraphOp * OpDescriptor
Definition: OpGraph.h:219
BoundingBox
Definition: ClusteredMapper.h:104
ClusteredMapperDriver::l_clusters
std::vector< std::vector< OpGraphOpDesc > > l_clusters
Definition: ClusteredMapper.h:87
OpGraph
Definition: OpGraph.h:215
AnnealPlacer::ripUpOp
void ripUpOp(OpGraphOpDesc op)
places and removes an op from an mrrgnode
Definition: AnnealPlacer.cpp:221
TMPack::checkReachbitlity
bool checkReachbitlity(std::vector< OpGraphOpDesc > &, std::string)
Definition: TMPack.cpp:454
AnnealPlacer::AnnealPlacer
AnnealPlacer(ClusteredMapperDriver driver, const OpGraph &opgraph, const MRRG &mrrg, std::unordered_map< std::string, std::string > fix_ports, int rows, int cols, bool isElastic=false)
Definition: AnnealPlacer.cpp:28
TMPack::getOpClusterIndex
std::map< OpGraphOpDesc, int > getOpClusterIndex()
Definition: ClusteredMapper.h:224
AnnealPlacer::randomRealBetween0And1
double randomRealBetween0And1() const
Definition: ClusteredMapper.h:345
TMPack::getModulesToMapOp
void getModulesToMapOp(OpGraphOpDesc op, std::map< std::string, MRRGNodeDesc > &modules_could_map_op)
Definition: TMPack.cpp:209
TMPack::checkIfOutputPortsNeeded
bool checkIfOutputPortsNeeded(OpGraphValDesc val, std::vector< OpGraphOpDesc > &ops)
Definition: TMPack.cpp:247
AnnealPlacer::UnmappableException
Definition: ClusteredMapper.h:269
AnnealPlacer::l_mapping
std::map< OpGraph::NodeDescriptor, std::vector< MRRGNodeDesc > > l_mapping
Definition: ClusteredMapper.h:340
TMPack::l_reschedule
bool l_reschedule
Definition: ClusteredMapper.h:233
TMPack::opsCouldBeClustered
void opsCouldBeClustered(std::vector< OpGraphOpDesc > nextOps, std::vector< MRRGNodeDesc > &used_nodes, std::vector< OpGraphOpDesc > &used_ops, std::set< OpGraphOpDesc > &visitedOps, std::string subModule)
Definition: TMPack.cpp:221
PathFinder::kUndefLatency
static constexpr Latency kUndefLatency
Definition: ClusteredMapper.h:121
Mapper::timelimit
int timelimit
Definition: Mapper.h:46
PathFinder::l_mrrg
const MRRG & l_mrrg
Definition: ClusteredMapper.h:160