Skip to content
108 changes: 55 additions & 53 deletions libs/libvtrutil/src/vtr_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ namespace vtr {
//
//If you need more std::map-like (instead of std::vector-like) behaviour see
//vtr::vector_map.
template<typename K, typename V>
class vector : private std::vector<V> {
template<typename K, typename V, typename Allocator = std::allocator<V>>
class vector : private std::vector<V, Allocator> {
using storage = std::vector<V, Allocator>;

public:
typedef K key_type;

Expand All @@ -25,71 +27,71 @@ class vector : private std::vector<V> {

public:
//Pass through std::vector's types
using typename std::vector<V>::value_type;
using typename std::vector<V>::allocator_type;
using typename std::vector<V>::reference;
using typename std::vector<V>::const_reference;
using typename std::vector<V>::pointer;
using typename std::vector<V>::const_pointer;
using typename std::vector<V>::iterator;
using typename std::vector<V>::const_iterator;
using typename std::vector<V>::reverse_iterator;
using typename std::vector<V>::const_reverse_iterator;
using typename std::vector<V>::difference_type;
using typename std::vector<V>::size_type;

//Pass through std::vector's methods
using std::vector<V>::vector;

using std::vector<V>::begin;
using std::vector<V>::end;
using std::vector<V>::rbegin;
using std::vector<V>::rend;
using std::vector<V>::cbegin;
using std::vector<V>::cend;
using std::vector<V>::crbegin;
using std::vector<V>::crend;

using std::vector<V>::size;
using std::vector<V>::max_size;
using std::vector<V>::resize;
using std::vector<V>::capacity;
using std::vector<V>::empty;
using std::vector<V>::reserve;
using std::vector<V>::shrink_to_fit;

using std::vector<V>::front;
using std::vector<V>::back;
using std::vector<V>::data;

using std::vector<V>::assign;
using std::vector<V>::push_back;
using std::vector<V>::pop_back;
using std::vector<V>::insert;
using std::vector<V>::erase;
using std::vector<V>::swap;
using std::vector<V>::clear;
using std::vector<V>::emplace;
using std::vector<V>::emplace_back;
using std::vector<V>::get_allocator;
using typename storage::allocator_type;
using typename storage::const_iterator;
using typename storage::const_pointer;
using typename storage::const_reference;
using typename storage::const_reverse_iterator;
using typename storage::difference_type;
using typename storage::iterator;
using typename storage::pointer;
using typename storage::reference;
using typename storage::reverse_iterator;
using typename storage::size_type;
using typename storage::value_type;

//Pass through storagemethods
using std::vector<V, Allocator>::vector;

using storage::begin;
using storage::cbegin;
using storage::cend;
using storage::crbegin;
using storage::crend;
using storage::end;
using storage::rbegin;
using storage::rend;

using storage::capacity;
using storage::empty;
using storage::max_size;
using storage::reserve;
using storage::resize;
using storage::shrink_to_fit;
using storage::size;

using storage::back;
using storage::data;
using storage::front;

using storage::assign;
using storage::clear;
using storage::emplace;
using storage::emplace_back;
using storage::erase;
using storage::get_allocator;
using storage::insert;
using storage::pop_back;
using storage::push_back;
using storage::swap;

//Don't include operator[] and at() from std::vector,
//since we redine them to take key_type instead of size_t
reference operator[](const key_type id) {
auto i = size_t(id);
return std::vector<V>::operator[](i);
return storage::operator[](i);
}
const_reference operator[](const key_type id) const {
auto i = size_t(id);
return std::vector<V>::operator[](i);
return storage::operator[](i);
}
reference at(const key_type id) {
auto i = size_t(id);
return std::vector<V>::at(i);
return storage::at(i);
}
const_reference at(const key_type id) const {
auto i = size_t(id);
return std::vector<V>::at(i);
return storage::at(i);
}

//Returns a range containing the keys
Expand Down
2 changes: 1 addition & 1 deletion vpr/src/base/read_route.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ static void process_nodes(std::ifstream& fp, ClusterNetId inet, const char* file
} else if (tokens[0] == "Node:") {
/*An actual line, go through each node and add it to the route tree*/
inode = atoi(tokens[1].c_str());
auto& node = device_ctx.rr_nodes[inode];
auto node = device_ctx.rr_nodes[inode];

/*First node needs to be source. It is isolated to correctly set heap head.*/
if (node_count == 0 && tokens[2] != "SOURCE") {
Expand Down
3 changes: 2 additions & 1 deletion vpr/src/base/vpr_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "vtr_vector.h"
#include "atom_netlist.h"
#include "clustered_netlist.h"
#include "rr_graph_storage.h"
#include "rr_node.h"
#include "tatum/TimingGraph.hpp"
#include "tatum/TimingConstraints.hpp"
Expand Down Expand Up @@ -145,7 +146,7 @@ struct DeviceContext : public Context {
t_chan_width chan_width;

/* Structures to define the routing architecture of the FPGA. */
std::vector<t_rr_node> rr_nodes; /* autogenerated in build_rr_graph */
t_rr_graph_storage rr_nodes; /* autogenerated in build_rr_graph */

std::vector<t_rr_indexed_data> rr_indexed_data; /* [0 .. num_rr_indexed_data-1] */

Expand Down
2 changes: 2 additions & 0 deletions vpr/src/base/vpr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1318,4 +1318,6 @@ class RouteStatus {

typedef vtr::vector<ClusterBlockId, std::vector<std::vector<int>>> t_clb_opins_used; //[0..num_blocks-1][0..class-1][0..used_pins-1]

typedef std::vector<std::map<int, int>> t_arch_switch_fanin;

#endif
14 changes: 7 additions & 7 deletions vpr/src/draw/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2051,24 +2051,24 @@ static void draw_rr_pin(int inode, const ezgl::color& color, ezgl::renderer* g)
* the physical pin is on. */
void draw_get_rr_pin_coords(int inode, float* xcen, float* ycen) {
auto& device_ctx = g_vpr_ctx.device();
draw_get_rr_pin_coords(&device_ctx.rr_nodes[inode], xcen, ycen);
draw_get_rr_pin_coords(device_ctx.rr_nodes[inode], xcen, ycen);
}

void draw_get_rr_pin_coords(const t_rr_node* node, float* xcen, float* ycen) {
void draw_get_rr_pin_coords(const t_rr_node node, float* xcen, float* ycen) {
t_draw_coords* draw_coords = get_draw_coords_vars();

int i, j, k, ipin, pins_per_sub_tile;
float offset, xc, yc, step;
t_physical_tile_type_ptr type;
auto& device_ctx = g_vpr_ctx.device();

i = node->xlow();
j = node->ylow();
i = node.xlow();
j = node.ylow();

xc = draw_coords->tile_x[i];
yc = draw_coords->tile_y[j];

ipin = node->ptc_num();
ipin = node.ptc_num();
type = device_ctx.grid[i][j].type;
pins_per_sub_tile = type->num_pins / type->capacity;
k = ipin / pins_per_sub_tile;
Expand All @@ -2080,7 +2080,7 @@ void draw_get_rr_pin_coords(const t_rr_node* node, float* xcen, float* ycen) {
step = (float)(draw_coords->get_tile_width()) / (float)(type->num_pins + type->capacity);
offset = (ipin + k + 1) * step;

switch (node->side()) {
switch (node.side()) {
case LEFT:
yc += offset;
break;
Expand All @@ -2101,7 +2101,7 @@ void draw_get_rr_pin_coords(const t_rr_node* node, float* xcen, float* ycen) {

default:
vpr_throw(VPR_ERROR_OTHER, __FILE__, __LINE__,
"in draw_get_rr_pin_coords: Unexpected side %s.\n", node->side_string());
"in draw_get_rr_pin_coords: Unexpected side %s.\n", node.side_string());
break;
}

Expand Down
2 changes: 1 addition & 1 deletion vpr/src/draw/draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void free_draw_structs();
#ifndef NO_GRAPHICS

void draw_get_rr_pin_coords(int inode, float* xcen, float* ycen);
void draw_get_rr_pin_coords(const t_rr_node* node, float* xcen, float* ycen);
void draw_get_rr_pin_coords(const t_rr_node node, float* xcen, float* ycen);

void draw_triangle_along_line(ezgl::renderer* g, ezgl::point2d start, ezgl::point2d end, float relative_position = 1., float arrow_size = DEFAULT_ARROW_SIZE);
void draw_triangle_along_line(ezgl::renderer* g, ezgl::point2d loc, ezgl::point2d start, ezgl::point2d end, float arrow_size = DEFAULT_ARROW_SIZE);
Expand Down
Loading