@@ -133,10 +133,35 @@ class NocStorage {
133
133
*/
134
134
double noc_router_latency;
135
135
136
+ /* *
137
+ * @brief When set true, specifies that some NoC routers have different
138
+ * latencies than others. When set false, all the NoC routers have the same
139
+ * latency.
140
+ */
136
141
bool detailed_router_latency_;
142
+
143
+ /* *
144
+ * @brief When set true, specifies that some NoC links have different
145
+ * latencies than others. When set false, all the NoC link have the same
146
+ * latency.
147
+ */
137
148
bool detailed_link_latency_;
149
+
150
+ /* *
151
+ * @brief When set true, specifies that some NoC links have different
152
+ * bandwidth than others. When set false, all the NoC link have the same
153
+ * bandwidth.
154
+ */
138
155
bool detailed_link_bandwidth_;
139
156
157
+ /* *
158
+ * @brief A constant reference to this vector is returned by get_noc_links(...).
159
+ * This is used to avoid memory allocation whenever get_noc_links(...) is called.
160
+ * The vector is mutable so that get_noc_links(...), which is a const method, can
161
+ * modify it.
162
+ */
163
+ mutable std::vector<std::reference_wrapper<const NocLink>> returnable_noc_link_const_refs_;
164
+
140
165
/* *
141
166
* @brief Internal reference to the device grid width. This is necessary
142
167
* to compute a unique key for a given grid location which we can then use
@@ -204,45 +229,54 @@ class NocStorage {
204
229
*
205
230
* @return A vector of links.
206
231
*/
207
- vtr::vector<NocLinkId, NocLink>& get_mutable_noc_links (void );
232
+ vtr::vector<NocLinkId, NocLink>& get_mutable_noc_links ();
208
233
209
234
/* *
210
235
* @return An integer representing the total number of links within the
211
236
* NoC.
212
237
*/
213
- int get_number_of_noc_links (void ) const ;
238
+ int get_number_of_noc_links () const ;
214
239
215
240
/* *
216
241
* @brief Get the maximum allowable bandwidth for a link
217
242
* within the NoC.
218
243
*
219
244
* @return a numeric value that represents the link bandwidth in bps
220
245
*/
221
-
222
- double get_noc_link_bandwidth (void ) const ;
246
+ double get_noc_link_bandwidth () const ;
223
247
224
248
/* *
225
249
* @brief Get the latency of traversing through a link in
226
250
* the NoC.
227
251
*
228
252
* @return a numeric value that represents the link latency in seconds
229
253
*/
230
-
231
- double get_noc_link_latency (void ) const ;
254
+ double get_noc_link_latency () const ;
232
255
233
256
/* *
234
257
* @brief Get the latency of traversing through a router in
235
258
* the NoC.
236
259
*
237
260
* @return a numeric value that represents the router latency in seconds
238
261
*/
262
+ double get_noc_router_latency () const ;
239
263
240
- double get_noc_router_latency (void ) const ;
241
-
264
+ /* *
265
+ * @return True if some NoC routers have different latencies than others.
266
+ * False if all NoC routers have the same latency.
267
+ */
242
268
bool get_detailed_router_latency () const ;
243
269
270
+ /* *
271
+ * @return True if some NoC links have different latencies than others.
272
+ * False if all NoC links have the same latency.
273
+ */
244
274
bool get_detailed_link_latency () const ;
245
275
276
+ /* *
277
+ * @return True if some NoC links have different bandwidths than others.
278
+ * False if all NoC links have the same bandwidth.
279
+ */
246
280
bool get_detailed_link_bandwidth () const ;
247
281
248
282
// getters for routers
@@ -279,6 +313,18 @@ class NocStorage {
279
313
*/
280
314
const NocLink& get_single_noc_link (NocLinkId id) const ;
281
315
316
+ /* *
317
+ *
318
+ * @tparam Container The type of standard library container used to carry
319
+ * NoCLinkIds. This container type must be iterable in a range-based loop.
320
+ * @param noc_link_ids A standard container that contains NoCLinkIds of the
321
+ * requested NoC links
322
+ * @return A const
323
+ */
324
+ template <template <typename > class Container >
325
+ const std::vector<std::reference_wrapper<const NocLink>>& get_noc_links (const Container<NocLinkId>& noc_link_ids) const ;
326
+
327
+
282
328
/* *
283
329
* @brief Given source and sink router identifiers, this function
284
330
* finds a link connecting these routers and returns its identifier.
@@ -292,7 +338,7 @@ class NocStorage {
292
338
* to the destination router. NocLinkId::INVALID() is such a link is not
293
339
* found.
294
340
*/
295
- NocLinkId get_single_noc_link_id (NocRouterId src_router, NocRouterId dst_router) const ;
341
+ NocLinkId get_single_noc_link_id (NocRouterId src_router, NocRouterId dst_router) const ;
296
342
297
343
/* *
298
344
* @brief Given a unique link identifier, get the corresponding link
@@ -376,7 +422,7 @@ class NocStorage {
376
422
377
423
void set_device_grid_spec (int grid_width, int grid_height);
378
424
379
- // general utiliy functions
425
+ // general utility functions
380
426
/* *
381
427
* @brief The link is removed from the outgoing vector of links for
382
428
* the source router. The link is not removed from the vector of all
@@ -404,6 +450,14 @@ class NocStorage {
404
450
* NoC (routers and links cannot be added or removed). This function
405
451
* should be called after building the NoC. Guarantees that
406
452
* no future changes can be made.
453
+ *
454
+ * When the NoC building is finished, this function checks whether
455
+ * all links and routers have the same bandwidth and latency.
456
+ * If some NoC elements have different latencies or bandwidths than
457
+ * others, a flag is set to indicate that the detailed NoC model should be
458
+ * used. In the detailed model, instead of associating a single latency or
459
+ * bandwidth value with all NoC routers or links, each NoC router or link
460
+ * has its specific value.
407
461
*
408
462
*/
409
463
void finished_building_noc ();
@@ -495,4 +549,18 @@ class NocStorage {
495
549
void echo_noc (char * file_name) const ;
496
550
};
497
551
498
- #endif
552
+
553
+ template <template <typename > class Container >
554
+ const std::vector<std::reference_wrapper<const NocLink>>& NocStorage::get_noc_links (const Container<NocLinkId>& noc_link_ids) const {
555
+ returnable_noc_link_const_refs_.clear ();
556
+
557
+ std::transform (noc_link_ids.begin (), noc_link_ids.end (), std::back_inserter (returnable_noc_link_const_refs_),
558
+ [this ](const NocLinkId lid) {
559
+ return std::reference_wrapper<const NocLink>(this ->get_single_noc_link (lid));
560
+ });
561
+
562
+ return returnable_noc_link_const_refs_;
563
+ }
564
+
565
+ #endif
566
+
0 commit comments