-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutilities.h
190 lines (128 loc) · 5.03 KB
/
utilities.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#pragma once
#include "basic_types.h"
#include "swap_target.h"
#include "design_info.h"
#include <map>
using namespace std;
void calculatePenalty();
double calculateFastPenalty(map<int, double> &m);
/* ************************************************** */
/* Cell Shortcuts */
/* ************************************************** */
inline bool isNI(int cell_index)
{
return design.cell_lib[cell_index].getNI();
}
inline bool isTerminal(int cell_index)
{
return design.cell_lib[cell_index].getTerminal();
}
inline coor_type getCellHalfWidth(int index)
{
return design.cell_lib[index].getWidth() / 2;
}
inline coor_type getCellLeftBorder(int index)
{
return design.cell_lib[index].getCenter().x - getCellHalfWidth(index);
}
inline coor_type getCellRightBorder(int index)
{
return design.cell_lib[index].getCenter().x + getCellHalfWidth(index);
}
inline Coor getCellCenter(int index)
{
return design.cell_lib[index].getCenter();
}
inline Coor getCellOriginalCenter(int index)
{
return design.cell_lib[index].getOriginalCenter();
}
inline coor_type getCellWidth(int index)
{
return design.cell_lib[index].getWidth();
}
inline coor_type getCellHeight(int index)
{
return design.cell_lib[index].getHeight();
}
inline coor_type getCellHalfHeight(int index)
{
return design.cell_lib[index].getHeight() / 2;
}
inline int getCellRow(int cell_index);
size_t getRow(coor_type p_y);
bool isInThisRow(int cell_index, int row_number);
/* ************************************************** */
/* HPWL */
/* ************************************************** */
double findTotalHPWL(void);
void printTotalHPWL(void);
coor_type findTotalHPWLofConnectedNets(int index);
coor_type findTotalHPWLofConnectedNets(int index, vector<int> &nets_to_ignore);
coor_type hpwlChangeAfterMovingCellToCoor(int cell_index, Coor target_coor);
coor_type hpwlChangeAfterMovingCellToCoor(int cell_index, Coor target_coor, vector<int> &nets_to_ignore);
coor_type hpwlChangeAfterSwappingTwoCells(int cell1_index, int cell2_index);
/* ************************************************** */
/* Optimal Region */
/* ************************************************** */
void findOptimalRegion(int cell_index, Region &r);
void findBetterRegion(int cell_index, Region &r);
int getManhattanDistanceToRegion(Coor c, Region r);
coor_type getDistanceToOptimalRegion(int cell_index);
coor_type getDistanceBetweenPoints(Coor p1, Coor p2);
Region overlapOfTwoRegion(Region& r1, Region& r2);
void findMaximumHandsomeRegion(int cell_index, Region &r);
/* ************************************************** */
/* Cell Tools */
/* ************************************************** */
bool compareCellsYX(int i1, int i2);
bool compareCellsX(int i1, int i2);
bool compareCellsLX(int i1, int i2);
void findNetsInCommon(int cell1_index, int cell2_index, vector<int> &common_nets);
coor_type getRowCenter(int row_number);
Coor getCellLL(int cell_index);
void getCellsInGivenRow(int row_number, vector<int> &cell_pool, vector<int> &result);
void fillRowVectors(int top_row, int bot_row, vector<int> &cell_pool, vector<vector<int> > &result);
/* ************************************************** */
/* SwapTarget Manipulations */
/* ************************************************** */
void fillVectorWithSwapTargetsInThisBin(int bin_index, vector<SwapTarget> &swap_targets);
void fillVectorWithSwapTargetsInThisRegion(Region &r, vector<SwapTarget> &swap_targets);
void fillVectorWithSwapTargetsInThisBinLeftSort(int bin_index, vector<SwapTarget> &swap_targets);
struct FartherstSortStruc
{
public:
Coor point;
FartherstSortStruc(Coor p) : point(p) {};
bool operator() (int i, int j )
{
return getManhattanDistanceToRegion(point, bin_lib[i].getRegion()) > getManhattanDistanceToRegion(point, bin_lib[j].getRegion());
}
};
float distanceBetween(int cell_index, SwapTarget swap_target);
bool sortByWhitespaceWidth(SwapTarget a, SwapTarget b);
bool areIndependent(int *cells, SwapTarget *targets, float *profit, int cell_num);
/*
inline coor_type getSwapTargetIfIsCellandGetWidth(SwapTarget st)
{
return getCellWidth(st.cell_index) + min(st.left_ww, st.right_ww) * 2;
}*/
/* ************************************************** */
/* Density */
/* ************************************************** */
bool densitySorter(int i1, int i2);
int getDensityPercentile(int cell_index);
float getSwapTargetDensity(SwapTarget swap_target);
/* ************************************************** */
/* Timing */
/* ************************************************** */
int timeInUs(void);
void resetTimers(void);
void displayTimers(void);
void resetTotalTimers(void);
void displayTotalTimers(void);
float timeInSec(int t);
bool isCellsDisjoint(int cell1_index, int cell2_index, Region &r1, Region &r2);
/* Multithreading */
void enterReader(void);
void exitReader(void);