|
15 | 15 | #include <string>
|
16 | 16 | #include <tuple>
|
17 | 17 | #include <vector>
|
| 18 | +#include "atom_lookup.h" |
18 | 19 | #include "cluster_placement.h"
|
19 | 20 | #include "cluster_router.h"
|
20 | 21 | #include "globals.h"
|
@@ -971,6 +972,39 @@ static void revert_place_atom_block(const AtomBlockId blk_id,
|
971 | 972 | atom_ctx.lookup.set_atom_pb(blk_id, nullptr);
|
972 | 973 | }
|
973 | 974 |
|
| 975 | +/* Speculation successful, commit input/output pins used */ |
| 976 | +static void commit_lookahead_pins_used(t_pb* cur_pb) { |
| 977 | + const t_pb_type* pb_type = cur_pb->pb_graph_node->pb_type; |
| 978 | + |
| 979 | + if (pb_type->num_modes > 0 && cur_pb->name) { |
| 980 | + for (int i = 0; i < cur_pb->pb_graph_node->num_input_pin_class; i++) { |
| 981 | + VTR_ASSERT(cur_pb->pb_stats->lookahead_input_pins_used[i].size() <= (unsigned int)cur_pb->pb_graph_node->input_pin_class_size[i]); |
| 982 | + for (size_t j = 0; j < cur_pb->pb_stats->lookahead_input_pins_used[i].size(); j++) { |
| 983 | + VTR_ASSERT(cur_pb->pb_stats->lookahead_input_pins_used[i][j]); |
| 984 | + cur_pb->pb_stats->input_pins_used[i].insert({j, cur_pb->pb_stats->lookahead_input_pins_used[i][j]}); |
| 985 | + } |
| 986 | + } |
| 987 | + |
| 988 | + for (int i = 0; i < cur_pb->pb_graph_node->num_output_pin_class; i++) { |
| 989 | + VTR_ASSERT(cur_pb->pb_stats->lookahead_output_pins_used[i].size() <= (unsigned int)cur_pb->pb_graph_node->output_pin_class_size[i]); |
| 990 | + for (size_t j = 0; j < cur_pb->pb_stats->lookahead_output_pins_used[i].size(); j++) { |
| 991 | + VTR_ASSERT(cur_pb->pb_stats->lookahead_output_pins_used[i][j]); |
| 992 | + cur_pb->pb_stats->output_pins_used[i].insert({j, cur_pb->pb_stats->lookahead_output_pins_used[i][j]}); |
| 993 | + } |
| 994 | + } |
| 995 | + |
| 996 | + if (cur_pb->child_pbs) { |
| 997 | + for (int i = 0; i < pb_type->modes[cur_pb->mode].num_pb_type_children; i++) { |
| 998 | + if (cur_pb->child_pbs[i]) { |
| 999 | + for (int j = 0; j < pb_type->modes[cur_pb->mode].pb_type_children[i].num_pb; j++) { |
| 1000 | + commit_lookahead_pins_used(&cur_pb->child_pbs[i][j]); |
| 1001 | + } |
| 1002 | + } |
| 1003 | + } |
| 1004 | + } |
| 1005 | + } |
| 1006 | +} |
| 1007 | + |
974 | 1008 | /**
|
975 | 1009 | * Cleans up a pb after unsuccessful molecule packing
|
976 | 1010 | *
|
@@ -1272,14 +1306,23 @@ e_block_pack_status ClusterLegalizer::try_pack_molecule(t_pack_molecule* molecul
|
1272 | 1306 | cluster.molecules.insert(molecule);
|
1273 | 1307 |
|
1274 | 1308 | for (int i = 0; i < molecule_size; i++) {
|
1275 |
| - if (molecule->atom_block_ids[i]) { |
1276 |
| - /* invalidate all molecules that share atom block with current molecule */ |
1277 |
| - t_pack_molecule* cur_molecule = atom_ctx.prepacker.get_atom_molecule(molecule->atom_block_ids[i]); |
1278 |
| - cur_molecule->valid = false; |
1279 |
| - |
1280 |
| - commit_primitive(cluster_placement_stats_ptr, primitives_list[i]); |
1281 |
| - } |
| 1309 | + AtomBlockId atom_blk_id = molecule->atom_block_ids[i]; |
| 1310 | + if (!atom_blk_id.is_valid()) |
| 1311 | + continue; |
| 1312 | + |
| 1313 | + /* invalidate all molecules that share atom block with current molecule */ |
| 1314 | + t_pack_molecule* cur_molecule = atom_ctx.prepacker.get_atom_molecule(atom_blk_id); |
| 1315 | + // TODO: This should really be named better. Something like |
| 1316 | + // "is_clustered". and then it should be set to true. |
| 1317 | + // Right now, valid implies "not clustered" which is |
| 1318 | + // confusing. |
| 1319 | + cur_molecule->valid = false; |
| 1320 | + |
| 1321 | + commit_primitive(cluster_placement_stats_ptr, primitives_list[i]); |
1282 | 1322 | }
|
| 1323 | + |
| 1324 | + // Update the lookahead pins used. |
| 1325 | + commit_lookahead_pins_used(cluster.pb); |
1283 | 1326 | }
|
1284 | 1327 | }
|
1285 | 1328 |
|
@@ -1521,6 +1564,8 @@ void ClusterLegalizer::reset() {
|
1521 | 1564 | // Reset the molecule_cluster map
|
1522 | 1565 | molecule_cluster.clear();
|
1523 | 1566 | // Free and reset the legalization_clusters
|
| 1567 | + // FIXME: It would make sense if this were to call the destroy method |
| 1568 | + // somehow. |
1524 | 1569 | for (LegalizationCluster& cluster : legalization_clusters) {
|
1525 | 1570 | // FIXME: Handle destroyed clusters better.
|
1526 | 1571 | if (cluster.pb == nullptr)
|
|
0 commit comments