Skip to content

Commit 875b98e

Browse files
[ParallelRouter] Removed Boost from FG Parallel Router
The original FG parallel router used to use boost. VTR does not install boost by default. Moved to STL instead.
1 parent fd2797f commit 875b98e

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

vpr/src/route/multi_queue_d_ary_heap.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
#ifndef _MULTI_QUEUE_D_ARY_HEAP_H
2121
#define _MULTI_QUEUE_D_ARY_HEAP_H
2222

23-
#include <vector>
24-
23+
#include <tuple>
2524
#include "device_grid.h"
2625
#include "heap_type.h"
2726
#include "multi_queue_d_ary_heap.tpp"
@@ -59,11 +58,11 @@ class MultiQueueDAryHeap {
5958

6059
bool try_pop(HeapNode& heap_node) {
6160
auto tmp = pq_->tryPop();
62-
if (!tmp) {
61+
if (!tmp.has_value()) {
6362
return false;
6463
} else {
6564
uint32_t node_id;
66-
std::tie(heap_node.prio, node_id) = tmp.get(); // FIXME: eliminate type cast by modifying MQ_IO
65+
std::tie(heap_node.prio, node_id) = tmp.value(); // FIXME: eliminate type cast by modifying MQ_IO
6766
heap_node.node = RRNodeId(node_id);
6867
return true;
6968
}
@@ -124,4 +123,4 @@ class MultiQueueDAryHeap {
124123
};
125124

126125

127-
#endif
126+
#endif

vpr/src/route/multi_queue_d_ary_heap.tpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,11 @@
2222
#include <cstdlib>
2323
#include <iostream>
2424
#include <limits>
25-
#include <tuple>
25+
#include <optional>
2626
#include <vector>
2727
#include <algorithm>
28-
#include <mutex>
29-
#include <queue>
30-
#include <random>
3128
#include <atomic>
3229
#include <cassert>
33-
#include <boost/optional.hpp>
34-
#include <boost/align/aligned_allocator.hpp>
3530
#include "d_ary_heap.tpp"
3631

3732
#define CACHELINE 64
@@ -68,8 +63,12 @@ class MultiQueueIO {
6863
} __attribute__((aligned (CACHELINE)));
6964

7065
std::vector<
71-
PQContainer,
72-
boost::alignment::aligned_allocator<PQContainer, CACHELINE>
66+
PQContainer
67+
// FIXME: Disabled this due to VTR not using Boost. There is a C++ way
68+
// of doing this, but it requires making an aligned allocator
69+
// class. May be a good idea to add to VTR util in the future.
70+
// Should profile for performance first; may not be worth it.
71+
// , boost::alignment::aligned_allocator<PQContainer, CACHELINE>
7372
> queues;
7473
uint64_t NUM_QUEUES;
7574

@@ -181,7 +180,7 @@ class MultiQueueIO {
181180
#ifdef PERF
182181
boost::optional<PQElement> __attribute__ ((noinline)) tryPop() {
183182
#else
184-
inline boost::optional<PQElement> tryPop() {
183+
inline std::optional<PQElement> tryPop() {
185184
#endif
186185
auto item = pop();
187186
if (item) return item;
@@ -191,7 +190,7 @@ class MultiQueueIO {
191190
do {
192191
item = pop();
193192
if (item) break;
194-
if (num >= threadNum) return boost::none;
193+
if (num >= threadNum) return {};
195194

196195
num = numIdle.load(std::memory_order_relaxed);
197196

@@ -212,7 +211,7 @@ class MultiQueueIO {
212211
#ifdef PERF
213212
boost::optional<PQElement> __attribute__ ((noinline)) pop() {
214213
#else
215-
inline boost::optional<PQElement> pop() {
214+
inline std::optional<PQElement> pop() {
216215
#endif
217216
uint64_t poppingQueue = NUM_QUEUES;
218217
while (true) {
@@ -270,13 +269,13 @@ class MultiQueueIO {
270269
}
271270
q.unlock();
272271
}
273-
return boost::none;
272+
return {};
274273
}
275274

276275
#ifdef PERF
277276
boost::optional<uint64_t> __attribute__ ((noinline)) tryPopBatch(PQElement* ret) {
278277
#else
279-
inline boost::optional<uint64_t> tryPopBatch(PQElement* ret) {
278+
inline std::optional<uint64_t> tryPopBatch(PQElement* ret) {
280279
#endif
281280
auto item = popBatch(ret);
282281
if (item) return item;
@@ -286,7 +285,7 @@ class MultiQueueIO {
286285
do {
287286
item = popBatch(ret);
288287
if (item) break;
289-
if (num >= threadNum) return boost::none;
288+
if (num >= threadNum) return {};
290289

291290
num = numIdle.load(std::memory_order_relaxed);
292291

@@ -308,7 +307,7 @@ class MultiQueueIO {
308307
#ifdef PERF
309308
boost::optional<uint64_t> __attribute__ ((noinline)) popBatch(PQElement* ret) {
310309
#else
311-
inline boost::optional<uint64_t> popBatch(PQElement* ret) {
310+
inline std::optional<uint64_t> popBatch(PQElement* ret) {
312311
#endif
313312
uint64_t poppingQueue = NUM_QUEUES;
314313
while (true) {
@@ -367,7 +366,7 @@ class MultiQueueIO {
367366

368367
return num;
369368
}
370-
return boost::none;
369+
return {};
371370
}
372371

373372
inline uint64_t getQueueOccupancy() const {

0 commit comments

Comments
 (0)