diff options
author | 2020-09-24 07:53:24 +0200 | |
---|---|---|
committer | 2020-09-24 15:22:23 +0200 | |
commit | 5a2f41d1a5b1e8186129be01c5d2903fdcd087cf (patch) | |
tree | 980732cf57a4dfb805a3a298c3cf8feef05957f4 | |
parent | 1bb99466bcfa188bca00855f80bd6098b0882419 (diff) |
netlist: Improve queue handling documentation in code.
* Document that for performance reasons pushes to queue are
allowed even if they may not change state and are filtered
out during process.
* Provide alternative code path. This is currently not used.
-rw-r--r-- | src/lib/netlist/core/exec.h | 12 | ||||
-rw-r--r-- | src/lib/netlist/core/nets.h | 35 | ||||
-rw-r--r-- | src/lib/netlist/plib/ptimed_queue.h | 1 |
3 files changed, 44 insertions, 4 deletions
diff --git a/src/lib/netlist/core/exec.h b/src/lib/netlist/core/exec.h index 307baa6b0f2..15a753593df 100644 --- a/src/lib/netlist/core/exec.h +++ b/src/lib/netlist/core/exec.h @@ -49,19 +49,27 @@ namespace netlist template<typename... Args> void qpush(Args&&...args) noexcept { - if (!NL_USE_QUEUE_STATS || !m_use_stats) +#if (!NL_USE_QUEUE_STATS) + m_queue.emplace<false>(std::forward<Args>(args)...); // NOLINT(performance-move-const-arg) +#else + if (!m_use_stats) m_queue.emplace<false>(std::forward<Args>(args)...); // NOLINT(performance-move-const-arg) else m_queue.emplace<true>(std::forward<Args>(args)...); // NOLINT(performance-move-const-arg) +#endif } template <class R> void qremove(const R &elem) noexcept { - if (!NL_USE_QUEUE_STATS || !m_use_stats) +#if (!NL_USE_QUEUE_STATS) + m_queue.remove<false>(elem); +#else + if (!m_use_stats) m_queue.remove<false>(elem); else m_queue.remove<true>(elem); +#endif } // Control functions diff --git a/src/lib/netlist/core/nets.h b/src/lib/netlist/core/nets.h index e4c1897ee81..2d17ebd8e04 100644 --- a/src/lib/netlist/core/nets.h +++ b/src/lib/netlist/core/nets.h @@ -17,6 +17,12 @@ #include "../plib/plists.h" #include "../plib/pstring.h" +// Enable the setting below to avoid queue pushes were at execution +// no action will be taken. This is academically cleaner, but slower than +// allowing this to happen and filter it during during "process". + +#define AVOID_NOOP_QUEUE_PUSHES (0) + namespace netlist { @@ -68,7 +74,14 @@ namespace netlist const auto nst(exec().time() + delay); m_next_scheduled_time = nst; - +#if (AVOID_NOOP_QUEUE_PUSHES) + m_in_queue = (m_list_active.empty() ? queue_status::DELAYED_DUE_TO_INACTIVE + : (m_new_Q != m_cur_Q ? queue_status::QUEUED : queue_status::DELIVERED)); + if (m_in_queue == queue_status::QUEUED) + exec().qpush(nst, this); + else + update_inputs(); +#else if (!m_list_active.empty()) { m_in_queue = queue_status::QUEUED; @@ -79,6 +92,7 @@ namespace netlist m_in_queue = queue_status::DELAYED_DUE_TO_INACTIVE; update_inputs(); } +#endif } } NVCC_CONSTEXPR bool is_queued() const noexcept { return m_in_queue == queue_status::QUEUED; } @@ -89,7 +103,10 @@ namespace netlist nl_assert(this->is_rail_net()); m_in_queue = queue_status::DELIVERED; // mark as taken ... + +#if (!AVOID_NOOP_QUEUE_PUSHES) if (m_new_Q ^ m_cur_Q) +#endif { process<KEEP_STATS>((m_new_Q << core_terminal_t::INP_LH_SHIFT) | (m_cur_Q << core_terminal_t::INP_HL_SHIFT), m_new_Q); @@ -117,7 +134,12 @@ namespace netlist railterminal().device().do_inc_active(); if (m_in_queue == queue_status::DELAYED_DUE_TO_INACTIVE) { +#if (AVOID_NOOP_QUEUE_PUSHES) + if (m_next_scheduled_time > exec().time() + && (m_cur_Q != m_new_Q)) +#else if (m_next_scheduled_time > exec().time()) +#endif { m_in_queue = queue_status::QUEUED; // pending exec().qpush(m_next_scheduled_time, this); @@ -139,7 +161,16 @@ namespace netlist gsl_Expects(!m_list_active.empty()); m_list_active.remove(&term); if (m_list_active.empty()) + { +#if (AVOID_NOOP_QUEUE_PUSHES) + if (!!is_queued()) + { + exec().qremove(this); + m_in_queue = queue_status::DELAYED_DUE_TO_INACTIVE; + } +#endif railterminal().device().do_dec_active(); + } } // ----------------------------------------------------------------------------- @@ -216,7 +247,7 @@ namespace netlist // ----------------------------------------------------------------------------- template <bool KEEP_STATS, typename T, typename S> - void process(T mask, const S &sig) noexcept + void process(const T &mask, const S &sig) noexcept { m_cur_Q = sig; diff --git a/src/lib/netlist/plib/ptimed_queue.h b/src/lib/netlist/plib/ptimed_queue.h index dc8db7c9bcc..13631dfe20a 100644 --- a/src/lib/netlist/plib/ptimed_queue.h +++ b/src/lib/netlist/plib/ptimed_queue.h @@ -165,6 +165,7 @@ namespace plib { return; } } + //printf("Element not found in delete %s\n", elem->name().c_str()); } template <bool KEEPSTAT, class R> |