diff options
author | couriersud <couriersud@gmx.org> | 2019-11-26 00:47:05 +0100 |
---|---|---|
committer | couriersud <couriersud@gmx.org> | 2019-11-26 00:47:05 +0100 |
commit | 6c181d7adb16227621329ee687b5f0cf95b6336e (patch) | |
tree | 2744961bbd37ade06cb012267a5dd37fa7e2d235 /src/lib | |
parent | c50bf9a698c8dc3e99ab6f703fc8bb9d1da41ad6 (diff) |
netlist: Change visibility to private for some members. [Couriersud]
Interesting observation to note: since MAME 208 bench 30 results for
pongf increased from 450% to 580%.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/netlist/solver/nld_matrix_solver.cpp | 6 | ||||
-rw-r--r-- | src/lib/netlist/solver/nld_matrix_solver.h | 216 | ||||
-rw-r--r-- | src/lib/netlist/solver/nld_ms_direct.h | 1 | ||||
-rw-r--r-- | src/lib/netlist/solver/nld_ms_direct2.h | 1 | ||||
-rw-r--r-- | src/lib/netlist/solver/nld_ms_gcr.h | 2 | ||||
-rw-r--r-- | src/lib/netlist/solver/nld_ms_gmres.h | 1 | ||||
-rw-r--r-- | src/lib/netlist/solver/nld_ms_sm.h | 1 | ||||
-rw-r--r-- | src/lib/netlist/solver/nld_ms_sor.h | 1 | ||||
-rw-r--r-- | src/lib/netlist/solver/nld_ms_sor_mat.h | 1 | ||||
-rw-r--r-- | src/lib/netlist/solver/nld_ms_w.h | 1 |
10 files changed, 112 insertions, 119 deletions
diff --git a/src/lib/netlist/solver/nld_matrix_solver.cpp b/src/lib/netlist/solver/nld_matrix_solver.cpp index 0f3b5cf2128..679632cfc15 100644 --- a/src/lib/netlist/solver/nld_matrix_solver.cpp +++ b/src/lib/netlist/solver/nld_matrix_solver.cpp @@ -40,11 +40,11 @@ namespace solver const solver_parameters_t *params) : device_t(anetlist, name) , m_params(*params) + , m_iterative_fail(*this, "m_iterative_fail", 0) + , m_iterative_total(*this, "m_iterative_total", 0) , m_stat_calculations(*this, "m_stat_calculations", 0) , m_stat_newton_raphson(*this, "m_stat_newton_raphson", 0) , m_stat_vsolver_calls(*this, "m_stat_vsolver_calls", 0) - , m_iterative_fail(*this, "m_iterative_fail", 0) - , m_iterative_total(*this, "m_iterative_total", 0) , m_last_step(*this, "m_last_step", netlist_time::zero()) , m_fb_sync(*this, "FB_sync") , m_Q_sync(*this, "Q_sync") @@ -419,6 +419,7 @@ namespace solver { update_dynamic(); // Gauss-Seidel will revert to Gaussian elemination if steps exceeded. + this->m_stat_calculations++; this_resched = this->vsolve_non_dynamic(true); newton_loops++; } while (this_resched > 1 && newton_loops < m_params.m_nr_loops); @@ -433,6 +434,7 @@ namespace solver } else { + this->m_stat_calculations++; this->vsolve_non_dynamic(false); } diff --git a/src/lib/netlist/solver/nld_matrix_solver.h b/src/lib/netlist/solver/nld_matrix_solver.h index 3065cd55afa..f1a4cf928ab 100644 --- a/src/lib/netlist/solver/nld_matrix_solver.h +++ b/src/lib/netlist/solver/nld_matrix_solver.h @@ -195,11 +195,6 @@ namespace solver NETLIB_UPDATEI(); NETLIB_RESETI(); - public: - int get_net_idx(const analog_net_t *net) const noexcept; - std::pair<int, int> get_left_right_of_diag(std::size_t irow, std::size_t idiag); - nl_fptype get_weight_around_diag(std::size_t row, std::size_t diag); - virtual void log_stats(); virtual std::pair<pstring, pstring> create_solver_code() @@ -216,22 +211,58 @@ namespace solver const analog_net_t::list_t &nets, const solver_parameters_t *params); + virtual unsigned vsolve_non_dynamic(const bool newton_raphson) = 0; + virtual netlist_time compute_next_timestep(const nl_fptype cur_ts) = 0; + + template <typename T> + using aligned_alloc = plib::aligned_allocator<T, PALIGN_VECTOROPT>; + + plib::pmatrix2d<nl_fptype, aligned_alloc<nl_fptype>> m_gonn; + plib::pmatrix2d<nl_fptype, aligned_alloc<nl_fptype>> m_gtn; + plib::pmatrix2d<nl_fptype, aligned_alloc<nl_fptype>> m_Idrn; + plib::pmatrix2d<nl_fptype *, aligned_alloc<nl_fptype *>> m_connected_net_Vn; + + plib::aligned_vector<terms_for_net_t> m_terms; + + const solver_parameters_t &m_params; + + state_var<std::size_t> m_iterative_fail; + state_var<std::size_t> m_iterative_total; + + private: + + plib::aligned_vector<terms_for_net_t> m_rails_temp; + std::vector<unique_pool_ptr<proxied_analog_output_t>> m_inps; + + state_var<std::size_t> m_stat_calculations; + state_var<std::size_t> m_stat_newton_raphson; + state_var<std::size_t> m_stat_vsolver_calls; + + state_var<netlist_time> m_last_step; + std::vector<core_device_t *> m_step_devices; + std::vector<core_device_t *> m_dynamic_devices; + + logic_input_t m_fb_sync; + logic_output_t m_Q_sync; + + std::size_t m_ops; + + // base setup - called from constructor + void setup_base(const analog_net_t::list_t &nets); + void sort_terms(matrix_sort_type_e sort); void update_dynamic(); + void step(const netlist_time &delta); - virtual unsigned vsolve_non_dynamic(const bool newton_raphson) = 0; - virtual netlist_time compute_next_timestep(const nl_fptype cur_ts) = 0; + int get_net_idx(const analog_net_t *net) const noexcept; + std::pair<int, int> get_left_right_of_diag(std::size_t irow, std::size_t idiag); + nl_fptype get_weight_around_diag(std::size_t row, std::size_t diag); void add_term(std::size_t net_idx, terminal_t *term); - std::size_t max_railstart() const noexcept - { - std::size_t max_rail = 0; - for (std::size_t k = 0; k < m_terms.size(); k++) - max_rail = std::max(max_rail, m_terms[k].railstart()); - return max_rail; - } + // calculate matrix + void setup_matrix(); void set_pointers() { @@ -262,100 +293,6 @@ namespace solver } } - - template <typename T, typename M> - void log_fill(const T &fill, M &mat) - { - const std::size_t iN = fill.size(); - - // FIXME: Not yet working, mat_cr.h needs some more work -#if 0 - auto mat_GE = dynamic_cast<plib::pGEmatrix_cr_t<typename M::base> *>(&mat); -#else - plib::unused_var(mat); -#endif - std::vector<unsigned> levL(iN, 0); - std::vector<unsigned> levU(iN, 0); - - // parallel scheme for L x = y - for (std::size_t k = 0; k < iN; k++) - { - unsigned lm=0; - for (std::size_t j = 0; j<k; j++) - if (fill[k][j] < M::FILL_INFINITY) - lm = std::max(lm, levL[j]); - levL[k] = 1+lm; - } - - // parallel scheme for U x = y - for (std::size_t k = iN; k-- > 0; ) - { - unsigned lm=0; - for (std::size_t j = iN; --j > k; ) - if (fill[k][j] < M::FILL_INFINITY) - lm = std::max(lm, levU[j]); - levU[k] = 1+lm; - } - for (std::size_t k = 0; k < iN; k++) - { - unsigned fm = 0; - pstring ml = ""; - for (std::size_t j = 0; j < iN; j++) - { - ml += fill[k][j] == 0 ? 'X' : fill[k][j] < M::FILL_INFINITY ? '+' : '.'; - if (fill[k][j] < M::FILL_INFINITY) - if (fill[k][j] > fm) - fm = fill[k][j]; - } -#if 0 - this->log().verbose("{1:4} {2} {3:4} {4:4} {5:4} {6:4}", k, ml, - levL[k], levU[k], mat_GE ? mat_GE->get_parallel_level(k) : 0, fm); -#else - this->log().verbose("{1:4} {2} {3:4} {4:4} {5:4} {6:4}", k, ml, - levL[k], levU[k], 0, fm); -#endif - } - } - - template <typename T> - using aligned_alloc = plib::aligned_allocator<T, PALIGN_VECTOROPT>; - - plib::pmatrix2d<nl_fptype, aligned_alloc<nl_fptype>> m_gonn; - plib::pmatrix2d<nl_fptype, aligned_alloc<nl_fptype>> m_gtn; - plib::pmatrix2d<nl_fptype, aligned_alloc<nl_fptype>> m_Idrn; - plib::pmatrix2d<nl_fptype *, aligned_alloc<nl_fptype *>> m_connected_net_Vn; - - plib::aligned_vector<terms_for_net_t> m_terms; - plib::aligned_vector<terms_for_net_t> m_rails_temp; - - std::vector<unique_pool_ptr<proxied_analog_output_t>> m_inps; - - const solver_parameters_t &m_params; - - state_var<int> m_stat_calculations; - state_var<int> m_stat_newton_raphson; - state_var<int> m_stat_vsolver_calls; - state_var<int> m_iterative_fail; - state_var<int> m_iterative_total; - - private: - - state_var<netlist_time> m_last_step; - std::vector<core_device_t *> m_step_devices; - std::vector<core_device_t *> m_dynamic_devices; - - logic_input_t m_fb_sync; - logic_output_t m_Q_sync; - - // base setup - called from constructor - void setup_base(const analog_net_t::list_t &nets); - - // calculate matrix - void setup_matrix(); - - void step(const netlist_time &delta); - - std::size_t m_ops; }; template <typename FT, int SIZE> @@ -411,6 +348,69 @@ namespace solver PALIGNAS_VECTOROPT() plib::parray<nl_fptype, SIZE> m_h_n_m_1; + std::size_t max_railstart() const noexcept + { + std::size_t max_rail = 0; + for (std::size_t k = 0; k < m_terms.size(); k++) + max_rail = std::max(max_rail, m_terms[k].railstart()); + return max_rail; + } + + + template <typename T, typename M> + void log_fill(const T &fill, M &mat) + { + const std::size_t iN = fill.size(); + + // FIXME: Not yet working, mat_cr.h needs some more work +#if 0 + auto mat_GE = dynamic_cast<plib::pGEmatrix_cr_t<typename M::base> *>(&mat); +#else + plib::unused_var(mat); +#endif + std::vector<unsigned> levL(iN, 0); + std::vector<unsigned> levU(iN, 0); + + // parallel scheme for L x = y + for (std::size_t k = 0; k < iN; k++) + { + unsigned lm=0; + for (std::size_t j = 0; j<k; j++) + if (fill[k][j] < M::FILL_INFINITY) + lm = std::max(lm, levL[j]); + levL[k] = 1+lm; + } + + // parallel scheme for U x = y + for (std::size_t k = iN; k-- > 0; ) + { + unsigned lm=0; + for (std::size_t j = iN; --j > k; ) + if (fill[k][j] < M::FILL_INFINITY) + lm = std::max(lm, levU[j]); + levU[k] = 1+lm; + } + for (std::size_t k = 0; k < iN; k++) + { + unsigned fm = 0; + pstring ml = ""; + for (std::size_t j = 0; j < iN; j++) + { + ml += fill[k][j] == 0 ? 'X' : fill[k][j] < M::FILL_INFINITY ? '+' : '.'; + if (fill[k][j] < M::FILL_INFINITY) + if (fill[k][j] > fm) + fm = fill[k][j]; + } +#if 0 + this->log().verbose("{1:4} {2} {3:4} {4:4} {5:4} {6:4}", k, ml, + levL[k], levU[k], mat_GE ? mat_GE->get_parallel_level(k) : 0, fm); +#else + this->log().verbose("{1:4} {2} {3:4} {4:4} {5:4} {6:4}", k, ml, + levL[k], levU[k], 0, fm); +#endif + } + } + constexpr std::size_t size() const noexcept { return (SIZE > 0) ? static_cast<std::size_t>(SIZE) : m_dim; diff --git a/src/lib/netlist/solver/nld_ms_direct.h b/src/lib/netlist/solver/nld_ms_direct.h index c72b08717ca..cd808c2ee3c 100644 --- a/src/lib/netlist/solver/nld_ms_direct.h +++ b/src/lib/netlist/solver/nld_ms_direct.h @@ -177,7 +177,6 @@ namespace solver this->clear_square_mat(m_A); this->fill_matrix_and_rhs(); - this->m_stat_calculations++; return this->solve_non_dynamic(newton_raphson); } diff --git a/src/lib/netlist/solver/nld_ms_direct2.h b/src/lib/netlist/solver/nld_ms_direct2.h index 7be8e006baf..3e2b9727776 100644 --- a/src/lib/netlist/solver/nld_ms_direct2.h +++ b/src/lib/netlist/solver/nld_ms_direct2.h @@ -47,7 +47,6 @@ namespace solver this->m_new_V[0] = v0; this->m_new_V[1] = v1; - this->m_stat_calculations++; bool err(false); if (newton_raphson) err = this->check_err(); diff --git a/src/lib/netlist/solver/nld_ms_gcr.h b/src/lib/netlist/solver/nld_ms_gcr.h index c3fdf9a4328..e72a645b33e 100644 --- a/src/lib/netlist/solver/nld_ms_gcr.h +++ b/src/lib/netlist/solver/nld_ms_gcr.h @@ -247,8 +247,6 @@ namespace solver mat.gaussian_back_substitution(this->m_new_V, this->m_RHS); } - this->m_stat_calculations++; - bool err(false); if (newton_raphson) err = this->check_err(); diff --git a/src/lib/netlist/solver/nld_ms_gmres.h b/src/lib/netlist/solver/nld_ms_gmres.h index 566a003110e..6900f7f8f28 100644 --- a/src/lib/netlist/solver/nld_ms_gmres.h +++ b/src/lib/netlist/solver/nld_ms_gmres.h @@ -115,7 +115,6 @@ namespace solver auto gsl = m_gmres.solve(m_ops, this->m_new_V, this->m_RHS, iter, accuracy); this->m_iterative_total += gsl; - this->m_stat_calculations++; if (gsl > iter) { diff --git a/src/lib/netlist/solver/nld_ms_sm.h b/src/lib/netlist/solver/nld_ms_sm.h index 481b957bf6c..c3aae29b798 100644 --- a/src/lib/netlist/solver/nld_ms_sm.h +++ b/src/lib/netlist/solver/nld_ms_sm.h @@ -289,7 +289,6 @@ namespace solver this->clear_square_mat(this->m_A); this->fill_matrix_and_rhs(); - this->m_stat_calculations++; return this->solve_non_dynamic(newton_raphson); } diff --git a/src/lib/netlist/solver/nld_ms_sor.h b/src/lib/netlist/solver/nld_ms_sor.h index 44669e5b6af..a5ac1fc7fc2 100644 --- a/src/lib/netlist/solver/nld_ms_sor.h +++ b/src/lib/netlist/solver/nld_ms_sor.h @@ -145,7 +145,6 @@ namespace solver } while (resched && (resched_cnt < this->m_params.m_gs_loops)); this->m_iterative_total += resched_cnt; - this->m_stat_calculations++; if (resched) { diff --git a/src/lib/netlist/solver/nld_ms_sor_mat.h b/src/lib/netlist/solver/nld_ms_sor_mat.h index 1e1f8aba071..68632b82be9 100644 --- a/src/lib/netlist/solver/nld_ms_sor_mat.h +++ b/src/lib/netlist/solver/nld_ms_sor_mat.h @@ -200,7 +200,6 @@ namespace solver resched_cnt++; } while (resched && (resched_cnt < this->m_params.m_gs_loops)); - this->m_stat_calculations++; this->m_iterative_total += resched_cnt; if (resched) diff --git a/src/lib/netlist/solver/nld_ms_w.h b/src/lib/netlist/solver/nld_ms_w.h index 07a4635d7dc..5a78b668e62 100644 --- a/src/lib/netlist/solver/nld_ms_w.h +++ b/src/lib/netlist/solver/nld_ms_w.h @@ -356,7 +356,6 @@ namespace solver this->clear_square_mat(this->m_A); this->fill_matrix_and_rhs(); - this->m_stat_calculations++; return this->solve_non_dynamic(newton_raphson); } |