:github_url: https://github.com/svenevs/exhale-companion .. _program_listing_file_ckpttncpp_FMKWayGainCalc.hpp: Program Listing for File FMKWayGainCalc.hpp =========================================== |exhale_lsh| :ref:`Return to documentation for file ` (``ckpttncpp/FMKWayGainCalc.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #pragma once #include "FMPmrConfig.hpp" #include "dllist.hpp" // import dllink #include "netlist.hpp" // import Netlist #include "robin.hpp" // import robin #include // class FMKWayGainMgr; class FMKWayGainCalc { friend class FMKWayGainMgr; using node_t = typename SimpleNetlist::node_t; using Item = dllink>; private: const SimpleNetlist& H; std::uint8_t K; robin RR; // size_t num_modules; int totalcost {0}; std::byte StackBuf[20000]; FMPmr::monotonic_buffer_resource rsrc; std::vector> vertex_list; FMPmr::vector deltaGainV; public: FMPmr::vector deltaGainW; FMPmr::vector IdVec; bool special_handle_2pin_nets {true}; // @TODO should be template parameter FMKWayGainCalc(const SimpleNetlist& H, std::uint8_t K) : H {H} , K {K} , RR {K} , rsrc(StackBuf, sizeof StackBuf) , vertex_list {} , deltaGainV(K, 0, &rsrc) , deltaGainW(K, 0, &rsrc) , IdVec(&rsrc) { for (auto k = 0U; k != this->K; ++k) { auto vec = std::vector{}; vec.reserve(H.number_of_modules()); for (const auto& v : this->H) { vec.emplace_back(Item(std::pair {v, uint32_t(0)})); } this->vertex_list.emplace_back(std::move(vec)); } } // /*! // * @brief // * // * @param[in] toPart // * @return dllink* // */ // auto start_ptr(uint8_t toPart) -> dllink>* // { // return &this->vertex_list[toPart][0]; // } auto init(gsl::span part) -> int { this->totalcost = 0; for (auto& vec : this->vertex_list) { for (auto& vlink : vec) { vlink.data.second = 0U; } } for (const auto& net : this->H.nets) { this->_init_gain(net, part); } return this->totalcost; } auto update_move_init() -> void { std::fill(this->deltaGainV.begin(), this->deltaGainV.end(), 0); } auto update_move_2pin_net(gsl::span part, const MoveInfo& move_info) -> node_t; void init_IdVec(const node_t& v, const node_t& net); using ret_info = std::vector>; auto update_move_3pin_net(gsl::span part, const MoveInfo& move_info) -> ret_info; auto update_move_general_net(gsl::span part, const MoveInfo& move_info) -> ret_info; private: auto _modify_gain(const node_t& v, std::uint8_t part_v, unsigned int weight) -> void { for (const auto& k : this->RR.exclude(part_v)) { this->vertex_list[k][v].data.second += weight; } } template auto _modify_vertex_va(unsigned int weight, std::uint8_t k, Ts... v) -> void { ((this->vertex_list[k][v].data.second += weight), ...); } // /** // * @brief // * // * @tparam Ts // * @param weight // * @param part_v // * @param v // */ // auto _modify_vertex_va(unsigned int weight, std::uint8_t k, const node_t& v1) -> // void // { // this->vertex_list[k][v1].data.second += weight; // } // /** // * @brief // * // * @tparam Ts // * @param weight // * @param part_v // * @param v // */ // auto _modify_vertex_va( // unsigned int weight, std::uint8_t k, const node_t& v1, const node_t& v2) -> // void // { // this->vertex_list[k][v1].data.second += weight; // this->vertex_list[k][v2].data.second += weight; // } // /** // * @brief // * // * @tparam Ts // * @param weight // * @param part_v // * @param v // */ // auto _modify_vertex_va(unsigned int weight, std::uint8_t k, const node_t& v1, // const node_t& v2, const node_t& v3) -> void // { // this->vertex_list[k][v1].data.second += weight; // this->vertex_list[k][v2].data.second += weight; // this->vertex_list[k][v3].data.second += weight; // } template auto _modify_gain_va(unsigned int weight, std::uint8_t part_v, Ts... v) -> void { for (const auto& k : this->RR.exclude(part_v)) { _modify_vertex_va(weight, k, v...); } } auto _init_gain(const node_t& net, gsl::span part) -> void; auto _init_gain_2pin_net( const node_t& net, gsl::span part) -> void; auto _init_gain_3pin_net( const node_t& net, gsl::span part) -> void; auto _init_gain_general_net( const node_t& net, gsl::span part) -> void; };