|
6 | 6 |
|
7 | 7 | /**
|
8 | 8 | * @brief Abstract class whose children are HeapInterface implementations of a k-ary minheap.
|
9 |
| - * |
10 |
| - * @details |
11 |
| - * Currently, KAryHeap's two children are BinaryHeap and FourAryHeap. On small circuits, these |
12 |
| - * heaps have negligible differences in runtime, but on larger heaps, runtime is lower when |
13 |
| - * using FourAryHeap. On titan benchmarks, the runtime is ~1.8% better on FourAryHeap compared |
14 |
| - * to BinaryHeap. This is likely because FourAryHeap is more cache friendly, as we can fit 5 |
15 |
| - * heap_elem on a cache line. |
16 | 9 | */
|
17 | 10 | class KAryHeap : public HeapInterface {
|
18 | 11 | public:
|
@@ -48,12 +41,14 @@ class KAryHeap : public HeapInterface {
|
48 | 41 | * @param elem_ptr A pointer to the t_heap struct which contains all
|
49 | 42 | * the node's information.
|
50 | 43 | * @param cost The cost of the node.
|
51 |
| - */ |
52 |
| - /* TODO: We are currently storing the node cost in two places (in elem_ptr->cost and cost). This might be fixed in two ways: |
53 |
| - * 1. Don't store the cost in t_heap. |
| 44 | + * |
| 45 | + * @todo |
| 46 | + * We are currently storing the node cost in two places (in elem_ptr->cost and cost). This might be fixed in two ways:<BR> |
| 47 | + * 1. Don't store the cost in t_heap.<BR> |
54 | 48 | * 2. Instead of using pointers, use a 32-bit ID. If we do this, we can create a new 8-ary heap, which is likely to be even
|
55 | 49 | * faster as we can fit more heap_elem on one cache line (currently, we can fit 5 as heap_elem is 12 bytes), even with more
|
56 |
| - * comparisons.*/ |
| 50 | + * comparisons. |
| 51 | + */ |
57 | 52 | struct heap_elem {
|
58 | 53 | t_heap* elem_ptr;
|
59 | 54 | float cost;
|
@@ -110,11 +105,14 @@ class KAryHeap : public HeapInterface {
|
110 | 105 | HeapStorage storage_;
|
111 | 106 |
|
112 | 107 | /**
|
| 108 | + * @details |
113 | 109 | * heap_ is indexed from [1..heap_size]; the 0th element is unused. For BinaryHeap, this simplifies
|
114 | 110 | * arithmetic in left() and parent() functions. Using a heap beginning at index 0 would simplify
|
115 | 111 | * first_child() and parent() functions in FourAryHeap, but this does not improve runtime.
|
| 112 | + * |
| 113 | + * @todo |
| 114 | + * If an 8-ary heap is implemented, experiment with starting at index 0 |
116 | 115 | */
|
117 |
| - /* TODO: If an 8-ary heap is implemented, experiment with starting at index 0 */ |
118 | 116 | std::vector<heap_elem> heap_;
|
119 | 117 |
|
120 | 118 | size_t heap_size_; /* Number of slots in the heap array */
|
|
0 commit comments