Skip to content

Commit

Permalink
Merge pull request The-OpenROAD-Project#5573 from eder-matheus/grt_in…
Browse files Browse the repository at this point in the history
…stability

grt: fix instability in macOS builds
  • Loading branch information
eder-matheus authored Aug 13, 2024
2 parents 13116aa + 7e008e6 commit 665743f
Show file tree
Hide file tree
Showing 27 changed files with 19,754 additions and 20,057 deletions.
4 changes: 2 additions & 2 deletions src/grt/src/fastroute/include/DataType.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ struct Edge // An Edge is the routing track holder between two adjacent
uint16_t usage; // the usage of the edge
uint16_t red;
int16_t last_usage;
float est_usage; // the estimated usage of the edge
double est_usage; // the estimated usage of the edge

uint16_t usage_red() const { return usage + red; }
float est_usage_red() const { return est_usage + red; }
double est_usage_red() const { return est_usage + red; }
};

struct Edge3D
Expand Down
34 changes: 17 additions & 17 deletions src/grt/src/fastroute/include/FastRoute.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,10 @@ class FastRouteCore
void convertToMazerouteNet(const int netID);
void setupHeap(const int netID,
const int edgeID,
std::vector<float*>& src_heap,
std::vector<float*>& dest_heap,
multi_array<float, 2>& d1,
multi_array<float, 2>& d2,
std::vector<double*>& src_heap,
std::vector<double*>& dest_heap,
multi_array<double, 2>& d1,
multi_array<double, 2>& d2,
const int regionX1,
const int regionX2,
const int regionY1,
Expand Down Expand Up @@ -436,8 +436,8 @@ class FastRouteCore
void spiralRoute(int netID, int edgeID);
void routeMonotonic(int netID,
int edgeID,
multi_array<float, 2>& d1,
multi_array<float, 2>& d2,
multi_array<double, 2>& d1,
multi_array<double, 2>& d2,
int threshold,
int enlarge);

Expand Down Expand Up @@ -577,17 +577,17 @@ class FastRouteCore
std::vector<short> h_capacity_3D_;
std::vector<short> last_col_v_capacity_3D_;
std::vector<short> last_row_h_capacity_3D_;
std::vector<float> cost_hvh_; // Horizontal first Z
std::vector<float> cost_vhv_; // Vertical first Z
std::vector<float> cost_h_; // Horizontal segment cost
std::vector<float> cost_v_; // Vertical segment cost
std::vector<float> cost_lr_; // Left and right boundary cost
std::vector<float> cost_tb_; // Top and bottom boundary cost
std::vector<float> cost_hvh_test_; // Vertical first Z
std::vector<float> cost_v_test_; // Vertical segment cost
std::vector<float> cost_tb_test_; // Top and bottom boundary cost
std::vector<float> h_cost_table_;
std::vector<float> v_cost_table_;
std::vector<double> cost_hvh_; // Horizontal first Z
std::vector<double> cost_vhv_; // Vertical first Z
std::vector<double> cost_h_; // Horizontal segment cost
std::vector<double> cost_v_; // Vertical segment cost
std::vector<double> cost_lr_; // Left and right boundary cost
std::vector<double> cost_tb_; // Top and bottom boundary cost
std::vector<double> cost_hvh_test_; // Vertical first Z
std::vector<double> cost_v_test_; // Vertical segment cost
std::vector<double> cost_tb_test_; // Top and bottom boundary cost
std::vector<double> h_cost_table_;
std::vector<double> v_cost_table_;
std::vector<int> xcor_;
std::vector<int> ycor_;
std::vector<int> dcor_;
Expand Down
40 changes: 20 additions & 20 deletions src/grt/src/fastroute/src/maze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,13 +520,13 @@ void FastRouteCore::convertToMazeroute()
}

// non recursive version of heapify
static void heapify(std::vector<float*>& array)
static void heapify(std::vector<double*>& array)
{
bool stop = false;
const int heapSize = array.size();
int i = 0;

float* tmp = array[i];
double* tmp = array[i];
do {
const int l = left_index(i);
const int r = right_index(i);
Expand All @@ -551,9 +551,9 @@ static void heapify(std::vector<float*>& array)
} while (!stop);
}

