Skip to content

Commit 599e06e

Browse files
committed
[Router] No Pointer in DAryHeap to Make ParallelNetlistRouter Happy
Replaced the pointer (dynamic memory allocations) of the priority queue in d_ary_heap.h with the priority queue object in order to make the coarse-grained parallel netlist router happy. Previously, when using pointers, as in commit 084fb54, the parallel netlist router would always throw weird double-free errors. After debugging with GDB and Valgrind, it appeared that the issues came from the Intel OneTBB deallocation process. However, there is no convincing evidence of the problems.
1 parent 084fb54 commit 599e06e

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

vpr/src/route/d_ary_heap.h

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,29 @@ class DAryHeap : public HeapInterface {
2323
public:
2424
using priority_queue = customized_d_ary_priority_queue<D, HeapNode, std::vector<HeapNode>, HeapNodeComparator>;
2525

26-
DAryHeap() {
27-
pq_ = new priority_queue();
28-
}
29-
30-
~DAryHeap() {
31-
delete pq_;
32-
}
26+
DAryHeap() {}
3327

3428
void init_heap(const DeviceGrid& grid) {
3529
size_t target_heap_size = (grid.width() - 1) * (grid.height() - 1);
36-
pq_->reserve(target_heap_size); // reserve the memory for the heap structure
30+
pq_.reserve(target_heap_size); // reserve the memory for the heap structure
3731
}
3832

3933
bool try_pop(HeapNode& heap_node) {
40-
if (pq_->empty()) {
34+
if (pq_.empty()) {
4135
return false;
4236
} else {
43-
heap_node = pq_->top();
44-
pq_->pop();
37+
heap_node = pq_.top();
38+
pq_.pop();
4539
return true;
4640
}
4741
}
4842

4943
void add_to_heap(const HeapNode& heap_node) {
50-
pq_->push(heap_node);
44+
pq_.push(heap_node);
5145
}
5246

5347
void push_back(const HeapNode& heap_node) {
54-
pq_->push(heap_node); // FIXME: add to heap without maintaining the heap property
48+
pq_.push(heap_node); // FIXME: add to heap without maintaining the heap property
5549
}
5650

5751
void build_heap() {
@@ -63,15 +57,15 @@ class DAryHeap : public HeapInterface {
6357
}
6458

6559
void empty_heap() {
66-
pq_->clear();
60+
pq_.clear();
6761
}
6862

6963
bool is_empty_heap() const {
70-
return (bool)(pq_->empty());
64+
return (bool)(pq_.empty());
7165
}
7266

7367
private:
74-
priority_queue* pq_;
68+
priority_queue pq_;
7569
};
7670

7771
using BinaryHeap = DAryHeap<2>;

0 commit comments

Comments
 (0)