Skip to content

Commit 2280445

Browse files
committed
[vpr] categorize files to rr_graph_type & rr_graph_cost in librrgraph
1 parent 9682216 commit 2280445

27 files changed

+120
-148
lines changed

libs/libarchfpga/src/base_cost_type.h

Lines changed: 0 additions & 14 deletions
This file was deleted.

libs/libarchfpga/src/chan_width.h

Lines changed: 0 additions & 16 deletions
This file was deleted.

libs/libarchfpga/src/cost_indices.h

Lines changed: 0 additions & 13 deletions
This file was deleted.

libs/libarchfpga/src/route_type.h

Lines changed: 0 additions & 9 deletions
This file was deleted.

libs/libarchfpga/src/unified_to_parallel_seg_index.h

Lines changed: 0 additions & 11 deletions
This file was deleted.

libs/librrgraph/src/base/check_rr_graph.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
#ifndef CHECK_RR_GRAPH_H
22
#define CHECK_RR_GRAPH_H
33

4-
#include "physical_types.h"
5-
#include "rr_graph_type.h"
64
#include "device_grid.h"
7-
#include "route_type.h"
85
#include "rr_graph_view.h"
9-
#include "chan_width.h"
10-
6+
#include "rr_graph_type.h"
117

128
void check_rr_graph(const RRGraphView& rr_graph,
139
const std::vector<t_physical_tile_type>& types,

libs/librrgraph/src/base/get_parallel_segs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef GET_PARALLEL_SEGS_H
22
#define GET_PARALLEL_SEGS_H
33

4-
#include "unified_to_parallel_seg_index.h"
4+
#include "rr_graph_type.h"
55
#include "physical_types.h"
66

77
std::vector<t_segment_inf> get_parallel_segs(const std::vector<t_segment_inf>& segment_inf,
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#ifndef RR_GRAPH_COST_H
2+
#define RR_GRAPH_COST_H
3+
4+
enum e_base_cost_type {
5+
DELAY_NORMALIZED,
6+
DELAY_NORMALIZED_LENGTH,
7+
DELAY_NORMALIZED_FREQUENCY,
8+
DELAY_NORMALIZED_LENGTH_FREQUENCY,
9+
DELAY_NORMALIZED_LENGTH_BOUNDED,
10+
DEMAND_ONLY,
11+
DEMAND_ONLY_NORMALIZED_LENGTH
12+
};
13+
14+
///@brief Index of the SOURCE, SINK, OPIN, IPIN, etc. member of device_ctx.rr_indexed_data.
15+
enum e_cost_indices {
16+
SOURCE_COST_INDEX = 0,
17+
SINK_COST_INDEX,
18+
OPIN_COST_INDEX,
19+
IPIN_COST_INDEX,
20+
CHANX_COST_INDEX_START
21+
};
22+
23+
#endif

libs/librrgraph/src/base/rr_graph_storage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "vtr_vector.h"
88
#include "physical_types.h"
9+
#include "rr_graph_storage_utils.h"
910
#include "rr_node_types.h"
1011
#include "rr_graph_fwd.h"
1112
#include "rr_node_fwd.h"
@@ -14,7 +15,6 @@
1415
#include "vtr_memory.h"
1516
#include "vtr_strong_id_range.h"
1617
#include "vtr_array_view.h"
17-
#include "rr_graph_utils.h"
1818

1919
/* Main structure describing one routing resource node. Everything in *
2020
* this structure should describe the graph -- information needed only *
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#ifndef RR_GRAPH_STORAGE_UTILS_H
2+
#define RR_GRAPH_STORAGE_UTILS_H
3+
4+
// Make room in a vector, with amortized O(1) time by using a pow2 growth pattern.
5+
//
6+
// This enables potentially random insertion into a vector with amortized O(1)
7+
// time.
8+
9+
template<typename T>
10+
void make_room_in_vector(T* vec, size_t elem_position) {
11+
if (elem_position < vec->size()) {
12+
return;
13+
}
14+
15+
size_t capacity = std::max(vec->capacity(), size_t(16));
16+
while (elem_position >= capacity) {
17+
capacity *= 2;
18+
}
19+
20+
if (capacity >= vec->capacity()) {
21+
vec->reserve(capacity);
22+
}
23+
24+
vec->resize(elem_position + 1);
25+
}
26+
27+
#endif

libs/librrgraph/src/base/rr_graph_type.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
#ifndef GRAPH_TYPE_H
22
#define GRAPH_TYPE_H
33

4+
#include <vector>
5+
#include "physical_types.h"
6+
7+
struct t_chan_width {
8+
int max = 0;
9+
int x_max = 0;
10+
int y_max = 0;
11+
int x_min = 0;
12+
int y_min = 0;
13+
std::vector<int> x_list;
14+
std::vector<int> y_list;
15+
};
16+
17+
enum e_route_type {
18+
GLOBAL,
19+
DETAILED
20+
};
21+
422
enum e_graph_type {
523
GRAPH_GLOBAL, /* One node per channel with wire capacity > 1 and full connectivity */
624
GRAPH_BIDIR, /* Detailed bidirectional graph */
@@ -10,4 +28,9 @@ enum e_graph_type {
1028
};
1129
typedef enum e_graph_type t_graph_type;
1230

31+
/* This map is used to get indices w.r.t segment_inf_x or segment_inf_y based on parallel_axis of a segment,
32+
* from indices w.r.t the **unified** segment vector, segment_inf in devices context which stores all segments
33+
* regardless of their axis. (see get_parallel_segs for more details)*/
34+
typedef std::unordered_multimap<size_t, std::pair<size_t, e_parallel_axis>> t_unified_to_parallel_seg_index;
35+
1336
#endif

libs/librrgraph/src/base/rr_graph_util.h

Lines changed: 0 additions & 24 deletions
This file was deleted.

libs/librrgraph/src/base/rr_graph_util.cpp renamed to libs/librrgraph/src/base/rr_graph_utils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
/****************************************************************************
23
* This file include most-utilized functions that manipulate on the
34
* RRGraph object
@@ -6,7 +7,7 @@
67
#include <random>
78
#include <algorithm>
89

9-
#include "rr_graph_util.h"
10+
#include "rr_graph_utils.h"
1011

1112
#include "vtr_memory.h"
1213
#include "vtr_time.h"
@@ -118,5 +119,4 @@ vtr::vector<RRNodeId, std::vector<RREdgeId>> get_fan_in_list(const RRGraphView&
118119
});
119120

120121
return node_fan_in_list;
121-
}
122-
122+
}
Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
#ifndef RR_GRAPH_UTILS_H
22
#define RR_GRAPH_UTILS_H
33

4-
// Make room in a vector, with amortized O(1) time by using a pow2 growth pattern.
5-
//
6-
// This enables potentially random insertion into a vector with amortized O(1)
7-
// time.
8-
template<typename T>
9-
void make_room_in_vector(T* vec, size_t elem_position) {
10-
if (elem_position < vec->size()) {
11-
return;
12-
}
4+
/* Include header files which include data structures used by
5+
* the function declaration
6+
*/
7+
#include <vector>
8+
#include "rr_graph_fwd.h"
9+
#include "rr_node_types.h"
10+
#include "rr_graph_view.h"
1311

14-
size_t capacity = std::max(vec->capacity(), size_t(16));
15-
while (elem_position >= capacity) {
16-
capacity *= 2;
17-
}
12+
/* Get node-to-node switches in a RRGraph */
13+
std::vector<RRSwitchId> find_rr_graph_switches(const RRGraph& rr_graph,
14+
const RRNodeId& from_node,
15+
const RRNodeId& to_node);
1816

19-
if (capacity >= vec->capacity()) {
20-
vec->reserve(capacity);
21-
}
17+
// This function generates and returns a vector indexed by RRNodeId
18+
// containing a list of fan-in edges for each node.
19+
vtr::vector<RRNodeId, std::vector<RREdgeId>> get_fan_in_list(const RRGraphView& rr_graph);
2220

23-
vec->resize(elem_position + 1);
24-
}
21+
int seg_index_of_cblock(const RRGraphView& rr_graph, t_rr_type from_rr_type, int to_node);
22+
int seg_index_of_sblock(const RRGraphView& rr_graph, int from_node, int to_node);
2523

26-
#endif
24+
#endif

libs/librrgraph/src/io/rr_graph_reader.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
#define RR_GRAPH_READER_H
55

66
#include "rr_graph_type.h"
7-
#include "device_grid.h"
8-
#include "physical_types.h"
9-
#include "base_cost_type.h"
10-
#include "chan_width.h"
11-
#include "rr_node.h"
7+
#include "rr_graph_cost.h"
128
#include "rr_graph_builder.h"
139
#include "rr_graph_view.h"
1410
#include "rr_graph_fwd.h"
11+
#include "rr_node.h"
12+
#include "device_grid.h"
13+
#include "physical_types.h"
1514

1615

1716
void load_rr_file(RRGraphBuilder* rr_graph_builder,

libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,17 @@
77
#include "rr_graph_uxsdcxx_interface.h"
88

99
#include "rr_node.h"
10-
#include "rr_rc_data.h"
11-
#include "rr_metadata.h"
10+
#include "rr_graph_type.h"
11+
#include "rr_graph_cost.h"
1212
#include "rr_graph_view.h"
1313
#include "rr_graph_builder.h"
14+
#include "rr_rc_data.h"
15+
#include "rr_metadata.h"
1416

1517
#include "check_rr_graph.h"
1618
#include "read_xml_arch_file.h"
1719

1820
#include "device_grid.h"
19-
#include "chan_width.h"
20-
#include "base_cost_type.h"
21-
#include "unified_to_parallel_seg_index.h"
22-
#include "rr_graph_type.h"
23-
#include "cost_indices.h"
2421
#include "alloc_and_load_rr_indexed_data.h"
2522
#include "get_parallel_segs.h"
2623

libs/librrgraph/src/io/rr_graph_writer.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
#ifndef RR_GRAPH_WRITER_H
77
#define RR_GRAPH_WRITER_H
88

9-
#include "physical_types.h"
10-
#include "chan_width.h"
119
#include "rr_node.h"
10+
#include "rr_graph_type.h"
1211
#include "rr_graph_builder.h"
1312
#include "rr_graph_view.h"
1413
#include "rr_graph_fwd.h"
15-
#include "chan_width.h"
1614
#include "device_grid.h"
15+
#include "physical_types.h"
1716

1817
void write_rr_graph(RRGraphBuilder* rr_graph_builder,
1918
RRGraphView* rr_graph,

libs/librrgraph/src/utils/alloc_and_load_rr_indexed_data.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
#include "vpr_error.h"
1515

16-
#include "rr_graph_util.h"
16+
#include "rr_graph_utils.h"
1717
#include "read_xml_arch_file.h"
1818

19-
#include "base_cost_type.h"
20-
#include "cost_indices.h"
19+
#include "rr_graph_cost.h"
20+
#include "rr_graph_type.h"
2121

2222
#include "histogram.h"
2323

libs/librrgraph/src/utils/alloc_and_load_rr_indexed_data.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "rr_graph_view.h"
55
#include "rr_node.h"
6-
#include "base_cost_type.h"
6+
#include "rr_graph_cost.h"
77
#include "device_grid.h"
88

99
void alloc_and_load_rr_indexed_data(const RRGraphView& rr_graph,

0 commit comments

Comments
 (0)