1 #ifndef DATAFLOW_IMPL_H 2 #define DATAFLOW_IMPL_H 12 #include "MILP_Model.h" 15 #define ForAllBlocks(b) for (blockID b: allBlocks) 16 #define ForAllChannels(c) for (channelID c: allChannels) 17 #define ForAllPorts(b,p) for (portID p: getPorts(b, ALL_PORTS)) 18 #define ForAllInputPorts(b,p) for (portID p: getPorts(b, INPUT_PORTS)) 19 #define ForAllOutputPorts(b,p) for (portID p: getPorts(b, OUTPUT_PORTS)) 20 #define ForAllBasicBlocks(bb) for (bbID bb = 0; bb < numBasicBlocks(); ++bb) 29 using vecBBs = std::vector<bbID>;
30 using setBBs = std::set<bbID>;
31 using vecBBArcs = std::vector<bbArcID>;
32 using setBBArcs = std::set<bbArcID>;
34 using longValueType =
long long;
62 entryBB = invalidDataflowID;
92 bbID
id = BBs.size() + 1;
119 setBBs& getExitBasicBlocks() {
123 void addExitBasicBlock(bbID bb) {
127 bool isEntryBasicBlock(bbID bb) {
128 return entryBB == bb;
131 bool isExitBasicBlock(bbID bb) {
132 return exitBBs.count(bb) > 0;
142 bbArcID
findArc(bbID src, bbID dst)
const;
150 bbArcID
findOrAddArc(bbID src, bbID dst,
double freq = 0);
158 return Arcs[arc].src;
167 return Arcs[arc].dst;
176 Arcs[arc].prob = prob;
185 return Arcs[arc].prob;
188 void setFrequencyArc(bbArcID arc,
double freq) {
189 Arcs[arc].freq = freq;
192 double getFrequencyArc(bbArcID arc)
const {
193 return Arcs[arc].freq;
210 Arcs[arc].back = back;
219 return Arcs[arc].back;
228 return BBs[bb - 1].pred;
237 return BBs[bb - 1].succ;
246 BBs[bb - 1].freq = f;
255 return BBs[bb - 1].freq;
264 BBs[bb - 1].exec = t;
273 return BBs[bb - 1].exec;
276 double isEntryBB(bbID bb) {
277 return entryBB == bb;
280 double getDFSorder(bbID bb) {
281 return BBs[bb - 1].DFS_order;
284 void setDFSorder(bbID bb,
int order) {
285 BBs[bb - 1].DFS_order = order;
288 double getSCCnumber(bbID bb) {
289 return BBs[bb - 1].SCC_number;
292 void setSCCnumber(bbID bb,
int number) {
293 BBs[bb - 1].SCC_number = number;
325 void setDSUnumberArc(bbArcID arc,
int number) {
326 assert (arc >= 0 && arc <
numArcs());
327 Arcs[arc].DSU_number = number;
330 void addMGnumber(bbArcID arc,
int number) {
331 assert (arc >= 0 && arc <
numArcs());
332 Arcs[arc].MG_numbers.push_back(number);
335 int getDSUnumberArc(bbArcID arc) {
336 return Arcs[arc].DSU_number;
339 vector<int>& getMGnumbers(bbArcID arc) {
340 return Arcs[arc].MG_numbers;
343 std::vector<bbID>& getBlocksInCycle(
int cycle_number){
344 return cycles[cycle_number].cycle;
348 return cycles.size();
358 double residual_freq;
373 vector<int> MG_numbers;
378 struct BasicBlockCycle {
381 std::vector<bbID> cycle;
382 std::vector<bool> executed;
385 std::vector<BasicBlock> BBs;
386 std::vector<BB_Arc> Arcs;
389 std::vector<bbID> DFSorder;
391 std::vector<BasicBlockCycle> cycles;
401 void setDefaultProbabilities(
double back_prob = 0.9);
407 BasicBlockCycle extractBasicBlockCycle();
446 DFnetlist_Impl(
const std::string& name,
const std::string& name_bb);
458 const std::string& getName()
const;
466 blockID createBlock(BlockType type,
const std::string& name =
"");
473 blockID getBlock(
const std::string& name)
const;
480 const std::string& getBlockName(blockID
id)
const;
487 BlockType getBlockType(blockID
id)
const;
489 std::string printBlockType(BlockType type)
const;
491 void printChannelInfo(channelID c,
int slots,
int transparent);
493 bool isInnerChannel(channelID c);
495 bool getChannelMerge(channelID c);
496 void setChannelMerge(channelID c);
504 double getBlockDelay(blockID
id,
int indx)
const;
511 void setBasicBlock(blockID
id, bbID bb = invalidDataflowID);
518 bbID getBasicBlock(blockID
id)
const;
525 void setBlockDelay(blockID
id,
double d,
int indx);
532 int getLatency(blockID
id)
const;
539 void setLatency(blockID
id,
int lat);
542 double getBlockRetimingDiff(blockID
id)
const;
545 void setBlockRetimingDiff(blockID
id,
double diff);
552 int getInitiationInterval(blockID
id)
const;
559 void setInitiationInterval(blockID
id,
int ii);
566 void setExecutionFrequency(blockID
id,
double freq);
573 int getExecutionFrequency(blockID
id)
const;
581 void setTrueFrac(blockID
id,
double freq);
588 double getTrueFrac(blockID
id)
const;
595 void setValue(blockID
id, longValueType value);
602 void setOperation(blockID
id, std::string op);
605 const std::string& getOperation(blockID
id)
const;
608 void setMemPortID(blockID
id,
int memPortID);
610 int getMemPortID(blockID
id)
const;
612 void setMemOffset(blockID
id,
int memOffset);
614 int getMemOffset(blockID
id)
const;
616 void setMemBBCount(blockID
id,
int count);
618 int getMemBBCount(blockID
id)
const;
620 void setMemLdCount(blockID
id,
int count);
622 int getMemLdCount(blockID
id)
const;
624 void setMemStCount(blockID
id,
int count);
626 int getMemStCount(blockID
id)
const;
628 void setMemName(blockID
id, std::string name);
630 const std::string& getMemName(blockID
id)
const;
632 void setMemPortSuffix(blockID
id, std::string op);
634 const std::string& getMemPortSuffix(blockID
id)
const;
636 void setFuncName(blockID
id, std::string op);
638 const std::string& getFuncName(blockID
id)
const;
640 void setOrderings(blockID
id, map<bbID, vector<int>> value);
644 void setLSQDepth(blockID
id,
int depth);
646 int getLSQDepth(blockID
id)
const;
648 void setNumLoads(blockID
id, std::string name);
650 const std::string& getNumLoads(blockID
id)
const;
652 void setNumStores(blockID
id, std::string name);
654 const std::string& getNumStores(blockID
id)
const;
656 void setLoadOffsets(blockID
id, std::string name);
658 const std::string& getLoadOffsets(blockID
id)
const;
660 void setStoreOffsets(blockID
id, std::string name);
662 const std::string& getStoreOffsets(blockID
id)
const;
664 void setLoadPorts(blockID
id, std::string name);
666 const std::string& getLoadPorts(blockID
id)
const;
668 void setStorePorts(blockID
id, std::string name);
670 const std::string& getStorePorts(blockID
id)
const;
672 void setGetPtrConst(blockID
id,
int c);
674 int getGetPtrConst(blockID
id)
const;
681 longValueType getValue(blockID
id);
688 bool getBoolValue(blockID
id)
const;
695 int getBufferSize(blockID
id)
const;
702 void setBufferSize(blockID
id,
int slots);
709 bool isBufferTransparent(blockID
id)
const;
716 void setBufferTransparency(blockID
id,
bool value);
722 blockID getBlockFromPort(portID p)
const;
728 void removeBlock(blockID block);
740 portID createPort(blockID block,
bool isInput,
const std::string& name=
"",
int width = -1, PortType type = GENERIC_PORT);
746 void removePort(portID port);
754 portID getPort(blockID block,
const std::string& name)
const;
762 const std::string& getPortName(portID port,
bool full=
true)
const;
769 PortType getPortType(portID port)
const;
776 bool isInputPort(portID port)
const;
783 bool isOutputPort(portID port)
const;
790 void setPortWidth(portID port,
int width);
797 int getPortWidth(portID port)
const;
804 bool isBooleanPort(portID port)
const;
811 bool isControlPort(portID port)
const;
819 bool isBooleanConstant(portID port,
bool& value)
const;
826 double getPortDelay(portID port)
const;
833 void setPortDelay(portID port,
double d);
843 double getCombinationalDelay(portID inp, portID outp)
const;
851 const setPorts& getPorts(blockID
id, PortDirection dir)
const;
858 const setPorts& getDefinitions(portID p)
const;
864 portID getConditionalPort(blockID
id)
const;
870 portID getTruePort(blockID
id)
const;
876 portID getFalsePort(blockID
id)
const;
882 portID getDataPort(blockID
id)
const;
891 portID getDemuxComplementaryPort(portID port)
const;
898 channelID getConnectedChannel(portID port)
const;
905 bool isPortConnected(portID port)
const;
912 portID getConnectedPort(portID port)
const;
922 channelID createChannel(portID src, portID dst,
int slots = 0,
bool transparent =
true);
928 void removeChannel(channelID
id);
935 portID getSrcPort(channelID
id)
const;
942 portID getDstPort(channelID
id)
const;
949 blockID getSrcBlock(channelID
id)
const;
956 blockID getDstBlock(channelID
id)
const;
965 string getChannelName(channelID
id,
bool full=
true)
const;
972 channelID getChannelID(portID
id);
980 int getChannelBufferSize(channelID
id)
const;
987 void setChannelBufferSize(blockID
id,
int slots);
994 bool isChannelTransparent(channelID
id)
const;
1001 void setChannelTransparency(channelID
id,
bool value);
1008 void setChannelEB(channelID
id);
1014 bool getChannelEB(channelID
id);
1016 void setChannelFrequency(channelID
id,
double value);
1018 double getChannelFrequency(channelID
id);
1025 bool hasBuffer(channelID
id)
const;
1035 blockID insertBuffer(channelID c,
int slots,
bool transparent);
1046 blockID insertBuffer(channelID c,
int slots,
bool transparent,
bool EB);
1053 channelID removeBuffer(blockID buf);
1059 void setError(
const std::string& err);
1064 const std::string& getError()
const;
1069 std::string& getError();
1080 bool hasError()
const;
1085 int numBlocks()
const;
1090 int numChannels()
const;
1095 int numPorts()
const;
1101 bool validPort(portID p)
const;
1108 bool validBlock(blockID
id)
const;
1115 bool validChannel(channelID
id)
const;
1120 void reduceMerges();
1122 void execute_reduction(blockID b);
1130 bool writeDot(
const std::string& filename =
"");
1137 bool writeDot(std::ostream& of);
1139 bool writeDotMG(
const std::string& filename =
"");
1140 bool writeDotMG(std::ostream& s);
1142 bool writeDotBB(
const std::string& filename =
"");
1143 bool writeDotBB(std::ostream& of);
1151 bool writeBasicBlockDot(
const std::string& filename =
"");
1158 bool writeBasicBlockDot(std::ostream& s);
1170 bool addElasticBuffers(
double Period = 0,
double BufferDelay = 0,
bool MaxThroughput =
false,
double coverage = 0);
1182 bool addElasticBuffersBB(
double Period = 0,
double BufferDelay = 0,
bool MaxThroughput =
false,
double coverage = 0,
int timeout = -1,
bool first_MG =
false);
1183 bool addElasticBuffersBB_sc(
double Period = 0,
double BufferDelay = 0,
bool MaxThroughput =
false,
double coverage = 0,
int timeout = -1,
bool first_MG =
false,
const std::string& model_mode =
"default",
const std::string& lib_path=
"");
1185 void addBorderBuffers();
1186 void findMCLSQ_load_channels();
1191 void instantiateElasticBuffers();
1196 void instantiateAdditionalElasticBuffers(
const std::string& filename);
1202 void hideElasticBuffers();
1207 void cleanElasticBuffers();
1213 void setMilpSolver(
const std::string& solver=
"cbc");
1228 bool calculateBasicBlocks();
1242 bool removeControl();
1251 double extractMarkedGraphs(
double coverage);
1260 double extractMarkedGraphsBB(
double coverage);
1262 void printBlockSCCs();
1263 void computeSCCpublic(
bool onlyMarked) {
1264 computeSCC(onlyMarked);
1267 setBlocks allBlocks;
1269 setChannels allChannels;
1280 longValueType value;
1294 portID portTrue, portFalse;
1299 double retimingDiff;
1303 std::deque<portID> listPorts;
1304 std::map<portID,portID> demuxPairs;
1307 std::string operation;
1313 std::string memName;
1314 std::string funcName;
1317 std::string numLoads;
1318 std::string numStores;
1319 std::string loadOffsets;
1320 std::string storeOffsets;
1321 std::string loadPorts;
1322 std::string storePorts;
1324 map<bbID, vector<int>> orderings;
1329 std::string short_name;
1330 std::string full_name;
1339 std::string memPortSuffix;
1353 bool channelMerge =
false;
1360 setChannels channels;
1366 subNetlist(subNetlist
const& other) :
1367 blocks(other.blocks), channels(other.channels) {}
1370 subNetlist& operator=(subNetlist other) {
1376 void swap(subNetlist& other) {
1378 swap(blocks, other.blocks);
1379 swap(channels, other.channels);
1389 bool empty()
const {
1390 return channels.empty() and blocks.empty();
1394 int numBlocks()
const {
1395 return blocks.size();
1399 int numChannels()
const {
1400 return channels.size();
1404 const setBlocks& getBlocks()
const {
1409 const setChannels& getChannels()
const {
1414 bool hasBlock(blockID b)
const {
1415 return blocks.count(b) > 0;
1419 bool hasChannel(channelID c)
const {
1420 return channels.count(c) > 0;
1424 void insertBlock(blockID b) {
1437 struct subNetlistBB {
1438 set <bbID> BasicBlocks;
1439 set <bbArcID> BasicBlockArcs;
1450 BasicBlockArcs = {};
1455 BasicBlocks.clear();
1456 BasicBlockArcs.clear();
1465 return BasicBlocks.empty() and BasicBlockArcs.empty();
1469 return BasicBlocks.size();
1472 int numBasicBlockArcs() {
1473 return BasicBlockArcs.size();
1476 const set<bbID>& getBasicBlocks() {
1480 const set<bbArcID>& getBasicBlockArcs() {
1481 return BasicBlockArcs;
1484 bool hasBasicBlock(bbID b) {
1485 return BasicBlocks.count(b) > 0;
1488 bool hasBasicBlockArc(bbArcID a) {
1489 return BasicBlockArcs.count(a) > 0;
1492 void insertBasicBlock(bbID b) {
1493 BasicBlocks.insert(b);
1496 void insertBasicBlockArc(bbArcID a) {
1497 BasicBlockArcs.insert(a);
1500 void merge(subNetlistBB& other) {
1501 for (bbID bb: other.getBasicBlocks()) {
1502 insertBasicBlock(bb);
1505 for (bbArcID bbArc: other.getBasicBlockArcs()) {
1506 insertBasicBlockArc(bbArc);
1510 bool sameSCC(subNetlistBB other) {
1511 return SCC_no == other.getSCCnumber();
1514 int getSCCnumber() {
1518 int setSCCnumber(
int number) {
1522 int getMinimumFreq() {
1526 void setMinimumFreq(
int freq) {
1530 int getDSUnumber() {
1534 void setDSUnumber(
int number) {
1538 bool haveCommonBasicBlock(subNetlistBB &other) {
1539 for (bbID bb: other.getBasicBlocks()) {
1540 if (hasBasicBlock(bb)) {
1547 int getDSUParent() {
1551 void setDSUParent(
int parent) {
1552 DSU_parent = parent;
1559 void setDSURank(
int rank) {
1563 void increaseDSURank() {
1568 std::string net_name;
1576 std::vector<Block> blocks;
1577 std::vector<Port> ports;
1578 std::vector<Channel> channels;
1592 setBlocks parameters;
1594 blockID entryControl;
1595 setBlocks exitControl;
1600 std::string milpSolver;
1602 std::map<std::string,blockID> name2block;
1603 std::map<std::string,portID> name2port;
1606 static std::map<BlockType,std::string> BlockType2String;
1607 static std::map<std::string,BlockType> String2BlockType;
1608 static std::map<PortType,std::string> PortType2String;
1609 static std::map<std::string,PortType> String2PortType;
1611 std::vector<blockID> DFSorder;
1612 std::vector<subNetlist> SCC;
1614 std::vector<subNetlist> MG;
1615 std::vector<double> MGfreq;
1617 setBlocks blocks_in_MGs;
1618 setChannels channels_in_MGs;
1620 setBlocks blocks_in_borders;
1621 setChannels channels_in_borders;
1623 setBlocks blocks_in_MC_LSQ;
1624 setChannels channels_in_MC_LSQ;
1626 std::vector<subNetlist> MG_disjoint;
1627 std::vector<double> MG_disjoint_freq;
1629 std::vector<subNetlistBB> CFDFC;
1630 std::vector<double> CFDFCfreq;
1633 std::vector<subNetlistBB> CFDFC_disjoint;
1634 std::vector<double> CFDFC_disjoint_freq;
1636 std::vector<vector<int> > components;
1641 vector<int> buffer_flop;
1642 vector<int> buffer_flop_valid;
1643 vector<int> buffer_flop_ready;
1644 vector<int> buffer_slots;
1645 vector<int> has_buffer;
1646 vector<int> time_path;
1647 vector<int> time_valid_path;
1648 vector<int> time_ready_path;
1649 vector<int> time_elastic;
1650 vector<vector<int>> in_retime_tokens;
1651 vector<vector<int>> out_retime_tokens;
1652 vector<vector<int>> retime_bubbles;
1653 vector<vector<int>> th_tokens;
1654 vector<vector<int>> th_bubbles;
1666 int vecBlocksSize()
const {
1667 return blocks.size();
1673 int vecChannelsSize()
const {
1674 return channels.size();
1680 int vecPortsSize()
const {
1681 return ports.size();
1691 bool readDataflowDot(
const std::string& filename);
1700 bool readDataflowDot(FILE* f);
1702 bool readDataflowDotBB(FILE *f);
1703 bool readDataflowDotBB(
const std::string& filename);
1710 std::string genBlockName(BlockType type)
const;
1719 bool checkPortsConnected(blockID
id = invalidDataflowID);
1726 int numInPorts(blockID b)
const {
1727 assert(validBlock(b));
1728 return blocks[b].inPorts.size();
1731 int getBlockSCCno(blockID b)
const {
1732 assert(validBlock(b));
1733 return blocks[b].scc_number;
1740 int numOutPorts(blockID b)
const {
1741 assert(validBlock(b));
1742 return blocks[b].outPorts.size();
1750 portID getInPort(blockID b)
const {
1751 if (blocks[b].inPorts.empty())
return invalidDataflowID;
1752 return *(blocks[b].inPorts.begin());
1760 portID getOutPort(blockID b)
const {
1761 if (blocks[b].outPorts.empty())
return invalidDataflowID;
1762 return *(blocks[b].outPorts.begin());
1769 bool checkElasticBuffer(blockID b);
1775 bool checkFork(blockID b);
1781 bool checkBranch(blockID b);
1787 bool checkMerge(blockID b);
1793 bool checkSelect(blockID b);
1799 bool checkFunc(blockID b);
1805 bool checkConstant(blockID b);
1812 bool checkFuncEntry(blockID b);
1819 bool checkFuncExit(blockID b);
1826 bool checkDemux(blockID b);
1833 bool checkGenericPorts(blockID b);
1839 void inferChannelWidth(
int default_width);
1848 bool checkSamePortWidth(portID p1, portID p2);
1856 bool checkSamePortWidth(
const setPorts& P);
1866 bool checkNumPorts(blockID b,
int nin,
int nout);
1868 bool setAllBBFrequencies();
1869 bool determineEntryExitBlock();
1870 void computeChannelFrequencies();
1871 void computeBlockFrequencies();
1878 void writeBlockDot(std::ostream& s, blockID
id);
1885 void writeChannelDot(std::ostream& s, channelID
id);
1888 void writeBasicBlockDot(std::ostream& s, bbID
id);
1889 void writeArcDot(std::ostream& s, bbArcID
id);
1895 void markAllBlocks(
bool value) {
1896 ForAllBlocks(b) blocks[b].mark = value;
1903 void markAllChannels(
bool value) {
1904 ForAllChannels(c) channels[c].mark = value;
1912 void markBlock(blockID b,
bool value) {
1913 assert(validBlock(b));
1914 blocks[b].mark = value;
1922 void setDFSorder(blockID b,
int value) {
1923 assert(validBlock(b));
1924 blocks[b].DFSorder = value;
1931 int getDFSorder(blockID b)
const {
1932 assert(validBlock(b));
1933 return blocks[b].DFSorder;
1941 void markChannel(channelID c,
bool value) {
1942 assert(validChannel(c));
1943 channels[c].mark = value;
1951 bool isBlockMarked(blockID b)
const {
1952 assert(validBlock(b));
1953 return blocks[b].mark;
1961 bool isChannelMarked(channelID c)
const {
1962 assert(validChannel(c));
1963 return channels[c].mark;
1972 void setBackEdge(channelID c,
bool value =
true) {
1973 assert(validChannel(c));
1974 channels[c].backEdge = value;
1982 bool isBackEdge(channelID c)
const {
1983 assert(validChannel(c));
1984 return channels[c].backEdge;
1995 void DFS(
bool forward =
true,
bool onlyMarked =
false);
2001 void calculateBackEdges();
2010 void computeSCC(
bool onlyMarked =
false);
2015 const std::string& getMilpSolver()
const {
2025 void createMilpVarsEB(
Milp_Model& milp, milpVarsEB& vars,
bool max_throughput,
bool first_MG=
false);
2026 void createMilpVarsEB_sc(
Milp_Model& milp, milpVarsEB& vars,
bool max_throughput,
int mg,
bool first_MG=
false,
string model_mode=
"default");
2027 void createMilpVars_remaining(
Milp_Model& milp, milpVarsEB& vars,
string model_mode);
2038 bool createPathConstraints(
Milp_Model& milp, milpVarsEB& Vars,
double Period,
double BufferDelay);
2039 bool createPathConstraints_sc(
Milp_Model& milp, milpVarsEB& Vars,
double Period,
double BufferDelay,
int mg);
2040 bool createPathConstraintsOthers_sc(
Milp_Model& milp, milpVarsEB& Vars,
double Period,
double BufferDelay,
int mg,
string model_mode,
string lib_path);
2041 bool createPathConstraints_remaining(
Milp_Model& milp, milpVarsEB& Vars,
double Period,
double BufferDelay);
2042 bool createPathConstraintsOthers_remaining(
Milp_Model& milp, milpVarsEB& Vars,
double Period,
double BufferDelay,
string model_mode,
string lib_path);
2045 vector< pair<string, vector<double>>> read_lib_file(
string lib_file_path);
2054 bool createElasticityConstraints(
Milp_Model& milp, milpVarsEB& Vars);
2055 bool createElasticityConstraints_sc(
Milp_Model& milp, milpVarsEB& Vars,
int mg);
2056 bool createElasticityConstraints_remaining(
Milp_Model& milp, milpVarsEB& Vars);
2066 bool createThroughputConstraints(
Milp_Model& milp, milpVarsEB& Vars,
bool first_MG=
false);
2067 bool createThroughputConstraints_sc(
Milp_Model& milp, milpVarsEB& Vars,
int mg,
bool first_MG=
false);
2069 bool channelIsInMGs(channelID c);
2070 bool blockIsInMGs(blockID b);
2072 bool channelIsInBorders(channelID c);
2073 bool blockIsInBorders(blockID b);
2075 bool channelIsInMCLSQ(channelID c);
2076 bool blockIsInMCLSQ(blockID b);
2078 bool channelIsCovered(channelID c,
bool MG,
bool borders,
bool MC_LSQ);
2079 bool blockIsCovered(blockID b,
bool MG,
bool borders,
bool MC_LSQ);
2085 void dumpMilpSolution(
const Milp_Model& milp,
const milpVarsEB& vars)
const;
2087 void writeRetimingDiffs(
const Milp_Model& milp,
const milpVarsEB& vars);
2096 void makeNonTransparentBuffers();
2104 bool removeUnreachableBlocksAndPorts();
2110 bool removeConstantBranchSelect();
2118 bool removeOneInOneOutMergeForkDemux();
2124 bool collapseMergeFork();
2130 void makeDisjointBB(blockID b);
2137 blockID findDisjointBB(blockID b);
2146 bool unionDisjointBB(blockID b1, blockID b2);
2152 void invalidateBasicBlocks();
2161 void calculateDefinitions();
2169 subNetlist extractMarkedGraph(
const map<blockID, double>& freq);
2177 subNetlistBB extractMarkedGraphBB(
const map<bbID, double>& freq);
2184 subNetlist getMGfromCFDFC(subNetlistBB &BB_CFDFC);
2186 void calculateDisjointCFDFCs();
2187 int findCFDFC(
int i);
2188 void unionCFDFC(
int x,
int y);
2190 void makeMGsfromCFDFCs();
2197 void setUnitDelays();
2199 bool removeFakeBranches();
2203 std::vector<Block> & getBlocks(){
2206 std::vector<Port> & getPorts(){
2209 std::vector<Channel> & getChannels(){
2236 bool add(
const string& filename);
2244 bool writeDot(
const std::string& filename =
"");
2251 bool writeDot(std::ostream& s);
2287 return error.exists();
2303 auto it = name2func.find(fname);
2304 if (it == name2func.end())
return invalidDataflowID;
2314 funcID
id = getFuncID(fname);
2315 assert (
id != invalidDataflowID);
2325 funcID
id = getFuncID(fname);
2326 assert (
id != invalidDataflowID);
2336 assert (allFuncs.count(
id) > 0);
2346 assert (allFuncs.count(
id) > 0);
2351 std::string libName;
2356 vector<DFnetlist> funcs;
2357 map<string, funcID> name2func;
2358 set<funcID> allFuncs;
2368 #endif // DATAFLOW_IMPL_H void setExecTime(bbID bb, double t)
Sets the execution time of a BB.
Definition: DFnetlist.h:263
int numFuncs() const
Definition: DFnetlist.h:2293
const DFnetlist & operator[](const string &fname) const
Returns a const reference to the dataflow netlist of a function.
Definition: DFnetlist.h:2324
setBBArcs & successors(bbID bb)
Returns the set of successor arcs.
Definition: DFnetlist.h:236
bbID getEntryBasicBlock() const
Definition: DFnetlist.h:115
bool calculateBasicBlockFrequencies(double back_prob=0.9)
If the BB frequencies are already define, nothing is done. Otherwise, the BB frequencies are calculat...
Definition: DFnetlsit_BasicBlocks.cpp:346
blockID getBlockFromPort(portID p) const
Definition: DFnetlist.cpp:612
funcID getFuncID(const string &fname) const
Gets a funcID from a name function.
Definition: DFnetlist.h:2302
portID getSrcPort(channelID id) const
Returns the source port of a channel.
Definition: DFnetlist.cpp:912
int numBasicBlocks() const
Definition: DFnetlist.h:68
void clear()
Initializes the BB graph (empty).
Definition: DFnetlist.h:59
Definition: DFnetlist.h:45
Definition: DFnetlist.h:417
portID getDstPort(channelID id) const
Returns the destination port of a channel.
Definition: DFnetlist.cpp:918
DFlib_Impl()
Default constructor (empty library).
Definition: DFnetlist.h:2221
std::string & getError()
Definition: DFnetlist.h:2271
setBBArcs & predecessors(bbID bb)
Returns the set of predecessor arcs.
Definition: DFnetlist.h:227
bbID createBasicBlock()
Adds a new BB to the BB graph.
Definition: DFnetlist.h:91
Definition: Dataflow.h:83
Definition: ErrorManager.h:17
DFnetlist & operator[](funcID id)
Returns a reference to the dataflow netlist of a function.
Definition: DFnetlist.h:2335
bool empty() const
Definition: DFnetlist.h:82
void clearError()
Erases the error.
Definition: DFnetlist.h:2278
BasicBlockGraph()
Constructor.
Definition: DFnetlist.h:52
bool hasError() const
Indicates whether there is an error.
Definition: DFnetlist.h:2286
double getProbability(bbArcID arc) const
Returns the probability of an arc.
Definition: DFnetlist.h:184
Definition: MILP_Model.h:26
const DFnetlist & operator[](funcID id) const
Returns a const reference to the dataflow netlist of a function.
Definition: DFnetlist.h:2345
bool isBackArc(bbArcID arc) const
Checks whether an arc is forward or backward.
Definition: DFnetlist.h:218
void setFrequency(bbID bb, double f)
Sets de execution frequency of a BB.
Definition: DFnetlist.h:245
Definition: DFnetlist.h:2214
void setProbability(bbArcID arc, double prob)
Defines the probability of an arc.
Definition: DFnetlist.h:175
void setError(const std::string &err)
Sets an error message for the library.
Definition: DFnetlist.h:2257
bbID getSrcBB(bbArcID arc) const
Returns the src BB of an arc.
Definition: DFnetlist.h:157
double getExecTime(bbID bb) const
Retgurns the execution time of a BB.
Definition: DFnetlist.h:272
void setBackArc(bbArcID arc, bool back=true)
Defines whether an arc is forward or backward.
Definition: DFnetlist.h:209
DFnetlist & operator[](const string &fname)
Returns a reference to the dataflow netlist of a function.
Definition: DFnetlist.h:2313
double getFrequency(bbID bb) const
Returns the execution frequency of a BB.
Definition: DFnetlist.h:254
void setEntryBasicBlock(bbID bb)
Defines the entry BB.
Definition: DFnetlist.h:108
bbArcID findArc(bbID src, bbID dst) const
Returns the arc between two BBs.
Definition: DFnetlsit_BasicBlocks.cpp:245
int numArcs() const
Definition: DFnetlist.h:75
bbID getDstBB(bbArcID arc) const
Returns the dst BB of an arc.
Definition: DFnetlist.h:166
bool calculateBackArcs()
Calculates the back edges using a DFS traversal from the entry basic block.
Definition: DFnetlsit_BasicBlocks.cpp:267
Class to handle few utilities for files.
const std::string & getError() const
Definition: DFnetlist.h:2264
double extractBasicBlockCycles(double coverage=-1.0)
Extracts a set of Basic Block cycles that maximizes the covered execution time.
Definition: DFnetlist_BBcycles.cpp:6
bbArcID findOrAddArc(bbID src, bbID dst, double freq=0)
Creates an arc between two BBs (if it did not exist)
Definition: DFnetlsit_BasicBlocks.cpp:253