CGRA-ME
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
AnnealPlacer Class Reference

Implementation of the Anneal Placer. More...

#include <ClusteredMapper.h>

Inheritance diagram for AnnealPlacer:
ClusteredMapperDriver

Classes

struct  UnmappableException
 

Public Member Functions

 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)
 
Mapping placeOpGraph (float temp)
 
void clearPlacement ()
 
void setInitialPlacement ()
 
float determineTemperature (float scale)
 

Private Types

using OpCodeByCycle = std::pair< OpGraphOpCode, int >
 

Private Member Functions

std::pair< bool, float > inner_place_and_route_loop (float temp)
 The main body of one iteration. More...
 
MRRGNodeDesc getRandomUnoccupiedFU (OpGraphOpDesc op)
 gets the functional units to map the op More...
 
MRRGNodeDesc getRandomFU (OpGraphOpDesc op)
 
std::vector< MRRGNodeDescgetRandomFUs (std::vector< OpGraphOpDesc > ops, bool occupied)
 
MRRGNodeDesc getFUForOpAtLoc (OpGraphOpDesc op, Location loc)
 
void ripUpOp (OpGraphOpDesc op)
 places and removes an op from an mrrgnode More...
 
bool placeOp (OpGraphOpDesc op, MRRGNodeDesc n)
 
MRRGNodeDesc getMappedMRRGNode (OpGraphOpDesc op)
 gets the mrrgnode associated with an op or the op associated with an mrrgnode More...
 
OpGraphOpDesc getOpMapedAt (MRRGNodeDesc n)
 
bool isClusterFixed (std::vector< OpGraphOpDesc > cluster)
 
bool accept (float delta_cost, float temperature) const
 Should a move with this delta_cost be accepted at this temperature? More...
 
float nextTemperature (float t, float accept_rate) const
 
bool isOpgraphCovered () const
 Checks if the opgraph mapping is valid. More...
 
bool checkOveruse ()
 
void assertOccupancyLimit (MRRGNodeDesc fu)
 
BoundingBox getBB (OpGraphValDesc)
 does the costing of the fopgraph
More...
 
double getTotalCost ()
 
void swap (OpGraphOpDesc op, MRRGNodeDesc node, std::map< OpGraphOpDesc, MRRGNodeDesc > &old_placement)
 
void setMappingInto (Mapping &m) const
 
void printMapping () const
 
void printMapping (std::ostream &os) const
 
std::size_t randomUintBelow (std::size_t past_end) const
 
double randomRealBetween0And1 () const
 
- Private Member Functions inherited from ClusteredMapperDriver
 ClusteredMapperDriver (std::shared_ptr< CGRA > cgra, int timelimit, const ConfigStore &args)
 
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 More...
 
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)
 
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)
 
const Latency getCyclesToSink (OpGraphOpDesc source, OpGraphOpDesc sink)
 
bool isAllOpsSupported (const OpGraph &opgraph, const MRRG &mrrg)
 
void printPlacementNeato (int i, const OpGraph &opgraph, Mapping placed, std::unordered_map< OpGraphOpDesc, int > sched)
 
- Private Member Functions inherited from Mapper
virtual ~Mapper ()
 
 Mapper (std::shared_ptr< CGRA > cgra, int timelimit)
 

Private Attributes

int l_rows = 0
 
int l_cols = 0
 
int l_II
 
bool l_isElastic
 
const MRRGl_mrrg
 
const OpGraphl_opgraph
 
std::set< MRRGNodeDescl_fixed_mrrg_nodes
 
std::minstd_rand l_randomInt
 
std::unordered_map< std::string, std::string > l_fix_ports
 
std::map< const MRRGNode *, NodeAttributesl_function_nodes
 
std::map< OpGraph::NodeDescriptor, std::vector< MRRGNodeDesc > > l_mapping = {}
 
std::map< OpGraphOpCode, std::vector< std::vector< MRRGNodeDesc > > > l_grid
 
std::unordered_map< OpCodeByCycle, std::vector< MRRGNodeDesc >, pair_hashl_op_to_nodes
 
- Private Attributes inherited from ClusteredMapperDriver
const int l_print
 
const int l_rand_seed
 
const double l_p_factor_factor
 
const double l_initial_pfactor
 
const double l_initial_hfactor
 
const double l_h_factor_factor
 
const int l_swap_factor
 
const int l_fanout_threshold
 
const int l_ram_ports
 
const int l_verbosity
 
const bool l_cluster
 
bool l_isElastic
 
int l_iteration_interval
 
