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;
49 static constexpr size_t stack_buf_size = 32768;
51 uint8_t stack_buf[stack_buf_size];
53 FMPmr::monotonic_buffer_resource rsrc;
72 : hyprgraph{hyprgraph},
73 vertex_list(hyprgraph.number_of_modules()),
74 init_gain_list(hyprgraph.number_of_modules(), 0),
75 rsrc(stack_buf, sizeof stack_buf),
77 for (
const auto& v : this->hyprgraph) {
78 this->vertex_list[v].data = std::make_pair(v, uint32_t(0));
92 auto init(std::span<const std::uint8_t> part) ->
int {
94 for (
auto& vlink : this->vertex_list) {
95 vlink.data.second = 0U;
97 for (
auto& elem : this->init_gain_list) {
100 for (
const auto& net : this->hyprgraph.nets) {
101 this->_init_gain(net, part);
103 return this->total_cost;
174 auto _modify_gain(
const node_t& w,
int weight) ->
void {
176 this->init_gain_list[w] += weight;
188 auto _increase_gain(
const node_t& w, uint32_t weight) ->
void {
190 this->init_gain_list[w] += weight;
202 auto _decrease_gain(
const node_t& w, uint32_t weight) ->
void {
204 this->init_gain_list[w] -= weight;
216 auto _init_gain(
const node_t& net, std::span<const std::uint8_t> part) -> void;
227 auto _init_gain_2pin_net(
const node_t& net, std::span<const std::uint8_t> part) -> void;
238 auto _init_gain_3pin_net(
const node_t& net, std::span<const std::uint8_t> part) -> void;
249 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:71
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:109
auto update_move_3pin_net(std::span< const std::uint8_t > part, const MoveInfo< node_t > &move_info) -> std::vector< int >
Update the gain values for a 3-pin net during a move operation.
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:61
const auto & get_init_gain_list() const
Expose initial gain list for read-only use.
Definition FMBiGainCalc.hpp:64
auto update_move_general_net(std::span< const std::uint8_t > part, const MoveInfo< node_t > &move_info) -> std::vector< int >
Update the gain values for a general net during a move operation.
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:57
FMPmr::vector< node_t > idx_vec
Index vector for net vertex enumeration.
Definition FMBiGainCalc.hpp:59
auto init(std::span< const std::uint8_t > part) -> int
Initializes the FMBiGainCalc object.
Definition FMBiGainCalc.hpp:92
typename Gnl::node_t node_t
Definition FMBiGainCalc.hpp:36
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