Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inverse of the average number of tracks per channel #2741

Merged
merged 20 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4a5c1c9
add ChanPlaceCostFacContainer
soheilshahrouz Sep 22, 2024
e793e21
remove std::max calls
soheilshahrouz Sep 22, 2024
8ef4144
remove std::min calls
soheilshahrouz Sep 22, 2024
6d870c4
remove dead code
soheilshahrouz Sep 22, 2024
1106c75
move part of chanx_place_cost_fac_ initialization to the loop by chan…
soheilshahrouz Sep 22, 2024
c9af1fb
compute inverse average channel for all valid indices
soheilshahrouz Sep 22, 2024
35a7e3e
inline operator()
soheilshahrouz Sep 23, 2024
0693f1d
add comments
soheilshahrouz Sep 23, 2024
625a610
update basic golder results
soheilshahrouz Sep 23, 2024
08d152c
increase channel width for two run failures in vtr_strong amd vtr_st…
soheilshahrouz Sep 23, 2024
9148e08
Merge branch 'master' into temp_chanx_place_cost_fac
soheilshahrouz Sep 24, 2024
afe22e2
update golden results in strong and strong_odin
soheilshahrouz Sep 24, 2024
451b929
use integer indices in vtr::NdOffsetMatrix to enable using negative i…
soheilshahrouz Sep 24, 2024
099d040
replace ChanPlaceCostFacContainer with vtr::NdOffsetMatrix
soheilshahrouz Sep 24, 2024
888ac89
vtr::NdOffsetMatrix range is not inclusive
soheilshahrouz Sep 24, 2024
6f5a3aa
fix compilation warnings
soheilshahrouz Sep 24, 2024
d4e1715
Merge branch 'master' into temp_chanx_place_cost_fac
vaughnbetz Sep 26, 2024
56b989a
initialize chany_place_cost_fac_
soheilshahrouz Sep 28, 2024
b7561cc
Merge branch 'master' into temp_chanx_place_cost_fac
soheilshahrouz Oct 1, 2024
566880e
Merge branch 'master' into temp_chanx_place_cost_fac
soheilshahrouz Oct 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 32 additions & 32 deletions libs/libvtrutil/src/vtr_ndoffsetmatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,30 @@ namespace vtr {
/**
* @brief A half-open range specification for a matrix dimension [begin_index, last_index)
*
* It comes with valid indicies from [begin_index() ... end_index()-1], provided size() > 0.
* It comes with valid indices from [begin_index() ... end_index()-1], provided size() > 0.
*/
class DimRange {
public:
///@brief default constructor
DimRange() = default;

///@brief a constructor with begin_index, end_index
DimRange(size_t begin, size_t end)
DimRange(int begin, int end)
: begin_index_(begin)
, end_index_(end) {}

///@brief Return the begin index
size_t begin_index() const { return begin_index_; }
int begin_index() const { return begin_index_; }

///@brief Return the end index
size_t end_index() const { return end_index_; }
int end_index() const { return end_index_; }

///@brief Return the size
size_t size() const { return end_index_ - begin_index_; }

private:
size_t begin_index_ = 0;
size_t end_index_ = 0;
int begin_index_ = 0;
int end_index_ = 0;
};

/**
Expand Down Expand Up @@ -69,7 +69,7 @@ class NdOffsetMatrixProxy {
, start_(start) {}

///@brief const [] operator
const NdOffsetMatrixProxy<T, N - 1> operator[](size_t index) const {
const NdOffsetMatrixProxy<T, N - 1> operator[](int index) const {
VTR_ASSERT_SAFE_MSG(index >= dim_ranges_[idim_].begin_index(), "Index out of range (below dimension minimum)");
VTR_ASSERT_SAFE_MSG(index < dim_ranges_[idim_].end_index(), "Index out of range (above dimension maximum)");

Expand All @@ -79,10 +79,10 @@ class NdOffsetMatrixProxy {
* The elements are stored in zero-indexed form, so we need to adjust
* for any non-zero minimum index
*/
size_t effective_index = index - dim_ranges_[idim_].begin_index();
int effective_index = index - dim_ranges_[idim_].begin_index();

//Determine the stride of the next dimension
size_t next_dim_stride = dim_stride_ / dim_ranges_[idim_ + 1].size();
int next_dim_stride = dim_stride_ / dim_ranges_[idim_ + 1].size();

//Strip off one dimension
return NdOffsetMatrixProxy<T, N - 1>(dim_ranges_, //Pass the dimension information
Expand All @@ -92,7 +92,7 @@ class NdOffsetMatrixProxy {
}

///@brief [] operator
NdOffsetMatrixProxy<T, N - 1> operator[](size_t index) {
NdOffsetMatrixProxy<T, N - 1> operator[](int index) {
//Call the const version and cast-away constness
return const_cast<const NdOffsetMatrixProxy<T, N>*>(this)->operator[](index);
}
Expand Down Expand Up @@ -122,21 +122,21 @@ class NdOffsetMatrixProxy<T, 1> {
, start_(start) {}

///@brief const [] operator
const T& operator[](size_t index) const {
const T& operator[](int index) const {
VTR_ASSERT_SAFE_MSG(dim_stride_ == 1, "Final dimension must have stride 1");
VTR_ASSERT_SAFE_MSG(index >= dim_ranges_[idim_].begin_index(), "Index out of range (below dimension minimum)");
VTR_ASSERT_SAFE_MSG(index < dim_ranges_[idim_].end_index(), "Index out of range (above dimension maximum)");

//The elements are stored in zero-indexed form, so we need to adjust
//for any non-zero minimum index
size_t effective_index = index - dim_ranges_[idim_].begin_index();
int effective_index = index - dim_ranges_[idim_].begin_index();

//Base case
return start_[effective_index];
}

///@brief [] operator
T& operator[](size_t index) {
T& operator[](int index) {
//Call the const version and cast-away constness
return const_cast<T&>(const_cast<const NdOffsetMatrixProxy<T, 1>*>(this)->operator[](index));
}
Expand All @@ -163,7 +163,7 @@ class NdOffsetMatrixProxy<T, 1> {
* This should improve memory usage (no extra pointers to store for each dimension),
* and cache locality (less indirection via pointers, predictable strides).
*
* The indicies are calculated based on the dimensions to access the appropriate elements.
* The indices are calculated based on the dimensions to access the appropriate elements.
* Since the indexing calculations are visible to the compiler at compile time they can be
* optimized to be efficient.
*/
Expand Down Expand Up @@ -230,14 +230,14 @@ class NdOffsetMatrixBase {
}

///@brief Returns the starting index of ith dimension
size_t begin_index(size_t i) const {
int begin_index(size_t i) const {
VTR_ASSERT_SAFE(i < ndims());

return dim_ranges_[i].begin_index();
}

///@brief Returns the one-past-the-end index of the ith dimension
size_t end_index(size_t i) const {
int end_index(size_t i) const {
VTR_ASSERT_SAFE(i < ndims());

return dim_ranges_[i].end_index();
Expand Down Expand Up @@ -333,7 +333,7 @@ class NdOffsetMatrixBase {
*
* Examples:
*
* //A 2-dimensional matrix with indicies [0..4][0..9]
* //A 2-dimensional matrix with indices [0..4][0..9]
* NdOffsetMatrix<int,2> m1({5,10});
*
* //Accessing an element
Expand All @@ -342,28 +342,28 @@ class NdOffsetMatrixBase {
* //Setting an element
* m4[6][20] = 0;
*
* //A 2-dimensional matrix with indicies [2..6][5..9]
* //A 2-dimensional matrix with indices [2..6][5..9]
* // Note that C++ requires one more set of curly brace than you would expect
* NdOffsetMatrix<int,2> m2({{{2,7},{5,10}}});
*
* //A 3-dimensional matrix with indicies [0..4][0..9][0..19]
* //A 3-dimensional matrix with indices [0..4][0..9][0..19]
* NdOffsetMatrix<int,3> m3({5,10,20});
*
* //A 3-dimensional matrix with indicies [2..6][1..19][50..89]
* //A 3-dimensional matrix with indices [2..6][1..19][50..89]
* NdOffsetMatrix<int,3> m4({{{2,7}, {1,20}, {50,90}}});
*
* //A 2-dimensional matrix with indicies [2..6][1..20], with all entries
* //intialized to 42
* //A 2-dimensional matrix with indices [2..6][1..20], with all entries
* //initialized to 42
* NdOffsetMatrix<int,2> m4({{{2,7}, {1,21}}}, 42);
*
* //A 2-dimensional matrix with indicies [0..4][0..9], with all entries
* //A 2-dimensional matrix with indices [0..4][0..9], with all entries
* //initialized to 42
* NdOffsetMatrix<int,2> m1({5,10}, 42);
*
* //Filling all entries with value 101
* m1.fill(101);
*
* //Resizing an existing matrix (all values reset to default constucted value)
* //Resizing an existing matrix (all values reset to default constructed value)
* m1.resize({5,5})
*
* //Resizing an existing matrix (all elements set to value 88)
Expand All @@ -385,25 +385,25 @@ class NdOffsetMatrix : public NdOffsetMatrixBase<T, N> {
* Returns a proxy-object to allow chained array-style indexing (N >= 2 case)
* template<typename = typename std::enable_if<N >= 2>::type, typename T1=T>
*/
const NdOffsetMatrixProxy<T, N - 1> operator[](size_t index) const {
const NdOffsetMatrixProxy<T, N - 1> operator[](int index) const {
VTR_ASSERT_SAFE_MSG(this->dim_size(0) > 0, "Can not index into size zero dimension");
VTR_ASSERT_SAFE_MSG(this->dim_size(1) > 0, "Can not index into size zero dimension");
VTR_ASSERT_SAFE_MSG(index >= this->dim_ranges_[0].begin_index(), "Index out of range (below dimension minimum)");
VTR_ASSERT_SAFE_MSG(index < this->dim_ranges_[0].end_index(), "Index out of range (above dimension maximum)");

/*
* Clacluate the effective index
* Calculate the effective index
*
* The elements are stored in zero-indexed form, so adjust for any
* non-zero minimum index in this dimension
*/
size_t effective_index = index - this->dim_ranges_[0].begin_index();
int effective_index = index - this->dim_ranges_[0].begin_index();

//Calculate the stride for the current dimension
size_t dim_stride = this->size() / this->dim_size(0);
int dim_stride = this->size() / this->dim_size(0);

//Calculate the stride for the next dimension
size_t next_dim_stride = dim_stride / this->dim_size(1);
int next_dim_stride = dim_stride / this->dim_size(1);

//Peel off the first dimension
return NdOffsetMatrixProxy<T, N - 1>(this->dim_ranges_.data(), //Pass the dimension information
Expand All @@ -417,7 +417,7 @@ class NdOffsetMatrix : public NdOffsetMatrixBase<T, N> {
*
* Returns a proxy-object to allow chained array-style indexing
*/
NdOffsetMatrixProxy<T, N - 1> operator[](size_t index) {
NdOffsetMatrixProxy<T, N - 1> operator[](int index) {
//Call the const version, since returned by value don't need to worry about const
return const_cast<const NdOffsetMatrix<T, N>*>(this)->operator[](index);
}
Expand All @@ -436,7 +436,7 @@ class NdOffsetMatrix<T, 1> : public NdOffsetMatrixBase<T, 1> {

public:
///@brief Access an element (immutable)
const T& operator[](size_t index) const {
const T& operator[](int index) const {
VTR_ASSERT_SAFE_MSG(this->dim_size(0) > 0, "Can not index into size zero dimension");
VTR_ASSERT_SAFE_MSG(index >= this->dim_ranges_[0].begin_index(), "Index out of range (below dimension minimum)");
VTR_ASSERT_SAFE_MSG(index < this->dim_ranges_[0].end_index(), "Index out of range (above dimension maximum)");
Expand All @@ -445,7 +445,7 @@ class NdOffsetMatrix<T, 1> : public NdOffsetMatrixBase<T, 1> {
}

///@brief Access an element (mutable)
T& operator[](size_t index) {
T& operator[](int index) {
//Call the const version, and cast away const-ness
return const_cast<T&>(const_cast<const NdOffsetMatrix<T, 1>*>(this)->operator[](index));
}
Expand Down
12 changes: 6 additions & 6 deletions vpr/src/draw/draw_basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,8 @@ void draw_partial_route(const std::vector<RRNodeId>& rr_nodes_to_draw, ezgl::ren
static vtr::OffsetMatrix<int> chany_track; /* [0..device_ctx.grid.width() - 2][1..device_ctx.grid.height() - 2] */
if (draw_state->draw_route_type == GLOBAL) {
/* Allocate some temporary storage if it's not already available. */
size_t width = device_ctx.grid.width();
size_t height = device_ctx.grid.height();
int width = (int)device_ctx.grid.width();
int height = (int)device_ctx.grid.height();
if (chanx_track.empty()) {
chanx_track = vtr::OffsetMatrix<int>({{{1, width - 1}, {0, height - 1}}});
}
Expand All @@ -641,12 +641,12 @@ void draw_partial_route(const std::vector<RRNodeId>& rr_nodes_to_draw, ezgl::ren
chany_track = vtr::OffsetMatrix<int>({{{0, width - 1}, {1, height - 1}}});
}

for (size_t i = 1; i < width - 1; i++)
for (size_t j = 0; j < height - 1; j++)
for (int i = 1; i < width - 1; i++)
for (int j = 0; j < height - 1; j++)
chanx_track[i][j] = (-1);

for (size_t i = 0; i < width - 1; i++)
for (size_t j = 1; j < height - 1; j++)
for (int i = 0; i < width - 1; i++)
for (int j = 1; j < height - 1; j++)
chany_track[i][j] = (-1);
}

Expand Down
Loading
Loading