Go to the documentation of this file.
23 #include <unordered_map>
28 #include <unordered_set>
30 #include <bits/stdc++.h>
51 std::unordered_map<std::string, std::string> fix_port)
override;
61 std::unordered_map<std::string, std::string> fix_port,
66 std::unordered_map<std::string, std::string> fix_port,
126 bool isElastic =
false,
127 const std::string placement_filename =
"");
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);
167 std::map<OpGraphValDesc, std::vector<const MRRGNode*>>
l_mapping = {};
175 std::shared_ptr<OpGraph> opgraph,
178 int II,
bool isElastic =
false);
185 void getFirstOps(std::queue<OpGraphOpDesc>& operations);
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);
199 std::string submodule);
209 std::vector<MRRGNodeDesc>& op_mrrg_nodes, std::string submodule);
211 std::vector<MRRGNodeDesc>& op_mrrg_nodes, std::string submodule);
218 std::vector<OpGraphOpDesc> nextOps, std::vector<MRRGNodeDesc> &used_nodes,
219 std::vector<OpGraphOpDesc> &used_ops, std::set<OpGraphOpDesc> &visitedOps, std::string subModule);
225 void printOps (std::vector<OpGraphOpDesc>& ops);
226 void printNodes (std::vector<MRRGNodeDesc>& mrrg_nodes);
229 using opPair = std::pair<OpGraphOp*, OpGraphOp*>;
262 std::unordered_map<std::string, std::string> fix_ports,
265 bool isElastic =
false);
281 std::vector<MRRGNodeDesc>
getRandomFUs(std::vector<OpGraphOpDesc> ops,
bool occupied);
299 bool accept(
float delta_cost,
float temperature)
const;
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);
324 cpy.outputMapping(os);
340 std::map<OpGraph::NodeDescriptor, std::vector<MRRGNodeDesc>>
l_mapping = {};
341 std::map<OpGraphOpCode, std::vector<std::vector<MRRGNodeDesc>>>
l_grid;
std::map< const MRRGNode *, NodeAttributes > l_function_nodes
TMPack(ClusteredMapperDriver &driver, Module *topLevelModule, std::shared_ptr< OpGraph > opgraph, const MRRG &mrrg, int rows, int cols, int II, bool isElastic=false)
std::vector< std::vector< OpGraphOpDesc > > getClusters()
ClusteredMapperDriver(std::shared_ptr< CGRA > cgra, int timelimit, const ConfigStore &args)
void printPlacementNeato(int i, const OpGraph &opgraph, Mapping placed, std::unordered_map< OpGraphOpDesc, int > sched)
bool routeVal(OpGraphValDesc)
bool placeOp(OpGraphOpDesc op, MRRGNodeDesc n)
std::shared_ptr< OpGraph > l_opgraph
std::unordered_map< opPair, int, pair_hash > extended_sched_const
void printMapping(std::ostream &os) const
std::vector< MRRGNodeDesc > getRandomFUs(std::vector< OpGraphOpDesc > ops, bool occupied)
std::unordered_map< OpGraphOpDesc, int > l_schedule
const MRRGNode * NodeDescriptor
const OpGraphVal * ValDescriptor
Proxy class that makes a new instance of the for ever call. Holds constant configuration info,...
Mapping routeOpGraph(Mapping placement)
bool isAllOpsSupported(const OpGraph &opgraph, const MRRG &mrrg)
void printNumberOfResourcesUsed()
void setInitialPlacement()
std::map< std::string, std::vector< std::vector< OpGraphOpDesc > > > l_mem_name_ops
std::pair< OpGraphOpCode, int > OpCodeByCycle
std::set< OpsNotToCluster > l_ops_not_clustered
std::unordered_map< OpGraphOpDesc, std::vector< std::string > > getOpsNodeNames()
std::unordered_map< OpCodeByCycle, std::vector< MRRGNodeDesc >, pair_hash > l_op_to_nodes
void setMappingInto(Mapping &m) const
std::map< OpGraphOpCode, std::vector< std::vector< MRRGNodeDesc > > > l_grid
void printNodes(std::vector< MRRGNodeDesc > &mrrg_nodes)
void ripUpOpVal(OpGraphValDesc)
std::map< std::string, std::set< MRRGNodeDesc > > l_submodule_input_ports
const std::string l_arch_name
void getFirstOps(std::queue< OpGraphOpDesc > &operations)
Common interface for mappers.
std::vector< const MRRGNode * > dijkstraVisit(const MRRGNode *, const MRRGNode *, OperandTag, OpGraphValDesc, std::set< const MRRGNode * >, int, int)
std::map< std::string, std::set< MRRGNodeDesc > > l_submodule_output_ports
OpGraphOpDesc getOpMapedAt(MRRGNodeDesc n)
const double l_initial_hfactor
Mapping placeOpGraph(float temp)
void checkIfAllOpsAreClustered()
std::map< OpGraphOpDesc, int > l_op_cluster_index
void setNodeMapping(OpGraph::NodeDescriptor, std::vector< MRRG::NodeDescriptor > mapping)
void assertOccupancyLimit(MRRGNodeDesc fu)
void setSourceOpNodes(std::vector< MRRGNodeDesc > &source_op_nodes, OpGraphOpDesc source_op, std::string submodule)
void mapMRRGNode(OpGraphValDesc, const MRRGNode *)
std::pair< bool, float > inner_place_and_route_loop(float temp)
The main body of one iteration.
std::unordered_map< std::string, std::string > l_fix_ports
std::set< MRRGNodeDesc > l_fixed_mrrg_nodes
void createSingleOpClusters()
void setSchedule(std::unordered_map< OpGraphOpDesc, int > s)
void setPortsForSubmodule(std::string)
bool clusterPEs(bool cluster)
std::pair< OpGraphOp *, OpGraphOp * > opPair
const OpGraph & l_opgraph
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)
std::map< std::string, std::vector< MRRGNodeDesc > > l_routing_nodes
MRRGNodeDesc getRandomUnoccupiedFU(OpGraphOpDesc op)
gets the functional units to map the op
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
std::unordered_map< OpGraphOpDesc, std::vector< std::string > > l_ops_to_node_names
BoundingBox getBB(OpGraphValDesc)
does the costing of the fopgraph
double getCost(const MRRGNode *)
PathFinder(ClusteredMapperDriver driver, const OpGraph &opgraph, const MRRG &mrrg, bool isElastic=false, const std::string placement_filename="")
std::minstd_rand l_randomInt
const Latency getCyclesToSink(OpGraphOpDesc source, OpGraphOpDesc sink)
std::vector< MRRGNodeDesc > l_critical_path
std::map< const OpGraphNode *, const MRRGNode * > l_placement
const double l_h_factor_factor
std::pair< OpGraphOpDesc, OpGraphOpDesc > OpsNotToCluster
Mapping l_empty_mapping_result
bool checkConnectedOperations(std::pair< OpGraphOpDesc, OpGraphOpDesc >, std::map< OpGraphOpDesc, std::vector< MRRGNodeDesc >> &ops_mrrg_nodes, std::string submodule)
bool isOpgraphCovered() const
Checks if the opgraph mapping is valid.
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)
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)
void resolveReachability(OpGraphOpDesc source, OpGraphOpDesc sink, OpGraphVal *val)
void printMapping() const
const double l_p_factor_factor
bool isReachable(MRRGNodeDesc source, MRRGNodeDesc sink, std::string, Latency cycles=-1)
std::map< std::string, std::vector< MRRGNodeDesc > > l_function_nodes
bool accept(float delta_cost, float temperature) const
Should a move with this delta_cost be accepted at this temperature?
float nextTemperature(float t, float accept_rate) const
Implementation of the Anneal Placer.
const ConfigStore l_mapper_args
std::size_t randomUintBelow(std::size_t past_end) const
void parsePlacementFile()
std::shared_ptr< CGRA > cgra
std::vector< OpGraphValDesc > mapped_values
void addNextOps(std::vector< OpGraphOpDesc > *next_ops, OpGraphOpDesc op)
MRRGNodeDesc getMappedMRRGNode(OpGraphOpDesc op)
gets the mrrgnode associated with an op or the op associated with an mrrgnode
std::string l_placement_filename
static constexpr Latency kUndefLatency
std::map< OpGraphValDesc, std::vector< const MRRGNode * > > l_mapping
void printOps(std::vector< OpGraphOpDesc > &ops)
const double l_initial_pfactor
std::map< std::string, MRRG * > l_subModule_MRRGs
MRRGNodeDesc getRandomFU(OpGraphOpDesc op)
void setReachesOutputPorts(std::map< MRRGNodeDesc, std::set< MRRGNodeDesc >> &connected_nodes, std::vector< MRRGNodeDesc > &op_mrrg_nodes, std::string submodule)
void swap(OpGraphOpDesc op, MRRGNodeDesc node, std::map< OpGraphOpDesc, MRRGNodeDesc > &old_placement)
const int l_fanout_threshold
float determineTemperature(float scale)
bool checkIfInputPortsNeeded(OpGraphOpDesc source_op, std::vector< OpGraphOpDesc > &ops)
void setReachesInputPorts(std::map< MRRGNodeDesc, std::set< MRRGNodeDesc >> &connected_nodes, std::vector< MRRGNodeDesc > &op_mrrg_nodes, std::string submodule)
bool isClusterFixed(std::vector< OpGraphOpDesc > cluster)
std::unordered_set< OpGraphOpDesc > l_clustered_ops
std::unordered_map< const MRRGNode *, NodeAttributes > l_routing_nodes
void clusterMemoryOperations(std::set< OpGraphOpDesc > *)
MRRGNodeDesc getFUForOpAtLoc(OpGraphOpDesc op, Location loc)
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)
const OpGraph & l_opgraph
void setMappingInto(Mapping &m) const
static constexpr Latency kUndefLatency
std::set< MRRGNodeDesc > l_used_rounting_function_nodes
const OpGraphOp * OpDescriptor
std::vector< std::vector< OpGraphOpDesc > > l_clusters
void ripUpOp(OpGraphOpDesc op)
places and removes an op from an mrrgnode
bool checkReachbitlity(std::vector< OpGraphOpDesc > &, std::string)
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)
std::map< OpGraphOpDesc, int > getOpClusterIndex()
double randomRealBetween0And1() const
void getModulesToMapOp(OpGraphOpDesc op, std::map< std::string, MRRGNodeDesc > &modules_could_map_op)
bool checkIfOutputPortsNeeded(OpGraphValDesc val, std::vector< OpGraphOpDesc > &ops)
std::map< OpGraph::NodeDescriptor, std::vector< MRRGNodeDesc > > l_mapping
void opsCouldBeClustered(std::vector< OpGraphOpDesc > nextOps, std::vector< MRRGNodeDesc > &used_nodes, std::vector< OpGraphOpDesc > &used_ops, std::set< OpGraphOpDesc > &visitedOps, std::string subModule)
static constexpr Latency kUndefLatency