const std::string l_arch_name
 
const ConfigStore l_mapper_args
 
const int l_cost_func
 
OpSchedulerl_op_sched
 
std::vector< std::vector< OpGraphOpDesc > > l_clusters
 
std::map< OpGraphOpDesc, int > l_op_cluster_index
 
std::unordered_map< OpGraphOpDesc, std::vector< std::string > > l_ops_to_node_names
 
std::unordered_map< OpGraphOpDesc, int > l_schedule
 
Mapping l_empty_mapping_result
 
- Private Attributes inherited from Mapper
std::shared_ptr< CGRAcgra
 
int timelimit
 

Additional Inherited Members

- Static Private Attributes inherited from ClusteredMapperDriver
static constexpr Latency kUndefLatency = -1
 

Detailed Description

Implementation of the Anneal Placer.

Instatiated for every mapping call. Inherits from the driver to get easy access to configuration members.

Definition at line 257 of file ClusteredMapper.h.

Member Typedef Documentation

◆ OpCodeByCycle

using AnnealPlacer::OpCodeByCycle = std::pair<OpGraphOpCode, int>
private

Definition at line 334 of file ClusteredMapper.h.

Constructor & Destructor Documentation

◆ 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 at line 28 of file AnnealPlacer.cpp.

Member Function Documentation

◆ accept()

bool AnnealPlacer::accept ( float  delta_cost,
float  temperature 
) const
private

Should a move with this delta_cost be accepted at this temperature?

Definition at line 247 of file AnnealPlacer.cpp.

◆ assertOccupancyLimit()

void AnnealPlacer::assertOccupancyLimit ( MRRGNodeDesc  fu)
private

Definition at line 332 of file AnnealPlacer.cpp.

◆ checkOveruse()

bool AnnealPlacer::checkOveruse ( )
private

Definition at line 166 of file AnnealPlacer.cpp.

◆ clearPlacement()

void AnnealPlacer::clearPlacement ( )

Definition at line 633 of file AnnealPlacer.cpp.

◆ determineTemperature()

float AnnealPlacer::determineTemperature ( float  scale)

Definition at line 454 of file AnnealPlacer.cpp.

◆ getBB()

BoundingBox AnnealPlacer::getBB ( OpGraphValDesc  val)
private

does the costing of the fopgraph

Definition at line 129 of file AnnealPlacer.cpp.

◆ getFUForOpAtLoc()

MRRGNodeDesc AnnealPlacer::getFUForOpAtLoc ( OpGraphOpDesc  op,
Location  loc 
)
private

Definition at line 386 of file AnnealPlacer.cpp.

◆ getMappedMRRGNode()

MRRGNodeDesc AnnealPlacer::getMappedMRRGNode ( OpGraphOpDesc  op)
private

gets the mrrgnode associated with an op or the op associated with an mrrgnode

Definition at line 208 of file AnnealPlacer.cpp.

◆ getOpMapedAt()

OpGraph::OpDescriptor AnnealPlacer::getOpMapedAt ( MRRGNodeDesc  n)
private

Definition at line 189 of file AnnealPlacer.cpp.

◆ getRandomFU()

MRRGNodeDesc AnnealPlacer::getRandomFU ( OpGraphOpDesc  op)
private

Definition at line 417 of file AnnealPlacer.cpp.

◆ getRandomFUs()

std::vector< MRRG::NodeDescriptor > AnnealPlacer::getRandomFUs ( std::vector< OpGraphOpDesc ops,
bool  occupied 
)
private

Definition at line 577 of file AnnealPlacer.cpp.

◆ getRandomUnoccupiedFU()

MRRGNodeDesc AnnealPlacer::getRandomUnoccupiedFU ( OpGraphOpDesc  op)
private

gets the functional units to map the op

Definition at line 356 of file AnnealPlacer.cpp.

◆ getTotalCost()

double AnnealPlacer::getTotalCost ( )
private

Definition at line 73 of file AnnealPlacer.cpp.

◆ inner_place_and_route_loop()

std::pair< bool, float > AnnealPlacer::inner_place_and_route_loop ( float  temp)
private

The main body of one iteration.

Definition at line 265 of file AnnealPlacer.cpp.

◆ isClusterFixed()

bool AnnealPlacer::isClusterFixed ( std::vector< OpGraphOpDesc cluster)
private
Parameters
clusterchecks if the cluster has a fixed port or no
Returns
true if it does contain a fixed port
false if it doesn't contain a fixed port

Definition at line 256 of file AnnealPlacer.cpp.

