summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author couriersud <couriersud@gmx.org>2019-04-23 22:19:09 +0200
committer couriersud <couriersud@gmx.org>2019-04-23 22:19:09 +0200
commite669c0c4725bd98827ff11e3b93cf0009f6dba43 (patch)
tree6d5ae003720f85565320e2e4d250825cf86f3b67
parent51ed2fc42297d779e3e54c31c61dde5d47683742 (diff)
netlist: Protect defines with ifdefs ...
Protected defines in nl_config.h with ifdefs. Added a define to disable queue statistics during compile. This is only needed during development. Documented performance improvement efforts so I don't try this again.
-rw-r--r--src/lib/netlist/nl_base.h13
-rw-r--r--src/lib/netlist/nl_config.h19
-rw-r--r--src/lib/netlist/nl_lists.h29
3 files changed, 58 insertions, 3 deletions
diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h
index 346f0b58479..f995e0a26fd 100644
--- a/src/lib/netlist/nl_base.h
+++ b/src/lib/netlist/nl_base.h
@@ -1506,6 +1506,7 @@ namespace netlist
void qpush(detail::queue_t::entry_t && e) noexcept
{
+#if (USE_QUEUE_STATS)
#if 0
// clang treats -Wswitch-bool as error
switch (m_stats)
@@ -1519,12 +1520,22 @@ namespace netlist
else
m_queue.push(std::move(e));
#endif
+#else
+ m_queue.push_nostats(std::move(e));
+#endif
}
template <class R>
void qremove(const R &elem) noexcept
{
- m_queue.remove(elem);
+#if (USE_QUEUE_STATS)
+ if (!m_stats)
+ m_queue.remove_nostats(elem);
+ else
+ m_queue.remove(elem);
+#else
+ m_queue.remove_nostats(elem);
+#endif
}
/* Control functions */
diff --git a/src/lib/netlist/nl_config.h b/src/lib/netlist/nl_config.h
index 7e4047764bf..a668362bae9 100644
--- a/src/lib/netlist/nl_config.h
+++ b/src/lib/netlist/nl_config.h
@@ -28,7 +28,20 @@
* Your mileage may vary.
*
*/
+#ifndef USE_MEMPOOL
#define USE_MEMPOOL (1)
+#endif
+
+/*! Enable queue statistics.
+ *
+ * Queue statistics come at a performance cost. Although
+ * the cost is low, we disable them here since they are
+ * only needed during development.
+ *
+ */
+#ifndef USE_QUEUE_STATS
+#define USE_QUEUE_STATS (0)
+#endif
/*! Store input values in logic_terminal_t.
*
@@ -40,7 +53,9 @@
* the default approach. It is up to 5% slower.
*
*/
+#ifndef USE_COPY_INSTEAD_OF_REFERENCE
#define USE_COPY_INSTEAD_OF_REFERENCE (0)
+#endif
/*
* FIXME: Using truthtable is a lot slower than the explicit device
@@ -51,14 +66,18 @@
#define USE_TRUTHTABLE_7448 (0)
// How many times do we try to resolve links (connections)
+#ifndef NL_MAX_LINK_RESOLVE_LOOPS
#define NL_MAX_LINK_RESOLVE_LOOPS (100)
+#endif
//============================================================
// DEBUGGING
//============================================================
+#ifndef NL_DEBUG
#define NL_DEBUG (false)
//#define NL_DEBUG (true)
+#endif
//============================================================
// General Macros
diff --git a/src/lib/netlist/nl_lists.h b/src/lib/netlist/nl_lists.h
index 8b79e9553b1..f4b1c4e8ff5 100644
--- a/src/lib/netlist/nl_lists.h
+++ b/src/lib/netlist/nl_lists.h
@@ -132,6 +132,7 @@ namespace netlist
{
/* Lock */
lock_guard_type lck(m_lock);
+#if 1
T * i(m_end-1);
for (; QueueOp::less(*(i), e); --i)
{
@@ -139,6 +140,14 @@ namespace netlist
}
*(i+1) = std::move(e);
++m_end;
+#else
+ T * i(m_end++);
+ while (QueueOp::less(*(--i), e))
+ {
+ *(i+1) = *(i);
+ }
+ *(i+1) = std::move(e);
+#endif
}
T pop() noexcept { return *(--m_end); }
@@ -147,10 +156,16 @@ namespace netlist
template <class R>
void remove(const R &elem) noexcept
{
- /* Lock */
- lock_guard_type lck(m_lock);
m_prof_remove.inc();
+ remove_nostats(elem);
+ }
+ template <class R>
+ void remove_nostats(const R &elem) noexcept
+ {
+ /* Lock */
+ lock_guard_type lck(m_lock);
+#if 1
for (T * i = m_end - 1; i > &m_list[0]; --i)
{
if (QueueOp::equal(*i, elem))
@@ -159,6 +174,16 @@ namespace netlist
return;
}
}
+#else
+ for (T * i = &m_list[1]; i < m_end; ++i)
+ {
+ if (QueueOp::equal(*i, elem))
+ {
+ std::copy(i+1, m_end--, i);
+ return;
+ }
+ }
+#endif
}
void retime(T && elem) noexcept