diff options
author | couriersud <couriersud@gmx.org> | 2019-01-30 02:28:55 +0100 |
---|---|---|
committer | couriersud <couriersud@gmx.org> | 2019-01-31 01:03:35 +0100 |
commit | 1513c777b47d19c7df99ba43142d7a334392a0b5 (patch) | |
tree | 1698a72b6f570e579d9fe409ecb87c18108d5f1a /src/lib/netlist/solver/nld_ms_w.h | |
parent | 3d09dec7b80bfaaed75d04ace63fcdc7a289f68a (diff) |
netlist: Refactoring continues ... plus some innovations (nw)
Still some work ahead to separate interface from execution. This is a
preparation to switch to another sparse matrix format easily which may
be better suited for parallel processing.
On the linear algebra side there are some nice additions:
- Two additional sort modes: One tries to obtain a upper left identity
matrix, the other prefers a diagonal band matrix structure. Both deliver
slightly better performance than just sorting.
- Parallel execution analysis for Gaussian elimination and LU solve.
This determines which operations may be done independently.
All of this is not really useful right now. The matrix sizes are below
100 nets. I estimate that we at least need four times more so that CPU
parallel processing overhead pays off. For GPU, add another order. But
it's nice to have code which may scale.
Diffstat (limited to 'src/lib/netlist/solver/nld_ms_w.h')
-rw-r--r-- | src/lib/netlist/solver/nld_ms_w.h | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/src/lib/netlist/solver/nld_ms_w.h b/src/lib/netlist/solver/nld_ms_w.h index 7ce2802336d..d448facd5d0 100644 --- a/src/lib/netlist/solver/nld_ms_w.h +++ b/src/lib/netlist/solver/nld_ms_w.h @@ -44,7 +44,7 @@ #include "nld_solver.h" #include "nld_matrix_solver.h" -#include "vector_base.h" +#include "../plib/vector_ops.h" namespace netlist { @@ -74,7 +74,7 @@ protected: virtual unsigned vsolve_non_dynamic(const bool newton_raphson) override; unsigned solve_non_dynamic(const bool newton_raphson); - constexpr std::size_t N() const { return m_dim; } + constexpr std::size_t size() const { return m_dim; } void LE_invert(); @@ -97,7 +97,6 @@ protected: template <typename T1, typename T2> float_ext_type &lA(const T1 &r, const T2 &c) { return m_lA[r][c]; } - float_type m_last_RHS[storage_N]; // right hand side - contains currents private: static constexpr std::size_t m_pitch = ((( storage_N) + 7) / 8) * 8; @@ -136,9 +135,7 @@ void matrix_solver_w_t<FT, SIZE>::vsetup(analog_net_t::list_t &nets) { matrix_solver_t::setup_base(nets); - state().save(*this, m_last_RHS, "m_last_RHS"); - - for (unsigned k = 0; k < N(); k++) + for (unsigned k = 0; k < size(); k++) state().save(*this, RHS(k), plib::pfmt("RHS.{1}")(k)); } @@ -147,7 +144,7 @@ void matrix_solver_w_t<FT, SIZE>::vsetup(analog_net_t::list_t &nets) template <typename FT, int SIZE> void matrix_solver_w_t<FT, SIZE>::LE_invert() { - const std::size_t kN = N(); + const std::size_t kN = size(); for (std::size_t i = 0; i < kN; i++) { @@ -211,7 +208,7 @@ template <typename T> void matrix_solver_w_t<FT, SIZE>::LE_compute_x( T * RESTRICT x) { - const std::size_t kN = N(); + const std::size_t kN = size(); for (std::size_t i=0; i<kN; i++) x[i] = 0.0; @@ -229,11 +226,11 @@ void matrix_solver_w_t<FT, SIZE>::LE_compute_x( template <typename FT, int SIZE> unsigned matrix_solver_w_t<FT, SIZE>::solve_non_dynamic(const bool newton_raphson) { - const auto iN = N(); + const auto iN = size(); float_type new_V[storage_N]; // = { 0.0 }; - if ((m_cnt % 100) == 0) + if ((m_cnt % 50) == 0) { /* complete calculation */ this->LE_invert(); @@ -369,9 +366,6 @@ unsigned matrix_solver_w_t<FT, SIZE>::vsolve_non_dynamic(const bool newton_raphs this->build_LE_A(*this); this->build_LE_RHS(*this); - for (std::size_t i=0, iN=N(); i < iN; i++) - m_last_RHS[i] = RHS(i); - this->m_stat_calculations++; return this->solve_non_dynamic(newton_raphson); } @@ -379,14 +373,10 @@ unsigned matrix_solver_w_t<FT, SIZE>::vsolve_non_dynamic(const bool newton_raphs template <typename FT, int SIZE> matrix_solver_w_t<FT, SIZE>::matrix_solver_w_t(netlist_base_t &anetlist, const pstring &name, const solver_parameters_t *params, const std::size_t size) -: matrix_solver_t(anetlist, name, NOSORT, params) - ,m_cnt(0) + : matrix_solver_t(anetlist, name, NOSORT, params) + , m_cnt(0) , m_dim(size) { - for (std::size_t k = 0; k < N(); k++) - { - m_last_RHS[k] = 0.0; - } } } //namespace devices |