88
99#pragma once
1010
11- #include < algorithm>
12- #include < limits>
11+ #include " appack_max_dist_th_manager.h"
1312#include " device_grid.h"
1413#include " flat_placement_types.h"
1514#include " physical_types.h"
1615#include " vpr_context.h"
16+ #include " vpr_types.h"
1717#include " vpr_utils.h"
1818
1919/* *
2525 */
2626struct t_appack_options {
2727 // Constructor for the appack options.
28- t_appack_options (const FlatPlacementInfo& flat_placement_info,
29- const DeviceGrid& device_grid) {
28+ t_appack_options (const FlatPlacementInfo& flat_placement_info) {
3029 // If the flat placement info is valid, we want to use APPack.
3130 // TODO: Should probably check that all the information is valid here.
3231 use_appack = flat_placement_info.valid ;
33-
34- // Set the max candidate distance as being some fraction of the longest
35- // distance on the device (from the bottom corner to the top corner).
36- // We also use an offset for the minimum this distance can be to prevent
37- // small devices from finding candidates.
38- float max_candidate_distance_scale = 0 .1f ;
39- float max_candidate_distance_offset = 15 .0f ;
40- // Longest L1 distance on the device.
41- float longest_distance = device_grid.width () + device_grid.height ();
42- max_candidate_distance = std::max (max_candidate_distance_scale * longest_distance,
43- max_candidate_distance_offset);
44-
45- // Infer the logical block type in the architecture. This will be used
46- // for the max candidate distance optimization to use a more aggressive
47- // distance.
48- t_logical_block_type_ptr logic_block_type = infer_logic_block_type (device_grid);
49- if (logic_block_type != nullptr )
50- logic_block_type_index = logic_block_type->index ;
5132 }
5233
5334 // Whether to use APPack or not.
@@ -88,22 +69,6 @@ struct t_appack_options {
8869 // Squared scaling factor for the quadratic decay term.
8970 static constexpr float quad_fac_sqr = (1 .0f - attenuation_th) / (dist_th * dist_th);
9071
91- // =========== Candidate selection distance ============================ //
92- // When selecting candidates, what distance from the cluster will we
93- // consider? Any candidate beyond this distance will not be proposed.
94- // This is set in the constructor.
95- // TODO: It may be a good idea to have max different distances for different
96- // types of molecules / clusters. For example, CLBs vs DSPs
97- float max_candidate_distance = std::numeric_limits<float >::max();
98-
99- // A scaling applied to the max candidate distance of all clusters that are
100- // not logic blocks.
101- static constexpr float max_candidate_distance_non_lb_scale = 3 .5f ;
102-
103- // TODO: This should be an option similar to the target pin utilization
104- // so we can specify the max distance per block type!
105- int logic_block_type_index = -1 ;
106-
10772 // =========== Unrelated clustering ==================================== //
10873 // After searching for candidates by connectivity and timing, the user may
10974 // turn on unrelated clustering, which will allow molecules which are
@@ -144,9 +109,21 @@ struct APPackContext : public Context {
144109 /* *
145110 * @brief Constructor for the APPack context.
146111 */
147- APPackContext (const FlatPlacementInfo& fplace_info, const DeviceGrid& device_grid)
148- : appack_options(fplace_info, device_grid)
149- , flat_placement_info(fplace_info) {}
112+ APPackContext (const FlatPlacementInfo& fplace_info,
113+ const t_ap_opts& ap_opts,
114+ const std::vector<t_logical_block_type> logical_block_types,
115+ const DeviceGrid& device_grid)
116+ : appack_options(fplace_info)
117+ , flat_placement_info(fplace_info) {
118+
119+ // If the flat placement info has been provided, calculate max distance
120+ // thresholds for all logical block types.
121+ if (fplace_info.valid ) {
122+ max_distance_threshold_manager.init (ap_opts.appack_max_dist_th ,
123+ logical_block_types,
124+ device_grid);
125+ }
126+ }
150127
151128 /* *
152129 * @brief Options used to configure APPack.
@@ -157,4 +134,8 @@ struct APPackContext : public Context {
157134 * @brief The flat placement information passed into APPack.
158135 */
159136 const FlatPlacementInfo& flat_placement_info;
137+
138+ // When selecting candidates, what distance from the cluster will we
139+ // consider? Any candidate beyond this distance will not be proposed.
140+ APPackMaxDistThManager max_distance_threshold_manager;
160141};
0 commit comments