10#include <mywheel/dllist.hpp>
20template <
typename Node>
struct MoveInfo;
37 using Item = Dllink<std::pair<node_t, uint32_t>>;
43 std::vector<Item> vertex_list;
45 std::vector<int> init_gain_list;
47 std::vector<int> delta_gain_buf;
51 static constexpr size_t stack_buf_size = 32768;
53 uint8_t stack_buf[stack_buf_size];
55 FMPmr::monotonic_buffer_resource rsrc;
74 : hyprgraph{hyprgraph},
75 vertex_list(hyprgraph.number_of_modules()),
76 init_gain_list(hyprgraph.number_of_modules(), 0),
77 rsrc(stack_buf, sizeof stack_buf),
79 for (
const auto& v : this->hyprgraph) {
80 this->vertex_list[v].data = std::make_pair(v, uint32_t(0));
94 auto init(std::span<const std::uint8_t> part) ->
int {
96 for (
auto& vlink : this->vertex_list) {
97 vlink.data.second = 0U;
99 for (
auto& elem : this->init_gain_list) {
102 for (
const auto& net : this->hyprgraph.nets) {
103 this->_init_gain(net, part);
105 return this->total_cost;
150 -> std::span<const int>;
176 auto _modify_gain(
const node_t& w,
int weight) ->
void {
178 this->init_gain_list[w] += weight;
190 auto _increase_gain(
const node_t& w, uint32_t weight) ->
void {
192 this->init_gain_list[w] += weight;
204 auto _decrease_gain(
const node_t& w, uint32_t weight) ->
void {
206 this->init_gain_list[w] -= weight;
218 auto _init_gain(
const node_t& net, std::span<const std::uint8_t> part) -> void;
229 auto _init_gain_2pin_net(
const node_t& net, std::span<const std::uint8_t> part) -> void;
240 auto _init_gain_3pin_net(
const node_t& net, std::span<const std::uint8_t> part) -> void;
251 auto _init_gain_general_net(
const node_t& net, std::span<const std::uint8_t> part) -> void;
PMR configuration and constants for FM algorithm.
Binary Fiduccia-Mattheyses Gain Calculator.
Definition FMBiGainCalc.hpp:32
FMBiGainCalc(const Gnl &hyprgraph, std::uint8_t)
Constructs a new FMBiGainCalc object.
Definition FMBiGainCalc.hpp:73
auto update_move_2pin_net(std::span< const std::uint8_t > part, const MoveInfo< node_t > &move_info) -> node_t
Update a 2-pin net during a move operation.
auto update_move_init() -> void
This function does nothing in 2-way partitioning.
Definition FMBiGainCalc.hpp:111
void init_idx_vec(const node_t &module, const node_t &net)
Initializes the index vector for a given vertex and net.
bool special_handle_2pin_nets
Whether to use special handling for 2-pin nets (optimization)
Definition FMBiGainCalc.hpp:63
auto update_move_general_net(std::span< const std::uint8_t > part, const MoveInfo< node_t > &move_info) -> std::span< const int >
Update the gain values for a general net during a move operation.
const auto & get_init_gain_list() const
Expose initial gain list for read-only use.
Definition FMBiGainCalc.hpp:66
Dllink< std::pair< node_t, uint32_t > > Item
Definition FMBiGainCalc.hpp:37
int delta_gain_w
Delta gain for the winning partition.
Definition FMBiGainCalc.hpp:59
FMPmr::vector< node_t > idx_vec
Index vector for net vertex enumeration.
Definition FMBiGainCalc.hpp:61
auto init(std::span< const std::uint8_t > part) -> int
Initializes the FMBiGainCalc object.
Definition FMBiGainCalc.hpp:94
typename Gnl::node_t node_t
Definition FMBiGainCalc.hpp:36
auto update_move_3pin_net(std::span< const std::uint8_t > part, const MoveInfo< node_t > &move_info) -> std::span< const int >
Update the gain values for a 3-pin net during a move operation.
Binary Fiduccia-Mattheyses Gain Manager.
Definition FMBiGainMgr.hpp:26
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