8
8
9
9
#pragma once
10
10
11
- #include < algorithm>
12
- #include < limits>
11
+ #include " appack_max_dist_th_manager.h"
13
12
#include " device_grid.h"
14
13
#include " flat_placement_types.h"
15
14
#include " physical_types.h"
16
15
#include " vpr_context.h"
16
+ #include " vpr_types.h"
17
17
#include " vpr_utils.h"
18
18
19
19
/* *
25
25
*/
26
26
struct t_appack_options {
27
27
// 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) {
30
29
// If the flat placement info is valid, we want to use APPack.
31
30
// TODO: Should probably check that all the information is valid here.
32
31
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 ;
51
32
}
52
33
53
34
// Whether to use APPack or not.
@@ -88,22 +69,6 @@ struct t_appack_options {
88
69
// Squared scaling factor for the quadratic decay term.
89
70
static constexpr float quad_fac_sqr = (1 .0f - attenuation_th) / (dist_th * dist_th);
90
71
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
-
107
72
// =========== Unrelated clustering ==================================== //
108
73
// After searching for candidates by connectivity and timing, the user may
109
74
// turn on unrelated clustering, which will allow molecules which are
@@ -144,9 +109,21 @@ struct APPackContext : public Context {
144
109
/* *
145
110
* @brief Constructor for the APPack context.
146
111
*/
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
+ }
150
127
151
128
/* *
152
129
* @brief Options used to configure APPack.
@@ -157,4 +134,8 @@ struct APPackContext : public Context {
157
134
* @brief The flat placement information passed into APPack.
158
135
*/
159
136
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;
160
141
};
0 commit comments