@@ -96,116 +96,152 @@ class HeapStorage {
96
96
size_t num_heap_allocated_;
97
97
};
98
98
99
- // Interface to heap used for router optimization.
100
- //
101
- // Note: Objects used in instances of HeapInterface must always be allocated
102
- // and free'd using the HeapInterface::alloc and HeapInterface::free methods
103
- // of that instance. Object pools are likely in use.
104
- //
105
- // As a general rule, any t_heap objects returned from this interface,
106
- // **must** be HeapInterface::free'd before destroying the HeapInterface
107
- // instance. This ensure that no leaks are present in the users of the heap.
108
- // Violating this assumption may result in a assertion violation.
99
+ /* *
100
+ * @brief Interface to heap used for router optimization.
101
+ *
102
+ * @details
103
+ * Note: Objects used in instances of HeapInterface must always be allocated
104
+ * and free'd using the HeapInterface::alloc and HeapInterface::free methods
105
+ * of that instance. Object pools are likely in use.<BR><BR>
106
+ * As a general rule, any t_heap objects returned from this interface,
107
+ * **must** be HeapInterface::free'd before destroying the HeapInterface
108
+ * instance. This ensure that no leaks are present in the users of the heap.
109
+ * Violating this assumption may result in a assertion violation.
110
+ */
109
111
class HeapInterface {
110
112
public:
111
113
virtual ~HeapInterface () {}
112
114
113
- // Allocate a heap item.
114
- //
115
- // This transfers ownership of the t_heap object from HeapInterface to the
116
- // caller.
115
+ /* *
116
+ * @brief Allocate a heap item.
117
+ *
118
+ * @details
119
+ * This transfers ownership of the t_heap object from HeapInterface to the
120
+ * caller.
121
+ */
117
122
virtual t_heap* alloc () = 0;
118
123
119
- // Free a heap item.
120
- //
121
- // HeapInterface::free can be called on objects returned from either
122
- // HeapInterface::alloc or HeapInterface::get_heap_head.
124
+ /* *
125
+ * @brief Free a heap item.
126
+ *
127
+ * @details
128
+ * HeapInterface::free can be called on objects returned from either
129
+ * HeapInterface::alloc or HeapInterface::get_heap_head.
130
+ *
131
+ * @param hptr The element to free.
132
+ */
123
133
virtual void free (t_heap* hptr) = 0;
124
134
125
- // Initializes heap storage based on the size of the device.
126
- //
127
- // Note: this method **must** be invoked at least once prior to the
128
- // following methods being called:
129
- // - add_to_heap
130
- // - push_back
131
- // - get_heap_head
132
- // - is_empty_heap
133
- // - empty_heap
134
- // - build_heap
135
+ /* *
136
+ * @brief Initializes heap storage based on the size of the device.
137
+ *
138
+ * @details
139
+ * Note: this method **must** be invoked at least once prior to the
140
+ * following methods being called:<BR>
141
+ * - add_to_heap<BR>
142
+ * - push_back<BR>
143
+ * - get_heap_head<BR>
144
+ * - is_empty_heap<BR>
145
+ * - empty_heap<BR>
146
+ * - build_heap<BR>
147
+ *
148
+ * @param grid
149
+ */
135
150
virtual void init_heap (const DeviceGrid& grid) = 0;
136
151
137
- // Add t_heap to heap, preserving heap property.
138
- //
139
- // This transfers ownership of the t_heap object to HeapInterface from the
140
- // called.
152
+ /* *
153
+ * @brief Add t_heap to heap, preserving heap property.
154
+ *
155
+ * @details
156
+ * This transfers ownership of the t_heap object to HeapInterface from the
157
+ * called.
158
+ *
159
+ * @param hptr The element to add.
160
+ */
141
161
virtual void add_to_heap (t_heap* hptr) = 0;
142
162
143
- // Add t_heap to heap, however does not preserve heap property.
144
- //
145
- // This is useful if multiple t_heap's are being added in bulk. Once
146
- // all t_heap's have been added, HeapInterface::build_heap can be invoked
147
- // to restore the heap property in an efficient way.
148
- //
149
- // This transfers ownership of the t_heap object to HeapInterface from the
150
- // called.
163
+ /* *
164
+ * @brief Add t_heap to heap, however does not preserve heap property.
165
+ *
166
+ * @details
167
+ * This is useful if multiple t_heap's are being added in bulk. Once
168
+ * all t_heap's have been added, HeapInterface::build_heap can be invoked
169
+ * to restore the heap property in an efficient way.<BR><BR>
170
+ * This transfers ownership of the t_heap object to HeapInterface from the
171
+ * called.
172
+ *
173
+ * @param hptr The element to insert.
174
+ */
151
175
virtual void push_back (t_heap* const hptr) = 0;
152
176
153
- // Restore the heap property.
154
- //
155
- // This is useful in conjunction with HeapInterface::push_back when adding
156
- // multiple heap elements.
177
+ /* *
178
+ * @brief Restore the heap property.
179
+ *
180
+ * @details
181
+ * This is useful in conjunction with HeapInterface::push_back when adding
182
+ * multiple heap elements.
183
+ */
157
184
virtual void build_heap () = 0;
158
185
159
- // Pop the head (smallest element) of the heap, and return it.
160
- //
161
- // This transfers ownership of the t_heap object from HeapInterface to the
162
- // caller.
186
+ /* *
187
+ * @brief Pop the head (smallest element) of the heap, and return it.
188
+ *
189
+ * @details
190
+ * This transfers ownership of the t_heap object from HeapInterface to the
191
+ * caller.
192
+ */
163
193
virtual t_heap* get_heap_head () = 0;
164
194
165
- // Is the heap empty?
195
+ /* *
196
+ * @brief Is the heap empty?
197
+ */
166
198
virtual bool is_empty_heap () const = 0;
167
199
168
- // Is the heap valid?
200
+ /* *
201
+ * @brief Is the heap valid?
202
+ */
169
203
virtual bool is_valid () const = 0;
170
204
171
- // Empty all items from the heap.
205
+ /* *
206
+ * @brief Empty all items from the heap.
207
+ */
172
208
virtual void empty_heap () = 0;
173
209
174
- // Free all storage used by the heap.
175
- //
176
- // This returns all memory allocated by the HeapInterface instance. Only
177
- // call this if the heap is no longer being used.
178
- //
179
- // Note: Only invoke this method if all objects returned from this
180
- // HeapInterface instace have been free'd.
210
+ /* *
211
+ * @brief Free all storage used by the heap.
212
+ *
213
+ * @details
214
+ * This returns all memory allocated by the HeapInterface instance. Only
215
+ * call this if the heap is no longer being used.<BR><BR>
216
+ * Note: Only invoke this method if all objects returned from this
217
+ * HeapInterface instance have been free'd.
218
+ */
181
219
virtual void free_all_memory () = 0;
182
220
183
- // Set maximum number of elements that the heap should contain
184
- // (the prune_limit). If the prune limit is hit, then the heap should
185
- // kick out duplicate index entries.
186
- //
187
- // The prune limit exists to provide a maximum bound on memory usage in
188
- // the heap. In some pathological cases, the router may explore
189
- // incrementally better paths, resulting in many duplicate entries for
190
- // RR nodes. To handle this edge case, if the number of heap items
191
- // exceeds the prune_limit, then the heap will compacts itself.
192
- //
193
- // The heap compaction process simply means taking the lowest cost entry
194
- // for each index (e.g. RR node). All nodes with higher costs can safely
195
- // be dropped.
196
- //
197
- // The pruning process is intended to bound the memory usage the heap can
198
- // consume based on the prune_limit, which is expected to be a function of
199
- // the graph size.
200
- //
201
- // max_index should be the highest index possible in the heap.
202
- // prune_limit is the maximuming number of heap entries before pruning
203
- // should take place.
204
- //
205
- // The prune_limit should always be higher than max_index, likely by a
206
- // significant amount. The pruning process has some overhead, so
207
- // prune_limit should be ~2-4x the max_index to prevent excess pruning
208
- // when not required.
221
+ /* *
222
+ * @brief Set maximum number of elements that the heap should contain
223
+ * (the prune_limit). If the prune limit is hit, then the heap should
224
+ * kick out duplicate index entries.
225
+ *
226
+ * @details
227
+ * The prune limit exists to provide a maximum bound on memory usage in
228
+ * the heap. In some pathological cases, the router may explore
229
+ * incrementally better paths, resulting in many duplicate entries for
230
+ * RR nodes. To handle this edge case, if the number of heap items
231
+ * exceeds the prune_limit, then the heap will compacts itself.<BR><BR>
232
+ * The heap compaction process simply means taking the lowest cost entry
233
+ * for each index (e.g. RR node). All nodes with higher costs can safely
234
+ * be dropped.<BR><BR>
235
+ * The pruning process is intended to bound the memory usage the heap can
236
+ * consume based on the prune_limit, which is expected to be a function of
237
+ * the graph size.
238
+ *
239
+ * @param max_index The highest index possible in the heap.
240
+ * @param prune_limit The maximum number of heap entries before pruning should
241
+ * take place. This should alwasy be higher than max_index, likely by a
242
+ * significant amount. The pruning process has some overhead, so prune_limit
243
+ * should be ~2-4x the max_index to prevent excess pruning when not required.
244
+ */
209
245
virtual void set_prune_limit (size_t max_index, size_t prune_limit) = 0;
210
246
};
211
247
0 commit comments