Skip to content

Commit 2a44206

Browse files
committed
Ensure classic timing graph levels are stored in timing_ctx
Fixes segfault in classic critical path writer when ENABLE_CLASSIC_VPR_STA is enabled.
1 parent c59356e commit 2a44206

File tree

2 files changed

+11
-23
lines changed

2 files changed

+11
-23
lines changed

vpr/SRC/base/vpr_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ struct t_cluster_placement_stats {
295295

296296
//Enable the legacy STA engine to run along side the
297297
//new STA engine
298-
#define ENABLE_CLASSIC_VPR_STA
298+
//#define ENABLE_CLASSIC_VPR_STA
299299

300300
// #define PATH_COUNTING 'P'
301301
/* Uncomment this to turn on path counting. Its value determines how path criticality

vpr/SRC/timing/path_delay2.cpp

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,6 @@
1818
#include "read_xml_arch_file.h"
1919

2020
#include "path_delay.h"
21-
/************* Variables (globals) shared by all path_delay modules **********/
22-
23-
int num_tnode_levels; /* Number of levels in the timing graph. */
24-
25-
vtr::t_ivec *tnodes_at_level;
26-
/* [0..num__tnode_levels - 1]. Count and list of tnodes at each level of
27-
* the timing graph, to make topological searches easier. Level-0 nodes are
28-
* sources to the timing graph (types TN_FF_SOURCE, TN_INPAD_SOURCE
29-
* and TN_CONSTANT_GEN_SOURCE). Level-N nodes are in the immediate fanout of
30-
* nodes with level at most N-1. */
31-
3221
/******************* Subroutines local to this module ************************/
3322

3423
static int *alloc_and_load_tnode_fanin_and_check_edges(int *num_sinks_ptr);
@@ -122,7 +111,7 @@ int alloc_and_load_timing_graph_levels(void) {
122111
i;
123112
t_tedge *tedge;
124113

125-
auto& timing_ctx = g_vpr_ctx.timing();
114+
auto& timing_ctx = g_vpr_ctx.mutable_timing();
126115

127116
/* [0..timing_ctx.num_tnodes-1]. # of in-edges to each tnode that have not yet been *
128117
* seen in this traversal. */
@@ -137,7 +126,7 @@ int alloc_and_load_timing_graph_levels(void) {
137126
* Temporarily need one extra level on the end because I look at the first *
138127
* empty level. */
139128

140-
tnodes_at_level = (vtr::t_ivec *) vtr::malloc(
129+
timing_ctx.tnodes_at_level = (vtr::t_ivec *) vtr::malloc(
141130
(timing_ctx.num_tnodes + 1) * sizeof(vtr::t_ivec));
142131

143132
/* Scan through the timing graph, putting all the primary input nodes (no *
@@ -154,16 +143,16 @@ int alloc_and_load_timing_graph_levels(void) {
154143
}
155144

156145
alloc_ivector_and_copy_int_list(&nodes_at_level_head, num_at_level,
157-
&tnodes_at_level[0], &free_list_head);
146+
&timing_ctx.tnodes_at_level[0], &free_list_head);
158147

159148
num_levels = 0;
160149

161150
while (num_at_level != 0) { /* Until there's nothing in the queue. */
162151
num_levels++;
163152
num_at_level = 0;
164153

165-
for (i = 0; i < tnodes_at_level[num_levels - 1].nelem; i++) {
166-
inode = tnodes_at_level[num_levels - 1].list[i];
154+
for (i = 0; i < timing_ctx.tnodes_at_level[num_levels - 1].nelem; i++) {
155+
inode = timing_ctx.tnodes_at_level[num_levels - 1].list[i];
167156
tedge = timing_ctx.tnodes[inode].out_edges;
168157
num_edges = timing_ctx.tnodes[inode].num_edges;
169158

@@ -182,12 +171,11 @@ int alloc_and_load_timing_graph_levels(void) {
182171
}
183172

184173
alloc_ivector_and_copy_int_list(&nodes_at_level_head, num_at_level,
185-
&tnodes_at_level[num_levels], &free_list_head);
174+
&timing_ctx.tnodes_at_level[num_levels], &free_list_head);
186175
}
187176

188-
tnodes_at_level = (vtr::t_ivec *) vtr::realloc(tnodes_at_level,
189-
num_levels * sizeof(vtr::t_ivec));
190-
num_tnode_levels = num_levels;
177+
timing_ctx.tnodes_at_level = (vtr::t_ivec *) vtr::realloc(timing_ctx.tnodes_at_level, num_levels * sizeof(vtr::t_ivec));
178+
timing_ctx.num_tnode_levels = num_levels;
191179

192180
free(tnode_fanin_left);
193181
free_int_list(&free_list_head);
@@ -213,8 +201,8 @@ void check_timing_graph() {
213201

214202
/* TODO: Rework error checks for I/Os*/
215203

216-
for (ilevel = 0; ilevel < num_tnode_levels; ilevel++)
217-
num_tnodes_check += tnodes_at_level[ilevel].nelem;
204+
for (ilevel = 0; ilevel < timing_ctx.num_tnode_levels; ilevel++)
205+
num_tnodes_check += timing_ctx.tnodes_at_level[ilevel].nelem;
218206

219207
if (num_tnodes_check != timing_ctx.num_tnodes) {
220208
vtr::printf_error(__FILE__, __LINE__,

0 commit comments

Comments
 (0)