static void updateHeap(std::vector<float*>& array, int i)
static void updateHeap(std::vector<double*>& array, int i)
{
float* tmpi = array[i];
double* tmpi = array[i];
while (i > 0 && *(array[parent_index(i)]) > *tmpi) {
const int parent = parent_index(i);
array[i] = array[parent];
Expand All @@ -563,7 +563,7 @@ static void updateHeap(std::vector<float*>& array, int i)
}

// remove the entry with minimum distance from Priority queue
static void removeMin(std::vector<float*>& array)
static void removeMin(std::vector<double*>& array)
{
array[0] = array.back();
heapify(array);
Expand Down Expand Up @@ -730,10 +730,10 @@ void FastRouteCore::updateCongestionHistory(const int upType,
// dest_heap - the heap storing the addresses for d2
void FastRouteCore::setupHeap(const int netID,
const int edgeID,
std::vector<float*>& src_heap,
std::vector<float*>& dest_heap,
multi_array<float, 2>& d1,
multi_array<float, 2>& d2,
std::vector<double*>& src_heap,
std::vector<double*>& dest_heap,
multi_array<double, 2>& d1,
multi_array<double, 2>& d2,
const int regionX1,
const int regionX2,
const int regionY1,
Expand Down Expand Up @@ -1346,13 +1346,13 @@ void FastRouteCore::mazeRouteMSMD(const int iter,
StNetOrder();
}

std::vector<float*> src_heap;
std::vector<float*> dest_heap;
std::vector<double*> src_heap;
std::vector<double*> dest_heap;
src_heap.reserve(y_grid_ * x_grid_);
dest_heap.reserve(y_grid_ * x_grid_);

multi_array<float, 2> d1(boost::extents[y_range_][x_range_]);
multi_array<float, 2> d2(boost::extents[y_range_][x_range_]);
multi_array<double, 2> d1(boost::extents[y_range_][x_range_]);
multi_array<double, 2> d2(boost::extents[y_range_][x_range_]);

std::vector<bool> pop_heap2(y_grid_ * x_range_, false);

Expand Down Expand Up @@ -1527,7 +1527,7 @@ void FastRouteCore::mazeRouteMSMD(const int iter,
parent_x3_[curY][tmpX] = curX;
parent_y3_[curY][tmpX] = curY;
hv_[curY][tmpX] = false;
float* dtmp = &d1[curY][tmpX];
double* dtmp = &d1[curY][tmpX];
int ind = 0;
while (src_heap[ind] != dtmp)
ind++;
Expand All @@ -1536,7 +1536,7 @@ void FastRouteCore::mazeRouteMSMD(const int iter,
}
// right
if (curX < regionX2) {
float tmp, cost1, cost2;
double tmp, cost1, cost2;
const int pos1 = h_edges_[curY][curX].usage_red()
+ L * h_edges_[curY][curX].last_usage;

Expand Down Expand Up @@ -1588,7 +1588,7 @@ void FastRouteCore::mazeRouteMSMD(const int iter,
parent_x3_[curY][tmpX] = curX;
parent_y3_[curY][tmpX] = curY;
hv_[curY][tmpX] = false;
float* dtmp = &d1[curY][tmpX];
double* dtmp = &d1[curY][tmpX];
int ind = 0;
while (src_heap[ind] != dtmp)
ind++;
Expand All @@ -1597,7 +1597,7 @@ void FastRouteCore::mazeRouteMSMD(const int iter,
}
// bottom
if (curY > regionY1) {
float tmp, cost1, cost2;
double tmp, cost1, cost2;
const int pos1 = v_edges_[curY - 1][curX].usage_red()
+ L * v_edges_[curY - 1][curX].last_usage;

Expand Down Expand Up @@ -1648,7 +1648,7 @@ void FastRouteCore::mazeRouteMSMD(const int iter,
parent_x1_[tmpY][curX] = curX;
parent_y1_[tmpY][curX] = curY;
hv_[tmpY][curX] = true;
float* dtmp = &d1[tmpY][curX];
double* dtmp = &d1[tmpY][curX];
int ind = 0;
while (src_heap[ind] != dtmp)
ind++;
Expand All @@ -1657,7 +1657,7 @@ void FastRouteCore::mazeRouteMSMD(const int iter,
}
// top
if (curY < regionY2) {
float tmp, cost1, cost2;
double tmp, cost1, cost2;
const int pos1 = v_edges_[curY][curX].usage_red()
+ L * v_edges_[curY][curX].last_usage;

Expand Down Expand Up @@ -1709,7 +1709,7 @@ void FastRouteCore::mazeRouteMSMD(const int iter,
parent_x1_[tmpY][curX] = curX;
parent_y1_[tmpY][curX] = curY;
hv_[tmpY][curX] = true;
float* dtmp = &d1[tmpY][curX];
double* dtmp = &d1[tmpY][curX];
int ind = 0;
while (src_heap[ind] != dtmp)
ind++;
Expand Down
Loading

0 comments on commit 665743f

Please sign in to comment.