diff options
| author | 2019-02-23 16:24:01 +0100 | |
|---|---|---|
| committer | 2019-02-23 16:24:01 +0100 | |
| commit | 0b3787d5f4e66c38b182d7bec8fd7fbc8fcc5b68 (patch) | |
| tree | 3e6ab137f583b35ef5a0dee030eab9ec643f629c /src | |
| parent | d0ffeee256fe8e76bfd876c24dfad4ed98ca760e (diff) | |
netlist: Fix some more exotic compile options. (nw)
128bit integers on kaby lake are not that much slower than 64bit. This
may be an option for MAME's attotime as well.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/netlist/build/makefile | 4 | ||||
| -rw-r--r-- | src/lib/netlist/devices/nlid_system.h | 4 | ||||
| -rw-r--r-- | src/lib/netlist/devices/nlid_truthtable.cpp | 2 | ||||
| -rw-r--r-- | src/lib/netlist/nl_base.cpp | 4 | ||||
| -rw-r--r-- | src/lib/netlist/nl_config.h | 11 | ||||
| -rw-r--r-- | src/lib/netlist/nl_time.h | 5 | ||||
| -rw-r--r-- | src/lib/netlist/plib/pconfig.h | 2 | ||||
| -rw-r--r-- | src/lib/netlist/solver/nld_matrix_solver.cpp | 28 | ||||
| -rw-r--r-- | src/lib/netlist/solver/nld_matrix_solver.h | 26 | ||||
| -rw-r--r-- | src/lib/netlist/solver/nld_ms_gmres.h | 5 | ||||
| -rw-r--r-- | src/lib/netlist/solver/nld_ms_sor.h | 2 | ||||
| -rw-r--r-- | src/lib/netlist/solver/nld_ms_sor_mat.h | 6 | ||||
| -rw-r--r-- | src/lib/netlist/solver/nld_solver.cpp | 4 | ||||
| -rw-r--r-- | src/lib/netlist/solver/nld_solver.h | 7 |
14 files changed, 45 insertions, 65 deletions
diff --git a/src/lib/netlist/build/makefile b/src/lib/netlist/build/makefile index 40d75f32fd8..d4296c1b007 100644 --- a/src/lib/netlist/build/makefile +++ b/src/lib/netlist/build/makefile @@ -14,7 +14,7 @@ VSBUILD = $(SRC)/buildVS DOC = $(SRC)/documentation TIDY_DB = ../compile_commands.json -TIDY_FLAGSX = -checks=*,-google*,-hicpp*,-readability*,-fuchsia*,cert-*,-android-*, +TIDY_FLAGSX = -checks=*,google*,-hicpp*,-readability*,-fuchsia*,cert-*,-android-*, TIDY_FLAGSX += -llvm-header-guard,-cppcoreguidelines-pro-type-reinterpret-cast, TIDY_FLAGSX += -cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-owning-memory, TIDY_FLAGSX += -modernize-use-default-member-init,-cppcoreguidelines-pro-bounds-constant-array-index, @@ -23,7 +23,7 @@ TIDY_FLAGSX += -modernize-pass-by-value,-cppcoreguidelines-pro-type-static-cast- #TIDY_FLAGSX += -cppcoreguidelines-pro-bounds-array-to-pointer-decay, TIDY_FLAGSX += performance-unnecessary-value-param,-cppcoreguidelines-avoid-magic-numbers, TIDY_FLAGSX += -cppcoreguidelines-macro-usage, -TIDY_FLAGSX += cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes, +TIDY_FLAGSX += -cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes, #TIDY_FLAGSX += -cppcoreguidelines-avoid-c-arrays,-modernize-avoid-c-arrays, #TIDY_FLAGSX += -modernize-use-using, TIDY_FLAGSX += performance-unnecessary-copy-initialization, diff --git a/src/lib/netlist/devices/nlid_system.h b/src/lib/netlist/devices/nlid_system.h index 02e8453c6e7..10cbc498a6b 100644 --- a/src/lib/netlist/devices/nlid_system.h +++ b/src/lib/netlist/devices/nlid_system.h @@ -127,7 +127,7 @@ namespace netlist std::vector<pstring> pat(plib::psplit(m_pattern(),",")); m_off = netlist_time::from_double(m_offset()); - std::array<netlist_time::mult_type, 32> pati = { 0 }; + std::array<std::int64_t, 32> pati = { 0 }; m_size = static_cast<std::uint8_t>(pat.size()); netlist_time::mult_type total = 0; @@ -135,7 +135,7 @@ namespace netlist { // FIXME: use pstonum_ne //pati[i] = plib::pstonum<decltype(pati[i])>(pat[i]); - pati[i] = plib::pstonum<netlist_time::mult_type>(pat[i]); + pati[i] = plib::pstonum<std::int64_t>(pat[i]); total += pati[i]; } netlist_time ttotal = netlist_time::zero(); diff --git a/src/lib/netlist/devices/nlid_truthtable.cpp b/src/lib/netlist/devices/nlid_truthtable.cpp index cadbdf0b7bb..78fd076b560 100644 --- a/src/lib/netlist/devices/nlid_truthtable.cpp +++ b/src/lib/netlist/devices/nlid_truthtable.cpp @@ -399,7 +399,7 @@ void truthtable_parser::parse(const std::vector<pstring> &truthtable) else nl_assert_always(outs == "0", "Unknown value (not 0 or 1"); // FIXME: error handling - netlist_time t = netlist_time::from_nsec(plib::pstonum<netlist_time::internal_type>(plib::trim(times[j]))); + netlist_time t = netlist_time::from_nsec(plib::pstonum<std::int64_t>(plib::trim(times[j]))); uint_least8_t k=0; while (m_timing_nt[k] != netlist_time::zero() && m_timing_nt[k] != t) k++; diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp index 8ba7ad7b5f8..e5c59c7d43d 100644 --- a/src/lib/netlist/nl_base.cpp +++ b/src/lib/netlist/nl_base.cpp @@ -476,7 +476,7 @@ void netlist_t::print_stats() const [&](size_t i1, size_t i2) { return m_state->m_devices[i1].second->m_stat_total_time.total() < m_state->m_devices[i2].second->m_stat_total_time.total(); }); nperftime_t<NL_KEEP_STATISTICS>::type total_time(0); - netlist_time::mult_type total_count(0); + nperftime_t<NL_KEEP_STATISTICS>::ctype total_count(0); for (auto & j : index) { @@ -489,7 +489,7 @@ void netlist_t::print_stats() const } log().verbose("Total calls : {1:12} {2:12} {3:12}", total_count, - total_time, total_time / total_count); + total_time, total_time / static_cast<decltype(total_time)>(total_count)); nperftime_t<NL_KEEP_STATISTICS> overhead; nperftime_t<NL_KEEP_STATISTICS> test; diff --git a/src/lib/netlist/nl_config.h b/src/lib/netlist/nl_config.h index de9a370db2f..d5d195367ec 100644 --- a/src/lib/netlist/nl_config.h +++ b/src/lib/netlist/nl_config.h @@ -37,7 +37,7 @@ * This approach is stricter and should identify bugs in * the netlist core faster. * By default it is disabled since it is not as fast as - * the default approach. + * the default approach. It is up to 5% slower. * */ #define USE_COPY_INSTEAD_OF_REFERENCE (0) @@ -54,15 +54,6 @@ #define NL_MAX_LINK_RESOLVE_LOOPS (100) //============================================================ -// Solver defines -//============================================================ - -#define USE_GABS (1) -// savings are eaten up by effort -// FIXME: Convert into solver parameter -#define USE_LINEAR_PREDICTION (0) - -//============================================================ // DEBUGGING //============================================================ diff --git a/src/lib/netlist/nl_time.h b/src/lib/netlist/nl_time.h index 4fd2b0211f1..1db22241d64 100644 --- a/src/lib/netlist/nl_time.h +++ b/src/lib/netlist/nl_time.h @@ -131,7 +131,7 @@ namespace netlist }; #if (PHAS_INT128) - using netlist_time = ptime<UINT128, NETLIST_INTERNAL_RES>; + using netlist_time = ptime<INT128, NETLIST_INTERNAL_RES>; #else using netlist_time = ptime<std::int64_t, NETLIST_INTERNAL_RES>; static_assert(noexcept(netlist_time::from_nsec(1)) == true, "Not evaluated as constexpr"); @@ -149,7 +149,8 @@ namespace netlist namespace plib { - template<> inline void state_manager_t::save_item(const void *owner, netlist::netlist_time &nlt, const pstring &stname) + template<> + inline void state_manager_t::save_item(const void *owner, netlist::netlist_time &nlt, const pstring &stname) { save_state_ptr(owner, stname, datatype_t(sizeof(netlist::netlist_time::internal_type), true, false), 1, nlt.get_internaltype_ptr()); } diff --git a/src/lib/netlist/plib/pconfig.h b/src/lib/netlist/plib/pconfig.h index 9754643678a..3b4bc55fc32 100644 --- a/src/lib/netlist/plib/pconfig.h +++ b/src/lib/netlist/plib/pconfig.h @@ -26,7 +26,7 @@ /* * Set this to one if you want to use 128 bit int for ptime. - * This is for tests only. + * This is about 5% slower on a kaby lake processor. */ #ifndef PHAS_INT128 diff --git a/src/lib/netlist/solver/nld_matrix_solver.cpp b/src/lib/netlist/solver/nld_matrix_solver.cpp index ff1ed03a633..6494ca6eaee 100644 --- a/src/lib/netlist/solver/nld_matrix_solver.cpp +++ b/src/lib/netlist/solver/nld_matrix_solver.cpp @@ -23,16 +23,6 @@ namespace devices { } - void terms_for_net_t::clear() - { - m_terms.clear(); - m_connected_net_idx.clear(); - m_gt.clear(); - m_go.clear(); - m_Idr.clear(); - m_connected_net_V.clear(); - } - void terms_for_net_t::add(terminal_t *term, int net_other, bool sorted) { if (sorted) @@ -42,23 +32,20 @@ namespace devices { plib::container::insert_at(m_terms, i, term); plib::container::insert_at(m_connected_net_idx, i, net_other); - plib::container::insert_at(m_gt, i, 0.0); - plib::container::insert_at(m_go, i, 0.0); - plib::container::insert_at(m_Idr, i, 0.0); - plib::container::insert_at(m_connected_net_V, i, nullptr); return; } } m_terms.push_back(term); m_connected_net_idx.push_back(net_other); - m_gt.push_back(0.0); - m_go.push_back(0.0); - m_Idr.push_back(0.0); - m_connected_net_V.push_back(nullptr); } void terms_for_net_t::set_pointers() { + m_gt.resize(count(), 0.0); + m_go.resize(count(), 0.0); + m_Idr.resize(count(), 0.0); + m_connected_net_V.resize(count(), nullptr); + for (std::size_t i = 0; i < count(); i++) { m_terms[i]->set_ptrs(&m_gt[i], &m_go[i], &m_Idr[i]); @@ -271,11 +258,6 @@ namespace devices m_terms[k]->set_pointers(); } - for (auto &rt : m_rails_temp) - { - rt->clear(); // no longer needed - } - // free all - no longer needed m_rails_temp.clear(); diff --git a/src/lib/netlist/solver/nld_matrix_solver.h b/src/lib/netlist/solver/nld_matrix_solver.h index 6bd00c495ef..71c28236c67 100644 --- a/src/lib/netlist/solver/nld_matrix_solver.h +++ b/src/lib/netlist/solver/nld_matrix_solver.h @@ -22,16 +22,18 @@ namespace devices struct solver_parameters_t { - int m_pivot; + bool m_pivot; nl_double m_accuracy; nl_double m_dynamic_lte; nl_double m_min_timestep; nl_double m_max_timestep; nl_double m_gs_sor; bool m_dynamic_ts; - unsigned m_gs_loops; - unsigned m_nr_loops; + std::size_t m_gs_loops; + std::size_t m_nr_loops; netlist_time m_nr_recalc_delay; + bool m_use_gabs; + bool m_use_linear_prediction; bool m_log_stats; }; @@ -63,15 +65,9 @@ namespace devices const std::size_t term_count = this->count(); const std::size_t railstart = this->m_railstart; - const FT * const * other_cur_analog = m_connected_net_V.data(); - const FT * p_go = m_go.data(); - const FT * p_gt = m_gt.data(); - const FT * p_Idr = m_Idr.data(); for (std::size_t i = 0; i < railstart; i++) - { - *tcr[i] -= p_go[i]; - } + *tcr[i] -= m_go[i]; #if 1 FT gtot_t = 0.0; @@ -79,18 +75,18 @@ namespace devices for (std::size_t i = 0; i < term_count; i++) { - gtot_t += p_gt[i]; - RHS_t += p_Idr[i]; + gtot_t += m_gt[i]; + RHS_t += m_Idr[i]; } // FIXME: Code above is faster than vec_sum - Check this #else - auto gtot_t = plib::vec_sum<FT>(term_count, p_gt); - auto RHS_t = plib::vec_sum<FT>(term_count, p_Idr); + auto gtot_t = plib::vec_sum<FT>(term_count, m_gt); + auto RHS_t = plib::vec_sum<FT>(term_count, m_Idr); #endif for (std::size_t i = railstart; i < term_count; i++) { - RHS_t += (/*m_Idr[i]*/ + p_go[i] * *other_cur_analog[i]); + RHS_t += (/*m_Idr[i]*/ + m_go[i] * *m_connected_net_V[i]); } RHS = RHS_t; diff --git a/src/lib/netlist/solver/nld_ms_gmres.h b/src/lib/netlist/solver/nld_ms_gmres.h index dcb3726f5f2..e8963578452 100644 --- a/src/lib/netlist/solver/nld_ms_gmres.h +++ b/src/lib/netlist/solver/nld_ms_gmres.h @@ -117,11 +117,10 @@ namespace devices this->m_new_V[k] = this->m_nets[k]->Q_Analog(); } - const float_type accuracy = this->m_params.m_accuracy; - const std::size_t iter = std::max(1u, this->m_params.m_gs_loops); - std::size_t gsl = m_gmres.solve(m_ops, this->m_new_V, RHS, iter, accuracy); + auto iter = std::max(plib::constants<std::size_t>::one(), this->m_params.m_gs_loops); + auto gsl = m_gmres.solve(m_ops, this->m_new_V, RHS, iter, accuracy); this->m_iterative_total += gsl; this->m_stat_calculations++; diff --git a/src/lib/netlist/solver/nld_ms_sor.h b/src/lib/netlist/solver/nld_ms_sor.h index 5dfc395963a..a1893644084 100644 --- a/src/lib/netlist/solver/nld_ms_sor.h +++ b/src/lib/netlist/solver/nld_ms_sor.h @@ -103,7 +103,7 @@ unsigned matrix_solver_SOR_t<FT, SIZE>::vsolve_non_dynamic(const bool newton_rap RHS[k] = RHS_t; - if (USE_GABS) + if (this->m_params.m_use_gabs) { for (std::size_t i = 0; i < term_count; i++) gabs_t = gabs_t + std::abs(go[i]); diff --git a/src/lib/netlist/solver/nld_ms_sor_mat.h b/src/lib/netlist/solver/nld_ms_sor_mat.h index 0bb756c05f5..df4409ca5e9 100644 --- a/src/lib/netlist/solver/nld_ms_sor_mat.h +++ b/src/lib/netlist/solver/nld_ms_sor_mat.h @@ -72,7 +72,7 @@ float_type matrix_solver_SOR_mat_t<m_N, storage_N>::vsolve() * enable linear prediction on first newton pass */ - if (USE_LINEAR_PREDICTION) + if (this->m_params->use_linear_prediction) for (unsigned k = 0; k < this->size(); k++) { this->m_last_V[k] = this->m_nets[k]->m_cur_Analog; @@ -86,7 +86,7 @@ float_type matrix_solver_SOR_mat_t<m_N, storage_N>::vsolve() this->solve_base(this); - if (USE_LINEAR_PREDICTION) + if (this->m_params->use_linear_prediction) { float_type sq = 0; float_type sqo = 0; @@ -183,7 +183,7 @@ unsigned matrix_solver_SOR_mat_t<FT, SIZE>::vsolve_non_dynamic(const bool newton Idrive = Idrive + this->A(k,p[i]) * this->m_new_V[p[i]]; FT w = m_omega / this->A(k,k); - if (USE_GABS) + if (this->m_params.m_use_gabs) { FT gabs_t = 0.0; for (std::size_t i = 0; i < e; i++) diff --git a/src/lib/netlist/solver/nld_solver.cpp b/src/lib/netlist/solver/nld_solver.cpp index 64fb7c93998..be008a21706 100644 --- a/src/lib/netlist/solver/nld_solver.cpp +++ b/src/lib/netlist/solver/nld_solver.cpp @@ -262,6 +262,10 @@ void NETLIB_NAME(solver)::post_start() m_params.m_dynamic_ts = (m_dynamic_ts() == 1 ? true : false); m_params.m_max_timestep = netlist_time::from_double(1.0 / m_freq()).as_double(); + m_params.m_use_gabs = m_use_gabs(); + m_params.m_use_linear_prediction = m_use_linear_prediction(); + + if (m_params.m_dynamic_ts) { m_params.m_max_timestep *= 1;//NL_FCONST(1000.0); diff --git a/src/lib/netlist/solver/nld_solver.h b/src/lib/netlist/solver/nld_solver.h index 164b7663f98..646271e0ebd 100644 --- a/src/lib/netlist/solver/nld_solver.h +++ b/src/lib/netlist/solver/nld_solver.h @@ -57,6 +57,10 @@ NETLIB_OBJECT(solver) , m_dynamic_lte(*this, "DYNAMIC_LTE", 1e-5) // diff/timestep , m_dynamic_min_ts(*this, "DYNAMIC_MIN_TIMESTEP", 1e-6) // nl_double timestep resolution + /* special */ + , m_use_gabs(*this, "USE_GABS", true) + , m_use_linear_prediction(*this, "USE_LINEAR_PREDICTION", false) // // savings are eaten up by effort + , m_log_stats(*this, "LOG_STATS", true) // log statistics on shutdown , m_params() { @@ -94,6 +98,9 @@ private: param_double_t m_dynamic_lte; param_double_t m_dynamic_min_ts; + param_logic_t m_use_gabs; + param_logic_t m_use_linear_prediction; + param_logic_t m_log_stats; std::vector<poolptr<matrix_solver_t>> m_mat_solvers; |
