@@ -133,10 +133,35 @@ class NocStorage {
133133 */
134134 double noc_router_latency;
135135
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+ */
136141 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+ */
137148 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+ */
138155 bool detailed_link_bandwidth_;
139156
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+
140165 /* *
141166 * @brief Internal reference to the device grid width. This is necessary
142167 * to compute a unique key for a given grid location which we can then use
@@ -204,45 +229,54 @@ class NocStorage {
204229 *
205230 * @return A vector of links.
206231 */
207- vtr::vector<NocLinkId, NocLink>& get_mutable_noc_links (void );
232+ vtr::vector<NocLinkId, NocLink>& get_mutable_noc_links ();
208233
209234 /* *
210235 * @return An integer representing the total number of links within the
211236 * NoC.
212237 */
213- int get_number_of_noc_links (void ) const ;
238+ int get_number_of_noc_links () const ;
214239
215240 /* *
216241 * @brief Get the maximum allowable bandwidth for a link
217242 * within the NoC.
218243 *
219244 * @return a numeric value that represents the link bandwidth in bps
220245 */
221-
222- double get_noc_link_bandwidth (void ) const ;
246+ double get_noc_link_bandwidth () const ;
223247
224248 /* *
225249 * @brief Get the latency of traversing through a link in
226250 * the NoC.
227251 *
228252 * @return a numeric value that represents the link latency in seconds
229253 */
230-
231- double get_noc_link_latency (void ) const ;
254+ double get_noc_link_latency () const ;
232255
233256 /* *
234257 * @brief Get the latency of traversing through a router in
235258 * the NoC.
236259 *
237260 * @return a numeric value that represents the router latency in seconds
238261 */
262+ double get_noc_router_latency () const ;
239263
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+ */
242268 bool get_detailed_router_latency () const ;
243269
270+ /* *
271+ * @return True if some NoC links have different latencies than others.
272+ * False if all NoC links have the same latency.
273+ */
244274 bool get_detailed_link_latency () const ;
245275
276+ /* *
277+ * @return True if some NoC links have different bandwidths than others.
278+ * False if all NoC links have the same bandwidth.
279+ */
246280 bool get_detailed_link_bandwidth () const ;
247281
248282 // getters for routers
@@ -279,6 +313,18 @@ class NocStorage {
279313 */
280314 const NocLink& get_single_noc_link (NocLinkId id) const ;
281315
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+
282328 /* *
283329 * @brief Given source and sink router identifiers, this function
284330 * finds a link connecting these routers and returns its identifier.
@@ -292,7 +338,7 @@ class NocStorage {
292338 * to the destination router. NocLinkId::INVALID() is such a link is not
293339 * found.
294340 */
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 ;
296342
297343 /* *
298344 * @brief Given a unique link identifier, get the corresponding link
@@ -376,7 +422,7 @@ class NocStorage {
376422
377423 void set_device_grid_spec (int grid_width, int grid_height);
378424
379- // general utiliy functions
425+ // general utility functions
380426 /* *
381427 * @brief The link is removed from the outgoing vector of links for
382428 * the source router. The link is not removed from the vector of all
@@ -404,6 +450,14 @@ class NocStorage {
404450 * NoC (routers and links cannot be added or removed). This function
405451 * should be called after building the NoC. Guarantees that
406452 * 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.
407461 *
408462 */
409463 void finished_building_noc ();
@@ -495,4 +549,18 @@ class NocStorage {
495549 void echo_noc (char * file_name) const ;
496550};
497551
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