Program Listing for File HSPartitionFlow.h¶
↰ Return to documentation for file (src/sta/HSPartitionFlow.h)
#pragma once
#include <unordered_set>
#include "../partition/defs.h"
#include "../partition/parallel_hashmap/phmap.h"
#include "HSStaBase.h"
#include "HSTimingSlackRange.h"
using phmap::flat_hash_map;
namespace HSFullTiming {
// lihaoyuan add
struct edge_info {
int from_node;
int to_node;
int net;
// // 大图转小图功能过渡期变量:板间顶层新增port名称
// string bottom_port;
// string from_port;
// string to_port;
};
class HSTimingLocalData;
class HSTimingEdge;
class HSCutOnlyFlow;
class HSCutNetFlow;
// The HSPartitionNet struct represents a net within a partitioned timing graph.
// It stores information about the partitions connected by the net and the
// corresponding edge IDs.
struct HSPartitionNet {
// A vector of partition IDs that this net connects.
// The first element is typically considered the driver partition.
vector<int> m_parts; // first is driver node
// A vector of edge IDs associated with the connections between partitions in
// m_parts. The size of m_edgeIds should be m_parts.size() - 1.
vector<int> m_edgeIds; // m_parts.size() - 1 should equal m_edgeIds.size()
};
// The HSPartitionFlow class manages the overall static timing analysis flow
// for a partitioned design. It inherits from HSStaBase to leverage common STA
// functionalities and orchestrates the analysis across different partitions
// using HSTimingLocalData.
class HSPartitionFlow : public HSStaBase {
public:
// Default constructor.
HSPartitionFlow();
// Virtual destructor. Ensures proper cleanup of allocated HSPartitionNet and
// HSTimingLocalData objects.
virtual ~HSPartitionFlow();
// Cleans up data related to partitions, including nets and local timing data.
void cleanPartition();
void cleanOurPartition();
void deleteOurLocalData(int index);
// Parses the input files or data that describe the partitioned design and
// its timing characteristics.
// @param dInputs A string representing the path to input data or the data
// itself.
// @return An integer status code (typically 0 for success).
int parseInput(const string &dInputs);
// Overrides the pure virtual function from HSStaBase.
// Builds the local timing data for each partition.
// @return An integer status code.
virtual int buildLocalData();
string trim(const string &str);
// daiyt: 建立LocalData
HSTimingLocalData *buildLocalData(const vector<int> &partInfo);
// daiyt: 拷贝LocalData
HSTimingLocalData *cloneOurLocalData(int index);
// 前K条路径融合
void mergeEdgePaths(vector<timingpath> &mergePaths, const string &folder,
int k, float mergeRatio);
// Prints a report of timing paths for edges to the specified output
// directory.
// @param dOutDir The directory where the report files will be written.
// @param printNum The number of paths to print per edge or a similar
// controlling parameter.
// @return An integer status code.
int printEdgePathReport(const std::string &timing_aware_dOutDir,
const string &dOutDir,
int printNum); // print output dir
int expandPaths(const string &time, vector<timingpath> &pathDataAll);
// daiyt: 获取EdgePaths
void getEdgePaths(vector<timingpath> &edgePaths) const;
// lihaoyuan:获取割边上的时序路径
int getEdgePathReport(const vector<int> &edgeIds, vector<timingpath> &path);
// get or set data functions
// Gets the number of hyper-nodes (which could represent partitions or major
// blocks) in the design.
// @return The number of hyper-nodes.
int getHyperNodeNum() const;
// daiyt: 传入一个timingpath返回一个对应的json对象
json getTimingPaths(vector<timingpath> pathDataAll) const;
static bool initSlackRange(int slack_range)
{
return HSFullTiming::initSlackRange(slack_range);
}
static bool setSlackRange(int slack_range)
{
return HSFullTiming::setSlackRange(slack_range);
}
// daiyt: 获取slack range
int getSlackRange()
{
return HSFullTiming::getSlackRange();
}
// lihaoyuan:获取普通边的映射关系
int setEdgeInfos();
// peichunyan added start
int setPin2Edge();
// int setInsPaths();
bool hasLocalDatas() const
{
return !m_localDatas.empty();
};
vector<HSOuterEdge *> get_m_outerEdgeAll() const
{
return m_outerEdgeAll;
};
vector<HSPartitionNet *> get_m_netAll() const
{
return m_netAll;
};
const vector<HSPartitionNet *> &getNetAll() const
{
return m_netAll;
}
const vector<int> &getEdge2NetId() const
{
return m_edge2NetId;
}
vector<HSGraphClock *> get_m_clkAll() const
{
return m_clkAll;
}
const vector<std::shared_ptr<edge_info>> &get_edgeInfos() const
{
return edgeInfos;
}
const flat_hash_map<pair<int, int>, int> &get_pin2Edge() const
{
return pin2Edge;
}
void setEdgePortNames(int edgeId, const string &fromPort,
const string &toPort);
vector<HSTimingLocalData *> get_m_localDatas() const
{
return m_localDatas;
}
vector<HSTimingLocalData *> get_m_ourLocalDatas() const
{
return m_ourLocalDatas;
}
vector<set<int>> get_ins_paths() const
{
return ins_paths;
}
flat_hash_map<string, int> get_m_insPin_net() const
{
return m_insPin_net;
}
HSTimingLocalData *getOurLocalData(int index) const
{
if (index < 0 || index >= m_ourLocalDatas.size()) {
return nullptr;
}
return m_ourLocalDatas[index];
}
HSTimingLocalData *addOneLocalData();
int paramCal(flat_hash_map<int, set<pair<int, int>>> &net_insPin_set,
flat_hash_map<pair<int, int>, pinSlack> &pin_minslack,
const bool &has_mul_clock_domains,
const shared_ptr<mulClockAttr> &clockAttr,
const float &maximum_clock_period);
void storeClockAttr(shared_ptr<mulClockAttr> &clockAttr,
bool &has_mul_clock_domains);
// peichunyan added end
void printTopkMinSlack(HSTimingLocalData *oneLocal, int k);
void getTopkCutPaths(vector<HSStaBase::timingpath> &cutPaths,
HSTimingLocalData *oneLocal, int k);
void dumpTopkCutPaths(HSTimingLocalData *oneLocal, int k,
const std::string &filepath);
private:
friend class HSCutOnlyFlow;
friend class HSCutNetFlow;
void buildEdge2NetId();
// The number of hyper-nodes (partitions) in the design.
int m_hyperNodeNum = 0;
// A vector storing pointers to all HSPartitionNet objects, representing the
// connectivity between partitions.
vector<HSPartitionNet *> m_netAll;
// edgeId -> netId 映射,可被所有 localData 共享。
vector<int> m_edge2NetId;
// A vector storing pointers to HSTimingLocalData objects, one for each
// partition, managing the timing information local to that partition.
vector<HSTimingLocalData *> m_localDatas;
vector<HSTimingLocalData *> m_ourLocalDatas;
// added by peicy
vector<std::shared_ptr<edge_info>> edgeInfos;
flat_hash_map<pair<int, int>, int> pin2Edge;
vector<set<int>> ins_paths;
flat_hash_map<string, int> m_insPin_net;
};
} // namespace HSFullTiming