Skip to content

Placement Refactoring #2396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 207 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from 170 commits
Commits
Show all changes
207 commits
Select commit Hold shift + click to select a range
919b13e
Bringing back iterative improvements (1)
Nov 30, 2022
9845d06
Bringing back iterative improvements (2)
Nov 30, 2022
b15bbb9
Bringing back iterative improvement (3)
Nov 30, 2022
b804664
update the multithreading and locking techniques for iterative improv…
Nov 30, 2022
275fb41
Free cluster_pb_stats at the end of packing
Nov 30, 2022
6b237f3
Change the pointer in pb_graph_node to indeces for faster lookup and …
Dec 2, 2022
cde1d02
extend cluster_placement_stats to be a vector
Dec 2, 2022
6133c43
extending cluster_placement_stats to vector --WIP
Dec 6, 2022
424b4a6
extending cluster_placement_stats to vector --WIP2
Dec 8, 2022
21d4be7
Multitreading working -- need some refactoring to be more readable
Dec 8, 2022
3ee0bc4
Multithreading is working
Dec 8, 2022
99d2cfb
solve a variable size array issue
Dec 8, 2022
28875dd
fix formatting
Dec 8, 2022
a8cd188
Fix all issues with mulithreading
Jan 9, 2023
04fbb77
Fix formatting
Jan 9, 2023
69aa3fb
Add new moves that are evaluated based on absorbed connections not nets
Jan 10, 2023
a943734
change the definition of the Conn moves to be absorbed pins / total n…
Jan 11, 2023
3a34e5a
Fix an issue with calculating the abosorbed connections
Jan 12, 2023
a0e1f8e
Build and print a hash table for the count of connections between CLB…
Jan 16, 2023
30ad1e2
[WIP] implementing multiple moves and evaluation formulas for packing…
Jan 18, 2023
5153c54
update how moves are evaluated
Jan 20, 2023
5c8159a
fix the renaming bug to avoid having two pbs with the same name
Jan 24, 2023
8e2430d
Add a new way to evaluate moves based on the terminals outside
Jan 26, 2023
18feb40
a more generic way to fix the renaming bug
Jan 27, 2023
ff651ef
Hope it is now fixed
Jan 30, 2023
93b9b65
remove unnecesary logging
Jan 31, 2023
be78ac8
WIP fixing the renaming bug by make sure to bring the name back after…
Feb 6, 2023
086ffb8
solve the renaming issue and print a progress bar
Feb 6, 2023
3d1d565
fix formatting
Feb 6, 2023
1a523d6
Fix the bug with more generic way
Feb 6, 2023
c77ffd5
update the evaluation function for terminals outside
Feb 6, 2023
d0b2686
[WIP] working on using packing ost functions to evaluate moves
Feb 10, 2023
e4fb89d
Using packing cost function to evaluate moves
Feb 13, 2023
bb598be
Fix a bug in the API -- setting the mode for all the pb hierarchy lev…
Feb 23, 2023
c256c11
Fixing issues with move_mol_to_new_cluster function
Feb 23, 2023
a775f91
commit the version of the packing cost evaluation before updating it
Feb 28, 2023
e2abf60
Fixing the function to evaluate the moves based on the cutsize
Mar 1, 2023
a8fa346
fix formatting and some debugging code
Mar 1, 2023
d0a9e38
update the cost function to evaluate the packing move
Mar 1, 2023
618cfb7
fix memory leaks
Mar 18, 2023
de79046
create primitive_critical_uniform_move_generator.h/.cpp
amin1377 May 10, 2023
8e341ca
change the name of the file from primitive_*_move* to atom_*_move*
amin1377 May 11, 2023
0e4db8c
write getCriticalAtomBlock under atom_critical_uni*
amin1377 May 11, 2023
8df2762
use cluster_blk_id in functions under atom_critical_uniform*
amin1377 May 11, 2023
1ced777
remove total_primitive_count field from pb_type_graph_node since it w…
amin1377 May 18, 2023
e8af9b4
add primitive num to t_pb_graph_node
amin1377 May 18, 2023
5a72ec0
remove debugging code and adding more comments
Aug 8, 2023
accb38f
prevent double freeing when removing a molecule from cluster
Aug 8, 2023
2354720
Merge branch 'master' into packing-multithreading
Sep 12, 2023
08a68c3
more comments and remove debugging code
Sep 12, 2023
15d7ce3
Add a guard for packing multithreading
Sep 13, 2023
49d3f66
mor guards for multithreading
Sep 13, 2023
5109958
Merge branch 'packing-multithreading' of https://github.com/verilog-t…
amin1377 Sep 15, 2023
3553f5e
create place_re_cluster.cpp/.h
amin1377 Sep 15, 2023
2623ca8
call place_re_cluster after quench
amin1377 Sep 15, 2023
a29e44b
choose random cluster blocks and choose random atoms inside them
amin1377 Sep 15, 2023
d9c433a
write a basic impl for t_pl_atom_loc
amin1377 Sep 15, 2023
7e949b3
add move transaction data structure for atoms
amin1377 Sep 15, 2023
03b9c14
add get_atom_mol to pack_utils
amin1377 Sep 15, 2023
c764bda
Re-clustering API bug fixes
Sep 15, 2023
36aaa4e
remove ClusterAtomsLookup class
amin1377 Sep 15, 2023
1969e17
add operator== to t_pl_atom_loc
amin1377 Sep 15, 2023
d495243
add a method to gridblock to get the atom id from atom loc
amin1377 Sep 15, 2023
9b35c9a
impl for find_affected_blocks for atom blocks
amin1377 Sep 16, 2023
a44efb7
add macros for EMPTY_PRIMITIVE_BLOCK_ID
amin1377 Sep 16, 2023
3f70a1c
add hashing function for t_pl_atom_loc
amin1377 Sep 16, 2023
5fe87fa
write record_block_move for atom blocks
amin1377 Sep 16, 2023
dd01260
write a (temp) helper function to get the location of an atom
amin1377 Sep 16, 2023
13998dc
remove unused variable
Sep 18, 2023
ac31136
fix formatting
Sep 18, 2023
e5486f3
set a default number (-1) to pb_graph_node primitive_num
amin1377 Sep 18, 2023
93be443
rename pb_graph_node_class_range under logical block to primitive_pb_…
amin1377 Sep 18, 2023
8a13c7c
add is_atom_compatible to physical types util
amin1377 Sep 18, 2023
9907633
add place_re_cluster option
amin1377 Sep 18, 2023
b8b9ec1
do reclustring if the option is set
amin1377 Sep 18, 2023
48f77c8
remained from adding the new Cl arg
amin1377 Sep 18, 2023
0c00cf1
impl is_legal_swap for atoms
amin1377 Sep 18, 2023
ea24fbc
remove unused parameters and fix formatting
Sep 18, 2023
f84a792
Merge branch 'master' into reclustering-api-bug-fixes
MohamedElgammal Sep 18, 2023
176c913
implement record_single_block_swap for atom moves
amin1377 Sep 19, 2023
8c11b1b
impl create_move for placement reclustering
amin1377 Sep 19, 2023
a0880e8
floorplan_legal for atom block
amin1377 Sep 19, 2023
ccbf5a3
impl: cluster_pins_connected_to_atom_pin
amin1377 Oct 13, 2023
27f54f4
impl a function to update td and bb costs when a pin of a net is moved
amin1377 Oct 13, 2023
d54036a
fix a bug with passsing criticalities by pointer
amin1377 Oct 13, 2023
0fdc7e0
impl apply_move_blocks for atom blocks affected
amin1377 Oct 13, 2023
6a5430a
impl revert_move_blocks for atom block move
amin1377 Oct 13, 2023
6e41db8
pass move blocks to driven_by_moved_block instead of the whole data s…
amin1377 Oct 13, 2023
04bd8a3
use any_of instead of for loop
amin1377 Oct 13, 2023
9a0c16a
pass moved_blocks and affected_pins to update_td_delta_costs
amin1377 Oct 13, 2023
1911301
pass t_pl_moved_block to update_net_bb instead of all t_pl_blocks_to_…
amin1377 Oct 16, 2023
aee362d
change the update_net_info_on_pin_move to accept related parameters
amin1377 Oct 16, 2023
2da67de
fix a type in find_affected_nets_and_update_costs parameter list
amin1377 Oct 16, 2023
199c12f
add is_src_moving parameter to update_td_delta_costs instead of deter…
amin1377 Oct 16, 2023
59f6e3e
remove unused parameters from update_net_info_on_pin_move and pass is…
amin1377 Oct 16, 2023
dc896f1
write driven_by_moved_block for atom net
amin1377 Oct 16, 2023
ac9d1b0
impl find_affected_nets_and_update_costs for changing atom loc
amin1377 Oct 16, 2023
4491881
add a constructor to t_pl_moved_block
amin1377 Oct 16, 2023
1753662
add place_algorithm to re_cluster
amin1377 Oct 16, 2023
2fca2e0
add net_cost_handler to place dir
amin1377 Oct 16, 2023
9c7d2d4
add driven_by_moved block to net_list_handler.cpp
amin1377 Oct 16, 2023
48fa5b5
add find_affected_nets_and_update_costs for both cluster and atom nets
amin1377 Oct 16, 2023
7ae6bbd
add update_net_bb to net_cost_handler
amin1377 Oct 16, 2023
7adad23
add update_td_delta_costs and record_affected_net to net_list_handler
amin1377 Oct 16, 2023
627e2fe
add update_net_info_on_pin_move to net_cost_handler
amin1377 Oct 16, 2023
6ece0f4
remove static identifiers from find_affected_nets_and_update_costs
amin1377 Oct 16, 2023
113c4e1
add local variables related to net cost to net_cost_handler
amin1377 Oct 16, 2023
eec039b
add alloc_and_load_for_fast_cost_update and its vars to place_util
amin1377 Oct 16, 2023
b161988
add wirelength_crossing_count and get_net_bounding_box_cost to place_…
amin1377 Oct 16, 2023
f04a176
add init_net_cost_structs
amin1377 Oct 17, 2023
2633c6a
add get_non_updateable_bb, update_bb, get_bb_from_scratch, get_net_wi…
amin1377 Oct 17, 2023
e50de51
add comp_bb_cost, update_move_nets, reset_move_nets, recompute_costs_…
amin1377 Oct 17, 2023
c0af5fe
alloc_and_load_for_fast_cost_update & free_fast_cost_update & wirelen…
amin1377 Oct 17, 2023
8975b8d
move functions related to chanx/y_place_cost_fac to net_cost handler …
amin1377 Oct 17, 2023
598d136
remove all the functions moved to net_cost_handler from place.cpp
amin1377 Oct 17, 2023
0d1b039
add ERROR_TOL to placer globals
amin1377 Oct 17, 2023
b0ed53f
impl swap atoms in place re cluster
amin1377 Oct 17, 2023
9c24775
fix parameter names of t_pl_moved_block
amin1377 Oct 17, 2023
d587ac4
merge with master branch
amin1377 Oct 17, 2023
60eee08
fix a bug with passing loc to get_physical_type
amin1377 Oct 17, 2023
daf4352
remove ERROR_TOL and add it to place.cpp and net_cost_handler
amin1377 Oct 17, 2023
d2a9c06
comment unused vars in place_re_cluster
amin1377 Oct 17, 2023
c9b951d
comment unused vars in net_cost_handler and atom_critical...
amin1377 Oct 17, 2023
c747efb
remove assigning invalid to cluster block id
amin1377 Oct 17, 2023
83a7b02
use the interface for propose move of AtomCriticalUniformMoveGenerator
amin1377 Oct 17, 2023
cbef91e
merge with reclustering-api-bug-fixes
amin1377 Oct 18, 2023
cb21aaf
solve conflicts with api debug branch dir: libarchfpga and src/base
amin1377 Oct 18, 2023
cabe15e
remove dir vpr/src/pack/improvements
amin1377 Oct 18, 2023
2613b42
add api debug fixes to files under vpr/src/pack
amin1377 Oct 18, 2023
4076172
fix a typo in a field name
amin1377 Oct 18, 2023
3a16d9b
comment an error in place_recluster
amin1377 Oct 18, 2023
1daf8b9
add algorithm lib to vtr_vec_id
amin1377 Oct 18, 2023
e8bc42c
make format
amin1377 Oct 18, 2023
b04e309
fix placement debugging messages to show double numbers as long f ins…
amin1377 Oct 19, 2023
b94880d
change lf to e
amin1377 Oct 19, 2023
042a8ed
tmp: add some couts for dubbing
amin1377 Oct 19, 2023
cd1ef4d
Revert "tmp: add some couts for dubbing"
amin1377 Oct 19, 2023
f0bb77d
set the capacity instead of creating actual elements
amin1377 Oct 19, 2023
8b8027e
push back to blocks affected
amin1377 Oct 19, 2023
312ca54
clear moved_blocks once swap is done
amin1377 Oct 19, 2023
463d610
add comments for physical_types.h
amin1377 Oct 19, 2023
472b279
comment on is_atom_compatible
amin1377 Oct 19, 2023
25d5267
fix the help of place_re_cluster parameter
amin1377 Oct 19, 2023
2bc377d
add comment on atom block_at_location
amin1377 Oct 19, 2023
21559aa
make format
amin1377 Oct 19, 2023
1a975ad
make the constructor explicit
amin1377 Oct 19, 2023
9e27014
check if pb_graph_node benlongs to the logical type. If it doesn't re…
amin1377 Oct 21, 2023
fba5a66
add some comments and fix atom is_legal_swap_to_location
amin1377 Oct 21, 2023
b1bdfd1
comment on move_transaction & move_utils
amin1377 Oct 21, 2023
b445803
experiment: allocate moved_blocks to max_num_blocks
amin1377 Oct 21, 2023
d1f2e03
Merge branch 'master' of https://github.com/verilog-to-routing/vtr-ve…
amin1377 Nov 10, 2023
85447d8
Merge branch '3d_link_cost_in_placement' of https://github.com/verilo…
amin1377 Nov 10, 2023
b05d57b
debug update_bb
amin1377 Nov 10, 2023
71186a9
fix find_affected_nets_and_update_costs
amin1377 Nov 10, 2023
f94c577
fix update_net_layer_bb
amin1377 Nov 10, 2023
df7fdd4
fix comp_bb_cost
amin1377 Nov 10, 2023
9989f2f
remove pushing back to blocks_affected
amin1377 Nov 11, 2023
268ea24
Merge branch 'master' of https://github.com/verilog-to-routing/vtr-ve…
amin1377 Nov 13, 2023
22f9237
change bbptr to bb
amin1377 Nov 13, 2023
e34d848
change bb pointer to const ref in get_net_bounding_box_cost
amin1377 Nov 13, 2023
6a77e80
comment on ts_bb_coord_new and layer_ts_bb_coord_new usage
amin1377 Nov 13, 2023
49d33b8
fix a type
amin1377 Nov 13, 2023
fa45f03
remove an unused function - comment net_cost_handler helper functions
amin1377 Nov 13, 2023
2de0eca
get net cost based on bb type
amin1377 Nov 13, 2023
6abf300
impl a function to set bb delta c
amin1377 Nov 13, 2023
d20732b
comment functions in net_cost_handler.h
amin1377 Nov 13, 2023
113efec
expr: add static inline for update_net_info_on_pin_move
amin1377 Nov 14, 2023
7dd0e7b
Merge branch 'master' of https://github.com/verilog-to-routing/vtr-ve…
amin1377 Nov 16, 2023
d4e726f
remove unused access to cube_bb
amin1377 Nov 16, 2023
dbbe5f6
reverse inlining of update_net_info_on_pin_move
amin1377 Nov 16, 2023
deb8297
inline the operator overloading for atom_loc
amin1377 Nov 22, 2023
f047590
use string constructor instead casting char* to string
amin1377 Nov 22, 2023
569096a
pass primitive types by value
amin1377 Nov 22, 2023
f19d64a
use empty methon instead of comparing to zero
amin1377 Nov 22, 2023
85c53dc
set the upper bound of the loop outside of the loop body
amin1377 Nov 22, 2023
4e410ce
impl of atom revert_move_blocks was wrong
amin1377 Nov 22, 2023
8e28ea9
use enum class instead of defining net update status
amin1377 Nov 22, 2023
b2eb245
use num_layers variable as upper bound of a loop
amin1377 Nov 22, 2023
16f8fff
store num_moved_blocks before the for loop
amin1377 Nov 22, 2023
321344f
add std algorithm back since std sort is used
amin1377 Nov 22, 2023
4d024d3
Merge branch 'master' of https://github.com/verilog-to-routing/vtr-ve…
amin1377 Nov 23, 2023
a12be62
Merge branch 'master' of https://github.com/verilog-to-routing/vtr-ve…
amin1377 Jun 4, 2024
34d77d8
Merge branch 'master' of https://github.com/verilog-to-routing/vtr-ve…
amin1377 Jun 5, 2024
574b6fc
[vpr] fix the bugs after merge was mastered
amin1377 Jun 5, 2024
2a71a8c
Merge branch 'master' of https://github.com/verilog-to-routing/vtr-ve…
amin1377 Jun 12, 2024
2a76d79
[vpr][place] update bb_from_scratch to update layer too
amin1377 Jun 12, 2024
a6d2fa4
[vpr][place] update get_non_updatable_bb to update layer
amin1377 Jun 12, 2024
8a8345e
[vpr][place] initialize the num_sink_layer to zero per layer
amin1377 Jun 12, 2024
655409e
[vpr][place] update update_bb to update layer info
amin1377 Jun 12, 2024
38e6b31
[vpr][place] get pin direction from get_pin_type_...
amin1377 Jun 12, 2024
ccffd51
[vpr][place] fix update_net_layer declaration
amin1377 Jun 12, 2024
0a1f655
Merge branch 'master' of https://github.com/verilog-to-routing/vtr-ve…
amin1377 Jun 18, 2024
4af56aa
Merge branch 'master' of https://github.com/verilog-to-routing/vtr-ve…
amin1377 Jun 20, 2024
b958964
[vpr][place] remove the parts for reclustering
amin1377 Jun 20, 2024
5adfa2b
[vpr][place] add a library
amin1377 Jun 20, 2024
94b51b9
[vpr][place] add more comments to net_cost_handler.h
amin1377 Jun 26, 2024
e7a6032
Merge branch 'master' of https://github.com/verilog-to-routing/vtr-ve…
amin1377 Jul 4, 2024
7ae2112
add more comments on net_cost_handler
amin1377 Jul 4, 2024
7537c27
[vpr][place] remove block comment sysntax
amin1377 Jul 4, 2024
165931c
[vpr][place] apply Vaughn's comments on net_cost_handler
amin1377 Jul 5, 2024
fbc9452
[vpr][place] apply Vaughn's comments on place.cpp
amin1377 Jul 5, 2024
2d7fbf4
Merge branch 'master' of https://github.com/verilog-to-routing/vtr-ve…
amin1377 Jul 5, 2024
c9afd34
[vpr][place] fix typos in comments
amin1377 Jul 5, 2024
0388cb7
Merge branch 'master' of https://github.com/verilog-to-routing/vtr-ve…
amin1377 Jul 12, 2024
3f1f8e2
fix comment format issue
amin1377 Jul 12, 2024
fd9fce8
[vpr][place] put comments on net_cost_handler file
amin1377 Jul 12, 2024
d000874
Merge branch 'master' of https://github.com/verilog-to-routing/vtr-ve…
amin1377 Jul 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions libs/libarchfpga/src/physical_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -923,10 +923,10 @@ struct t_logical_block_type {
std::vector<t_physical_tile_type_ptr> equivalent_tiles; ///>List of physical tiles at which one could
///>place this type of netlist block.

std::unordered_map<int, t_pb_graph_pin*> pin_logical_num_to_pb_pin_mapping; /* pin_logical_num_to_pb_pin_mapping[pin logical number] -> pb_graph_pin ptr} */
std::unordered_map<const t_pb_graph_pin*, int> primitive_pb_pin_to_logical_class_num_mapping; /* primitive_pb_pin_to_logical_class_num_mapping[pb_graph_pin ptr] -> class logical number */
std::vector<t_class> primitive_logical_class_inf; /* primitive_logical_class_inf[class_logical_number] -> class */
std::unordered_map<const t_pb_graph_node*, t_class_range> pb_graph_node_class_range;
std::unordered_map<int, t_pb_graph_pin*> pin_logical_num_to_pb_pin_mapping; /* pin_logical_num_to_pb_pin_mapping[pin logical number] -> pb_graph_pin ptr} */
std::unordered_map<const t_pb_graph_pin*, int> primitive_pb_pin_to_logical_class_num_mapping; /* primitive_pb_pin_to_logical_class_num_mapping[pb_graph_pin ptr] -> class logical number */
std::vector<t_class> primitive_logical_class_inf; /* primitive_logical_class_inf[class_logical_number] -> class */
std::unordered_map<const t_pb_graph_node*, t_class_range> primitive_pb_graph_node_class_range; /* primitive_pb_graph_node_class_range[primitive_pb_graph_node ptr] -> class range for that primitive*/

// Is this t_logical_block_type empty?
bool is_empty() const;
Expand Down Expand Up @@ -1232,6 +1232,12 @@ class t_pb_graph_node {

int placement_index;

/*
* There is a root-level pb_graph_node assigned to each logical type. Each logical type can contain multiple primitives.
* If this pb_graph_node is associated with a primitive, a unique number is assigned to it within the logical block level.
*/
int primitive_num = OPEN;

/* Contains a collection of mode indices that cannot be used as they produce conflicts during VPR packing stage
*
* Illegal modes do arise when children of a graph_node do have inconsistent `edge_modes` with respect to
Expand Down
35 changes: 34 additions & 1 deletion libs/libarchfpga/src/physical_types_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,39 @@ bool is_sub_tile_compatible(t_physical_tile_type_ptr physical_tile, t_logical_bl
return capacity_compatible && is_tile_compatible(physical_tile, logical_block);
}

bool is_atom_compatible(t_logical_block_type_ptr logical_block, const t_pb_graph_node* atom_pb_graph_node, int loc_primitive_num) {
VTR_ASSERT(loc_primitive_num != OPEN);
const t_pb_graph_node* loc_pb_graph_node = nullptr;

// Check whether the atom
const t_pb_graph_node* parent_pb_graph_node = atom_pb_graph_node->parent_pb_graph_node;
while (parent_pb_graph_node->parent_pb_graph_node != nullptr) {
parent_pb_graph_node = parent_pb_graph_node->parent_pb_graph_node;
}

if (logical_block->pb_graph_head != parent_pb_graph_node) {
return false;
}
/**
* Iterate over the data structure that maps primitive_pb_graph_node to their respective class range,
* and retrieve the primitive_pb_graph_node from that map. If the primitive number assigned to that
* primitive_pb_graph_node is equal to loc_primitive_num, then we have found the desired primitive_pb_graph_node.
*/
for (const auto& primitive_node_class_pair : logical_block->primitive_pb_graph_node_class_range) {
const auto& primitive_node = primitive_node_class_pair.first;
VTR_ASSERT_SAFE(primitive_node->primitive_num != OPEN);
if (primitive_node->primitive_num == loc_primitive_num) {
loc_pb_graph_node = primitive_node;
break;
}
}
VTR_ASSERT_SAFE(loc_pb_graph_node != nullptr);
if (loc_pb_graph_node->pb_type == atom_pb_graph_node->pb_type)
return true;
else
return false;
}

int get_physical_pin_at_sub_tile_location(t_physical_tile_type_ptr physical_tile,
t_logical_block_type_ptr logical_block,
int sub_tile_capacity,
Expand Down Expand Up @@ -965,7 +998,7 @@ t_class_range get_pb_graph_node_class_physical_range(t_physical_tile_type_ptr /*
const t_pb_graph_node* pb_graph_node) {
VTR_ASSERT(pb_graph_node->is_primitive());

t_class_range class_range = logical_block->pb_graph_node_class_range.at(pb_graph_node);
t_class_range class_range = logical_block->primitive_pb_graph_node_class_range.at(pb_graph_node);
int logical_block_class_offset = sub_tile->primitive_class_range[sub_tile_relative_cap].at(logical_block).low;

class_range.low += logical_block_class_offset;
Expand Down
3 changes: 3 additions & 0 deletions libs/libarchfpga/src/physical_types_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ bool is_tile_compatible(t_physical_tile_type_ptr physical_tile, t_logical_block_
///@brief Verifies whether a logical block and a relative placement location is compatible with a given physical tile
bool is_sub_tile_compatible(t_physical_tile_type_ptr physical_tile, t_logical_block_type_ptr logical_block, int sub_tile_loc);

///@brief Verifies whether the given atom_pb_graph_node can be mapped to the primitive that loc_primitive_num is pointing to.
bool is_atom_compatible(t_logical_block_type_ptr logical_block, const t_pb_graph_node* atom_pb_graph_node, int loc_primitive_num);

/**
* @brief Returns the first physical tile type that matches the logical block
*
Expand Down
1 change: 1 addition & 0 deletions libs/libvtrutil/src/vtr_vec_id_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define VTR_SET_H

#include <vector>
#include <algorithm>

namespace vtr {

Expand Down
1 change: 1 addition & 0 deletions vpr/src/base/SetupVPR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ static void SetupPlacerOpts(const t_options& Options, t_placer_opts* PlacerOpts)
PlacerOpts->place_constraint_subtile = Options.place_constraint_subtile;
PlacerOpts->floorplan_num_horizontal_partitions = Options.floorplan_num_horizontal_partitions;
PlacerOpts->floorplan_num_vertical_partitions = Options.floorplan_num_vertical_partitions;
PlacerOpts->place_re_cluster = Options.place_re_cluster;

PlacerOpts->seed = Options.Seed;

Expand Down
9 changes: 9 additions & 0 deletions vpr/src/base/read_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2176,6 +2176,15 @@ argparse::ArgumentParser create_arg_parser(std::string prog_name, t_options& arg
.choices({"move_type", "move_block_type"})
.show_in(argparse::ShowIn::HELP_ONLY);

place_grp.add_argument<bool, ParseOnOff>(args.place_re_cluster, "--place_re_cluster")
.help(
"Use this option to determine whether reclustering occurs during placement. "
""
"When this option is set to 'on,' the placement stage may change some clusters. "
"Conversely, if the option is set to 'off,' the clustering determined by the packer will remain unchanged")
.default_value("off")
.show_in(argparse::ShowIn::HELP_ONLY);

place_grp.add_argument(args.placer_debug_block, "--placer_debug_block")
.help(
" Controls when placer debugging is enabled for blocks.\n"
Expand Down
1 change: 1 addition & 0 deletions vpr/src/base/read_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ struct t_options {
argparse::ArgValue<bool> place_constraint_subtile;
argparse::ArgValue<int> floorplan_num_horizontal_partitions;
argparse::ArgValue<int> floorplan_num_vertical_partitions;
argparse::ArgValue<bool> place_re_cluster;

argparse::ArgValue<int> placer_debug_block;
argparse::ArgValue<int> placer_debug_net;
Expand Down
27 changes: 27 additions & 0 deletions vpr/src/base/vpr_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,31 @@ void t_cluster_placement_stats::free_primitives() {
delete primitive.second;
}
}
}

/**
* @brief Get the atom block id at the given location. Since we currently don't have any array to retrieve this information directly,
* we first find the cluster mapped to that location, and then find the atom inside that cluster that is mapped to the given location.
*/
AtomBlockId GridBlock::block_at_location(const t_pl_atom_loc& loc) const {
const auto& atom_lookup = g_vpr_ctx.atom().lookup;
t_pl_loc cluster_loc(loc.x, loc.y, loc.sub_tile, loc.layer);
ClusterBlockId cluster_at_loc = block_at_location(cluster_loc);
if (cluster_at_loc == EMPTY_BLOCK_ID) {
return EMPTY_PRIMITIVE_BLOCK_ID;
} else if (cluster_at_loc == INVALID_BLOCK_ID) {
return INVALID_PRIMITIVE_BLOCK_ID;
} else {
VTR_ASSERT(cluster_at_loc.is_valid());
const auto& cluster_atoms = g_vpr_ctx.cl_helper().atoms_lookup;
const auto& atom_list = cluster_atoms.at(cluster_at_loc);
for (const auto& atom : atom_list) {
int primitive_pin = atom_lookup.atom_pb_graph_node(atom)->primitive_num;
t_pl_atom_loc atom_loc(primitive_pin, cluster_loc.x, cluster_loc.y, cluster_loc.sub_tile, cluster_loc.layer);
if (atom_loc == loc) {
return atom;
}
}
return EMPTY_PRIMITIVE_BLOCK_ID;
}
}
47 changes: 46 additions & 1 deletion vpr/src/base/vpr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ enum class ScreenUpdatePriority {

/* Defining macros for the placement_ctx t_grid_blocks. Assumes that ClusterBlockId's won't exceed positive 32-bit integers */
constexpr auto EMPTY_BLOCK_ID = ClusterBlockId(-1);
constexpr auto EMPTY_PRIMITIVE_BLOCK_ID = AtomBlockId(-1);
constexpr auto INVALID_BLOCK_ID = ClusterBlockId(-2);
constexpr auto INVALID_PRIMITIVE_BLOCK_ID = AtomBlockId(-2);

/*
* Files
Expand Down Expand Up @@ -774,7 +776,7 @@ struct t_pl_loc {
}

friend bool operator==(const t_pl_loc& lhs, const t_pl_loc& rhs) {
return std::tie(lhs.layer, lhs.x, lhs.y, lhs.sub_tile) == std::tie(rhs.layer, rhs.x, rhs.y, rhs.sub_tile);
return std::tie(lhs.x, lhs.y, lhs.sub_tile, lhs.layer) == std::tie(rhs.x, rhs.y, rhs.sub_tile, rhs.layer);
}

friend bool operator!=(const t_pl_loc& lhs, const t_pl_loc& rhs) {
Expand All @@ -795,6 +797,40 @@ struct hash<t_pl_loc> {
};
} // namespace std

struct t_pl_atom_loc {
t_pl_atom_loc() = default;
t_pl_atom_loc(int primitive_id_, int x_, int y_, int sub_tile_, int layer_)
: primitive_id(primitive_id_)
, x(x_)
, y(y_)
, sub_tile(sub_tile_)
, layer(layer_) {}

int primitive_id = OPEN;
int x = OPEN;
int y = OPEN;
int sub_tile = OPEN;
int layer = OPEN;

friend bool operator==(const t_pl_atom_loc& lhs, const t_pl_atom_loc& rhs) {
return std::tie(lhs.primitive_id, lhs.x, lhs.y, lhs.sub_tile, lhs.layer) == std::tie(rhs.primitive_id, rhs.x, rhs.y, rhs.sub_tile, rhs.layer);
}
};

namespace std {
template<>
struct hash<t_pl_atom_loc> {
std::size_t operator()(const t_pl_atom_loc& v) const noexcept {
std::size_t seed = std::hash<int>{}(v.x);
vtr::hash_combine(seed, v.y);
vtr::hash_combine(seed, v.sub_tile);
vtr::hash_combine(seed, v.layer);
vtr::hash_combine(seed, v.primitive_id);
return seed;
}
};
} // namespace std

struct t_place_region {
float capacity; ///<Capacity of this region, in tracks.
float inv_capacity;
Expand Down Expand Up @@ -859,6 +895,8 @@ class GridBlock {
return grid_blocks_[loc.layer][loc.x][loc.y].blocks[loc.sub_tile];
}

AtomBlockId block_at_location(const t_pl_atom_loc& loc) const;

inline size_t num_blocks_at_location(const t_physical_tile_loc& loc) const {
return grid_blocks_[loc.layer_num][loc.x][loc.y].blocks.size();
}
Expand Down Expand Up @@ -1255,6 +1293,7 @@ struct t_placer_opts {
int floorplan_num_horizontal_partitions;
int floorplan_num_vertical_partitions;

bool place_re_cluster;
int placer_debug_block;
int placer_debug_net;

Expand Down Expand Up @@ -1887,4 +1926,10 @@ void free_pack_molecules(t_pack_molecule* list_of_pack_molecules);
*/
void free_cluster_placement_stats(t_cluster_placement_stats* cluster_placement_stats);

struct pair_hash {
std::size_t operator()(const std::pair<ClusterBlockId, ClusterBlockId>& p) const noexcept {
return std::hash<ClusterBlockId>()(p.first) ^ (std::hash<ClusterBlockId>()(p.second) << 1);
}
};

#endif
35 changes: 16 additions & 19 deletions vpr/src/pack/pb_type_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node,
t_pb_type* pb_type,
const int index,
bool load_power_structures,
int& pin_count_in_cluster);
int& pin_count_in_cluster,
int& primitive_num);

static void alloc_and_load_pb_graph_pin_sinks(t_pb_graph_node* pb_graph_node);

Expand Down Expand Up @@ -147,12 +148,14 @@ void alloc_and_load_all_pb_graphs(bool load_power_structures, bool is_flat) {
if (type.pb_type) {
type.pb_graph_head = new t_pb_graph_node();
int pin_count_in_cluster = 0;
int primitive_num = 0;
alloc_and_load_pb_graph(type.pb_graph_head,
nullptr,
type.pb_type,
0,
load_power_structures,
pin_count_in_cluster);
pin_count_in_cluster,
primitive_num);
type.pb_graph_head->total_pb_pins = pin_count_in_cluster;
load_pin_classes_in_pb_graph_head(type.pb_graph_head);
if (is_flat) {
Expand Down Expand Up @@ -225,7 +228,8 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node,
t_pb_type* pb_type,
const int index,
bool load_power_structures,
int& pin_count_in_cluster) {
int& pin_count_in_cluster,
int& primitive_num) {
int i, j, k, i_input, i_output, i_clockport;

pb_graph_node->placement_index = index;
Expand All @@ -236,8 +240,6 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node,
pb_graph_node->num_output_ports = 0;
pb_graph_node->num_clock_ports = 0;

pb_graph_node->total_primitive_count = 0;

/* Generate ports for pb graph node */
for (i = 0; i < pb_type->num_ports; i++) {
if (pb_type->ports[i].type == IN_PORT && !pb_type->ports[i].is_clock) {
Expand Down Expand Up @@ -341,6 +343,11 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node,
pb_graph_node->pb_node_power->transistor_cnt_pb_children = 0.;
}

if (pb_graph_node->is_primitive()) {
pb_graph_node->primitive_num = primitive_num;
primitive_num++;
}

/* Allocate and load child nodes for each mode and create interconnect in each mode */

pb_graph_node->child_pb_graph_nodes = (t_pb_graph_node***)vtr::calloc(pb_type->num_modes, sizeof(t_pb_graph_node**));
Expand All @@ -355,7 +362,8 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node,
&pb_type->modes[i].pb_type_children[j],
k,
load_power_structures,
pin_count_in_cluster);
pin_count_in_cluster,
primitive_num);
}
}
}
Expand All @@ -370,17 +378,6 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node,
&pb_type->modes[i],
load_power_structures);
}

// update the total number of primitives of that type
if (pb_graph_node->is_primitive()) {
int total_count = 1;
auto pb_node = pb_graph_node;
while (!pb_node->is_root()) {
total_count *= pb_node->pb_type->num_pb;
pb_node = pb_node->parent_pb_graph_node;
}
pb_graph_node->total_primitive_count = total_count;
}
}

static void alloc_and_load_pb_graph_pin_sinks(t_pb_graph_node* pb_graph_node) {
Expand Down Expand Up @@ -532,8 +529,8 @@ static void add_primitive_logical_classes(t_logical_block_type* logical_block) {
}
num_added_classes += add_port_logical_classes(logical_block, pb_graph_pins, num_ports, num_pins);
}
logical_block->pb_graph_node_class_range.insert(std::make_pair(pb_graph_node, t_class_range(first_class_num,
first_class_num + num_added_classes - 1)));
logical_block->primitive_pb_graph_node_class_range.insert(std::make_pair(pb_graph_node, t_class_range(first_class_num,
first_class_num + num_added_classes - 1)));
}
}

Expand Down
Loading