12
12
13
13
#include < algorithm>
14
14
#include < map>
15
- #include < unordered_map>
16
15
#include " vpr_types.h"
17
16
#include " vtr_assert.h"
18
- #include " vtr_range .h"
17
+ #include " vtr_vector .h"
19
18
20
19
class AtomNetlist ;
21
20
class AtomBlockId ;
@@ -28,7 +27,7 @@ struct t_logical_block_type;
28
27
* This class maintains the prepacking state, allowing the use of molecules
29
28
* (prepacked atoms) while this object exists. After prepacking, every atom will
30
29
* be part of a molecule (with a large number being part of single-atom
31
- * molecules.
30
+ * molecules) .
32
31
*
33
32
* Molecules currently come from pack patterns in the architecture file. For
34
33
* example, a 3-bit carry chain in most architectures would turn into a molecule
@@ -72,18 +71,16 @@ class Prepacker {
72
71
void init (const AtomNetlist& atom_nlist, const std::vector<t_logical_block_type> &logical_block_types);
73
72
74
73
/* *
75
- * @brief Get the cluster molecules containing the given atom block.
74
+ * @brief Get the cluster molecule containing the given atom block.
76
75
*
77
- * @param blk_id The atom block to get the molecules of.
76
+ * @param blk_id The atom block to get the molecule of.
78
77
*/
79
78
inline t_pack_molecule* get_atom_molecule (AtomBlockId blk_id) const {
80
- // Internally the prepacker maintains multiple molecules per atom, since
81
- // some atoms may be part of multiple pack patterns; however, the
82
- // prepacker should merge these eventually into one single molecule.
83
- // TODO: If this can be 100% verified, this should be turned into a
84
- // debug assert.
85
- VTR_ASSERT (atom_molecules.count (blk_id) == 1 );
86
- return atom_molecules.find (blk_id)->second ;
79
+ // Safety debug to ensure the blk is valid and has a molecule entry.
80
+ VTR_ASSERT_SAFE (blk_id.is_valid () && (size_t )blk_id < atom_molecules.size ());
81
+ // Safety debug to ensure the molecule is valid
82
+ VTR_ASSERT_DEBUG (atom_molecules[blk_id] != nullptr );
83
+ return atom_molecules[blk_id];
87
84
}
88
85
89
86
/* *
@@ -93,11 +90,11 @@ class Prepacker {
93
90
* @param blk_id The atom block to get the pb graph node of.
94
91
*/
95
92
inline t_pb_graph_node* get_expected_lowest_cost_pb_gnode (AtomBlockId blk_id) const {
96
- auto iter = expected_lowest_cost_pb_gnode. find (blk_id);
97
- VTR_ASSERT (iter != expected_lowest_cost_pb_gnode.end ());
98
- t_pb_graph_node* pb_gnode = iter-> second ;
99
- VTR_ASSERT (pb_gnode != nullptr );
100
- return pb_gnode ;
93
+ // Safety debug to ensure the blk is valid and has an entry.
94
+ VTR_ASSERT_SAFE (blk_id. is_valid () && ( size_t )blk_id < expected_lowest_cost_pb_gnode.size ());
95
+ // Ensure the entry is valid.
96
+ VTR_ASSERT (expected_lowest_cost_pb_gnode[blk_id] != nullptr );
97
+ return expected_lowest_cost_pb_gnode[blk_id] ;
101
98
}
102
99
103
100
/* *
@@ -186,14 +183,13 @@ class Prepacker {
186
183
/* *
187
184
* @brief The molecules associated with each atom block.
188
185
*
189
- * This map is loaded in the prepacking stage and freed at the very end of
190
- * vpr flow run. The pointers in this multimap is shared with
191
- * list_of_pack_molecules.
186
+ * This vector is loaded in the init method and cleared in the reset method.
187
+ * The pointers in this vector are shared with list_of_pack_molecules.
192
188
*/
193
- std::multimap <AtomBlockId, t_pack_molecule*> atom_molecules;
189
+ vtr::vector <AtomBlockId, t_pack_molecule*> atom_molecules;
194
190
195
- // / @brief A map for the expected lowest cost physical block graph node.
196
- std::unordered_map <AtomBlockId, t_pb_graph_node*> expected_lowest_cost_pb_gnode;
191
+ // / @brief A vector of the expected lowest cost physical block graph node.
192
+ vtr::vector <AtomBlockId, t_pb_graph_node*> expected_lowest_cost_pb_gnode;
197
193
198
194
// / @brief A list of the pack patterns used for prepacking. I think the
199
195
// / molecules keep pointers to this vector, so this needs to remain
0 commit comments