◆ isOpgraphCovered()

bool AnnealPlacer::isOpgraphCovered ( ) const
private

Checks if the opgraph mapping is valid.

Definition at line 343 of file AnnealPlacer.cpp.

◆ nextTemperature()

float AnnealPlacer::nextTemperature ( float  t,
float  accept_rate 
) const
private

Definition at line 564 of file AnnealPlacer.cpp.

◆ placeOp()

bool AnnealPlacer::placeOp ( OpGraphOpDesc  op,
MRRGNodeDesc  n 
)
private

Definition at line 233 of file AnnealPlacer.cpp.

◆ placeOpGraph()

Mapping AnnealPlacer::placeOpGraph ( float  temp)

Definition at line 640 of file AnnealPlacer.cpp.

◆ printMapping() [1/2]

void AnnealPlacer::printMapping ( ) const
inlineprivate

Definition at line 320 of file ClusteredMapper.h.

◆ printMapping() [2/2]

void AnnealPlacer::printMapping ( std::ostream &  os) const
inlineprivate

Definition at line 321 of file ClusteredMapper.h.

◆ randomRealBetween0And1()

double AnnealPlacer::randomRealBetween0And1 ( ) const
inlineprivate

Definition at line 345 of file ClusteredMapper.h.

◆ randomUintBelow()

std::size_t AnnealPlacer::randomUintBelow ( std::size_t  past_end) const
inlineprivate

Definition at line 344 of file ClusteredMapper.h.

◆ ripUpOp()

void AnnealPlacer::ripUpOp ( OpGraphOpDesc  op)
private

places and removes an op from an mrrgnode

Definition at line 221 of file AnnealPlacer.cpp.

◆ setInitialPlacement()

void AnnealPlacer::setInitialPlacement ( )

Definition at line 620 of file AnnealPlacer.cpp.

◆ setMappingInto()

void AnnealPlacer::setMappingInto ( Mapping m) const
inlineprivate

Definition at line 313 of file ClusteredMapper.h.

◆ swap()

void AnnealPlacer::swap ( OpGraphOpDesc  op,
MRRGNodeDesc  node,
std::map< OpGraphOpDesc, MRRGNodeDesc > &  old_placement 
)
private

Definition at line 514 of file AnnealPlacer.cpp.

Member Data Documentation

◆ l_cols

int AnnealPlacer::l_cols = 0
private

Definition at line 328 of file ClusteredMapper.h.

◆ l_fix_ports

std::unordered_map<std::string, std::string> AnnealPlacer::l_fix_ports
private

Definition at line 338 of file ClusteredMapper.h.

◆ l_fixed_mrrg_nodes

std::set<MRRGNodeDesc> AnnealPlacer::l_fixed_mrrg_nodes
private

Definition at line 336 of file ClusteredMapper.h.

◆ l_function_nodes

std::map<const MRRGNode*, NodeAttributes> AnnealPlacer::l_function_nodes
private

Definition at line 339 of file ClusteredMapper.h.

◆ l_grid

std::map<OpGraphOpCode, std::vector<std::vector<MRRGNodeDesc> > > AnnealPlacer::l_grid
private

Definition at line 341 of file ClusteredMapper.h.

◆ l_II

int AnnealPlacer::l_II
private

Definition at line 329 of file ClusteredMapper.h.

◆ l_isElastic

bool AnnealPlacer::l_isElastic
private

Definition at line 330 of file ClusteredMapper.h.

◆ l_mapping

std::map<OpGraph::NodeDescriptor, std::vector<MRRGNodeDesc> > AnnealPlacer::l_mapping = {}
private

Definition at line 340 of file ClusteredMapper.h.

◆ l_mrrg

const MRRG& AnnealPlacer::l_mrrg
private

Definition at line 331 of file ClusteredMapper.h.

◆ l_op_to_nodes

std::unordered_map<OpCodeByCycle, std::vector<MRRGNodeDesc>, pair_hash> AnnealPlacer::l_op_to_nodes
private

Definition at line 342 of file ClusteredMapper.h.

◆ l_opgraph

const OpGraph& AnnealPlacer::l_opgraph
private

Definition at line 332 of file ClusteredMapper.h.

◆ l_randomInt

std::minstd_rand AnnealPlacer::l_randomInt
mutableprivate

Definition at line 337 of file ClusteredMapper.h.

◆ l_rows

int AnnealPlacer::l_rows = 0
private

Definition at line 327 of file ClusteredMapper.h.


The documentation for this class was generated from the following files: