CkPttn 1.2.4
Loading...
Searching...
No Matches
FMGainMgr.hpp
Go to the documentation of this file.
1
6#pragma once
7
8// #include <algorithm> // for all_of
9#include <cstdint> // for uint8_t
10#include <mywheel/bpqueue.hpp> // for BPQueue
11#include <mywheel/dllist.hpp> // for Dllink
12#include <span> // for span
13// #include <tuple> // for tuple
14#include <utility> // for pair
15#include <vector> // for vector<>::const_iterator, vector
16
17template <typename Node> struct MoveInfo;
18template <typename Node> struct MoveInfoV;
19
32template <typename Gnl, typename GainCalc, class Derived> class FMGainMgr {
33 Derived& self = *static_cast<Derived*>(this);
34 using node_t = typename Gnl::node_t;
35 using Item = Dllink<std::pair<node_t, uint32_t>>;
36
37 protected:
39 Dllist<std::pair<node_t, uint32_t>> waiting_list{std::make_pair(node_t{}, uint32_t(0))};
41 const Gnl& hyprgraph;
43 std::vector<BPQueue<node_t>> gain_bucket;
45 std::uint8_t num_parts;
46
47 public:
49 GainCalc gain_calc;
50
51 // int total_cost;
52
53 // FMGainMgr(FMGainMgr&&) = default;
54
61 FMGainMgr(const Gnl& hyprgraph, std::uint8_t num_parts);
62
69 auto init(std::span<const std::uint8_t> part) -> int;
70
78 auto is_empty_togo(uint8_t to_part) const -> bool {
79 return this->gain_bucket[to_part].is_empty();
80 }
81
88 auto is_empty() const -> bool;
89
99 auto select(std::span<const std::uint8_t> part) -> std::pair<MoveInfoV<node_t>, int>;
100
108 auto select_togo(uint8_t to_part) -> std::pair<node_t, int>;
109
116 auto update_move(std::span<const std::uint8_t> part, const MoveInfoV<node_t>& move_info_v)
117 -> void;
118
119 private:
126 auto _update_move_2pin_net(std::span<const std::uint8_t> part,
127 const MoveInfo<node_t>& move_info) -> void;
128
135 auto _update_move_3pin_net(std::span<const std::uint8_t> part,
136 const MoveInfo<node_t>& move_info) -> void;
137
144 auto _update_move_general_net(std::span<const std::uint8_t> part,
145 const MoveInfo<node_t>& move_info) -> void;
146};
Fiduccia-Mattheyses Gain Manager.
Definition FMGainMgr.hpp:32
auto is_empty_togo(uint8_t to_part) const -> bool
Checks if the gain bucket for the given partition is empty.
Definition FMGainMgr.hpp:78
auto update_move(std::span< const std::uint8_t > part, const MoveInfoV< node_t > &move_info_v) -> void
Updates the gain information for the given set of moves.
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
GainCalc gain_calc
Gain calculator instance.
Definition FMGainMgr.hpp:49
Dllist< std::pair< node_t, uint32_t > > waiting_list
Waiting list for vertices awaiting movement.
Definition FMGainMgr.hpp:39
std::vector< BPQueue< node_t > > gain_bucket
Gain buckets for each partition (used in bucket-based gain management)
Definition FMGainMgr.hpp:43
auto init(std::span< const std::uint8_t > part) -> int
Initializes the FMGainMgr with the given partition information.
auto select(std::span< const std::uint8_t > part) -> std::pair< MoveInfoV< node_t >, int >
Selects a vertex to move and computes the associated gain.
auto select_togo(uint8_t to_part) -> std::pair< node_t, int >
Selects a node to move to the given partition.
auto is_empty() const -> bool
Checks if all the gain buckets are empty.
FMGainMgr(const Gnl &hyprgraph, std::uint8_t num_parts)
Constructs a new FMGainMgr object.
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