CkPttn 1.2.4
Loading...
Searching...
No Matches
FMKWayGainMgr.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include <span>
9
10#include "FMGainMgr.hpp"
11#include "FMKWayGainCalc.hpp"
12
13// forward declare
14template <typename Node> struct MoveInfo;
15template <typename Node> struct MoveInfoV;
16
26template <typename Gnl> class FMKWayGainMgr
27 : public FMGainMgr<Gnl, FMKWayGainCalc<Gnl>, FMKWayGainMgr<Gnl>> {
28 private:
30 fun::Robin<std::uint8_t> rr;
31
32 public:
35 using node_t = typename Gnl::node_t;
36
43 FMKWayGainMgr(const Gnl& hyprgraph, std::uint8_t num_parts)
45
52 auto init(std::span<const std::uint8_t> part) -> int;
53
62 auto modify_key(const node_t& w, std::uint8_t part_w, std::span<const int> keys) -> void {
63 for (auto k : this->rr.exclude(part_w)) {
64 auto& item = this->gain_calc.vertex_list[k][w];
65 if (item.is_locked()) {
66 continue;
67 }
68 this->gain_bucket[k].modify_key(item, keys[k]);
69 }
70 }
71
78 auto update_move_v(const MoveInfoV<node_t>& move_info_v, int gain) -> void;
79
86 auto lock(uint8_t whichPart, const node_t& v) -> void {
87 auto& vlink = this->gain_calc.vertex_list[whichPart][v];
88 this->gain_bucket[whichPart].detach(vlink);
89 vlink.lock();
90 }
91
97 auto lock_all(uint8_t /*from_part*/, const node_t& v) -> void {
98 // for (const auto& [vlist, bckt] :
99 // views::zip(this->gain_calc.vertex_list, this->gain_bucket))
100 auto bckt_it = this->gain_bucket.begin();
101 for (auto& vlist : this->gain_calc.vertex_list) {
102 auto& vlink = vlist[v];
103 bckt_it->detach(vlink);
104 vlink.lock(); // lock
105 ++bckt_it;
106 }
107 }
108
109 private:
117 auto _set_key(uint8_t whichPart, const node_t& v, int key) -> void {
118 this->gain_bucket[whichPart].set_key(this->gain_calc.vertex_list[whichPart][v], key);
119 }
120};
CRTP base class for FM gain management.
K-way FM gain calculator.
Fiduccia-Mattheyses Gain Manager.
Definition FMGainMgr.hpp:32
std::uint8_t num_parts
Number of partitions.
Definition FMGainMgr.hpp:45
const Gnl & hyprgraph
Reference to the hypergraph being partitioned.
Definition FMGainMgr.hpp:41
FMKWayGainCalc< Gnl > gain_calc
Gain calculator instance.
Definition FMGainMgr.hpp:49
std::vector< BPQueue< node_t > > gain_bucket
Gain buckets for each partition (used in bucket-based gain management)
Definition FMGainMgr.hpp:43
K-Way Fiduccia-Mattheyses Gain Calculator.
Definition FMKWayGainCalc.hpp:33
K-Way Fiduccia-Mattheyses Gain Manager.
Definition FMKWayGainMgr.hpp:27
auto update_move_v(const MoveInfoV< node_t > &move_info_v, int gain) -> void
Updates the move information for a vertex.
auto init(std::span< const std::uint8_t > part) -> int
Initializes the gain manager with the given partition information.
auto lock(uint8_t whichPart, const node_t &v) -> void
Locks the vertex link for the given partition and vertex.
Definition FMKWayGainMgr.hpp:86
auto modify_key(const node_t &w, std::uint8_t part_w, std::span< const int > keys) -> void
Modifies the key for the given vertex in the gain buckets for all partitions except the given one.
Definition FMKWayGainMgr.hpp:62
auto lock_all(uint8_t, const node_t &v) -> void
Locks the vertex link for the given vertex in all partitions.
Definition FMKWayGainMgr.hpp:97
typename Gnl::node_t node_t
Definition FMKWayGainMgr.hpp:35
FMKWayGainMgr(const Gnl &hyprgraph, std::uint8_t num_parts)
Constructs a new FMKWayGainMgr object.
Definition FMKWayGainMgr.hpp:43
Move information for a single vertex (without net reference)
Definition moveinfo.hpp:37
Move information for a single vertex in a net.
Definition moveinfo.hpp:18