summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib
diff options
context:
space:
mode:
authorGravatarGravatar couriersud <couriersud@gmx.org>2019-10-16 13:57:54 +0200
committerGravatarGravatar couriersud <couriersud@gmx.org>2019-10-16 13:57:54 +0200
commit55f1dfafc2a1aa55e53e83eac2415c76218e15b4 (patch)
tree0dee656c5804eba92f649786db442da3ac3df78c /src/lib
parent063e81d756b37fb97493c7da42c817bd7f6390aa (diff)
Netlist: pongf update and code maintenance. [Couriersud]
After the recent string of updates pongf performance increased again. Also includes code maintenance and some fixes for the aligned memory operations.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/netlist/nl_lists.h41
-rw-r--r--src/lib/netlist/nl_setup.cpp5
-rw-r--r--src/lib/netlist/plib/palloc.h27
-rw-r--r--src/lib/netlist/plib/parray.h31
-rw-r--r--src/lib/netlist/plib/pconfig.h47
-rw-r--r--src/lib/netlist/plib/ppmf.h48
-rw-r--r--src/lib/netlist/plib/ptypes.h5
7 files changed, 85 insertions, 119 deletions
diff --git a/src/lib/netlist/nl_lists.h b/src/lib/netlist/nl_lists.h
index 27db664cc05..30c73062fd0 100644
--- a/src/lib/netlist/nl_lists.h
+++ b/src/lib/netlist/nl_lists.h
@@ -13,6 +13,7 @@
#include "plib/pchrono.h"
#include "plib/plists.h"
#include "plib/ptypes.h"
+#include "plib/parray.h"
#include "nl_config.h"
#include "nltypes.h"
@@ -128,28 +129,6 @@ namespace netlist
m_prof_call.inc();
}
- void push_nostatsx(T && e) noexcept
- {
- /* Lock */
- lock_guard_type lck(m_lock);
-#if 1
- T * i(m_end-1);
- for (; *i < e; --i)
- {
- *(i+1) = *(i);
- }
- *(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); }
const T &top() const noexcept { return *(m_end-1); }
@@ -160,7 +139,6 @@ namespace netlist
lock_guard_type lck(m_lock);
if (KEEPSTAT)
m_prof_remove.inc();
-#if 1
for (T * i = m_end - 1; i > &m_list[0]; --i)
{
// == operator ignores time!
@@ -170,16 +148,6 @@ 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
}
template <bool KEEPSTAT, class R>
@@ -231,11 +199,10 @@ namespace netlist
using mutex_type = pspin_mutex<TS>;
using lock_guard_type = std::lock_guard<mutex_type>;
- mutex_type m_lock;
+ mutex_type m_lock;
PALIGNAS_CACHELINE()
- T * m_end;
- //std::vector<T> m_list;
- plib::aligned_vector<T> m_list;
+ T * m_end;
+ plib::aligned_vector<T> m_list;
public:
// profiling
diff --git a/src/lib/netlist/nl_setup.cpp b/src/lib/netlist/nl_setup.cpp
index bb942fdaab1..e0a696c226a 100644
--- a/src/lib/netlist/nl_setup.cpp
+++ b/src/lib/netlist/nl_setup.cpp
@@ -1219,7 +1219,10 @@ plib::unique_ptr<std::istream> source_file_t::stream(const pstring &name)
{
plib::unused_var(name);
auto ret(plib::make_unique<std::ifstream>(plib::filesystem::u8path(m_filename)));
- return std::move(ret);
+ if (ret->is_open())
+ return std::move(ret);
+ else
+ return plib::unique_ptr<std::istream>(nullptr);
}
bool source_proc_t::parse(nlparse_t &setup, const pstring &name)
diff --git a/src/lib/netlist/plib/palloc.h b/src/lib/netlist/plib/palloc.h
index a9b03353b37..ad42d14c690 100644
--- a/src/lib/netlist/plib/palloc.h
+++ b/src/lib/netlist/plib/palloc.h
@@ -262,6 +262,9 @@ namespace plib {
using allocator_type = arena_allocator<aligned_arena, T, ALIGN>;
template <typename T>
+ using unique_pool_ptr = std::unique_ptr<T, arena_deleter<aligned_arena, T>>;
+
+ template <typename T>
using owned_pool_ptr = plib::owned_ptr<T, arena_deleter<aligned_arena, T>>;
static inline aligned_arena &instance()
@@ -300,16 +303,24 @@ namespace plib {
#endif
}
-#if 0
template<typename T, typename... Args>
- owned_pool_ptr<T> make_poolptr(Args&&... args)
+ unique_pool_ptr<T> make_unique(Args&&... args)
{
auto *mem = allocate(alignof(T), sizeof(T));
- return owned_pool_ptr<T>(new (mem) T(std::forward<Args>(args)...), true, arena_deleter<aligned_arena, T>(*this));
+ try
+ {
+ auto *mema = new (mem) T(std::forward<Args>(args)...);
+ return unique_pool_ptr<T>(mema, arena_deleter<aligned_arena, T>(*this));
+ }
+ catch (...)
+ {
+ deallocate(mem);
+ throw;
+ }
}
-#endif
+
template<typename T, typename... Args>
- owned_pool_ptr<T> make_poolptr(Args&&... args)
+ owned_pool_ptr<T> make_owned(Args&&... args)
{
auto *mem = allocate(alignof(T), sizeof(T));
try
@@ -324,6 +335,12 @@ namespace plib {
}
}
+ bool operator ==(const aligned_arena &rhs) const
+ {
+ plib::unused_var(rhs);
+ return true;
+ }
+
};
template <typename T, std::size_t ALIGN>
diff --git a/src/lib/netlist/plib/parray.h b/src/lib/netlist/plib/parray.h
index b385da56eab..65251a02002 100644
--- a/src/lib/netlist/plib/parray.h
+++ b/src/lib/netlist/plib/parray.h
@@ -11,6 +11,7 @@
#include "palloc.h"
#include "pconfig.h"
#include "pexception.h"
+#include "pstrutil.h"
#include <array>
#include <memory>
@@ -31,8 +32,7 @@ namespace plib {
struct sizeabs<FT, 0>
{
static constexpr std::size_t ABS() { return 0; }
- //using container = typename std::vector<FT, aligned_allocator<FT, PALIGN_VECTOROPT>>;
- using container = typename std::vector<FT>;
+ using container = typename std::vector<FT, aligned_allocator<FT, PALIGN_VECTOROPT>>;
};
/**
@@ -69,23 +69,12 @@ namespace plib {
{
}
-#if 1
-#if 0
- struct tag {};
- /* allow construction in fixed size arrays */
- template <int X = SIZE >
- parray(tag A = tag(), typename std::enable_if<(X >= 0), int>::type = 0)
- : m_size(X)
- {
- }
-#else
/* allow construction in fixed size arrays */
parray()
: m_size(SIZEABS())
{
}
-#endif
-#endif
+
template <int X = SIZE >
parray(size_type size, typename std::enable_if<(X != 0), int>::type = 0)
: m_size(size)
@@ -101,18 +90,6 @@ namespace plib {
bool empty() const noexcept { return size() == 0; }
-#if 0
- reference operator[](size_type i) /*noexcept*/
- {
- if (i >= m_size) throw plib::pexception("limits error " + to_string(i) + ">=" + to_string(m_size));
- return m_a[i];
- }
- const_reference operator[](size_type i) const /*noexcept*/
- {
- if (i >= m_size) throw plib::pexception("limits error " + to_string(i) + ">=" + to_string(m_size));
- return m_a[i];
- }
-#else
C14CONSTEXPR reference operator[](size_type i) noexcept
{
return assume_aligned_ptr<FT, PALIGN_VECTOROPT>(&m_a[0])[i];
@@ -121,7 +98,7 @@ namespace plib {
{
return assume_aligned_ptr<FT, PALIGN_VECTOROPT>(&m_a[0])[i];
}
-#endif
+
FT * data() noexcept { return assume_aligned_ptr<FT, PALIGN_VECTOROPT>(m_a.data()); }
const FT * data() const noexcept { return assume_aligned_ptr<FT, PALIGN_VECTOROPT>(m_a.data()); }
diff --git a/src/lib/netlist/plib/pconfig.h b/src/lib/netlist/plib/pconfig.h
index 4ce5aea4cdb..3e20170a752 100644
--- a/src/lib/netlist/plib/pconfig.h
+++ b/src/lib/netlist/plib/pconfig.h
@@ -121,53 +121,6 @@ typedef __int128_t INT128;
#define HAS_OPENMP (0)
#endif
-//============================================================
-// Pointer to Member Function
-//============================================================
-
-// This will be autodetected
-//#define PPMF_TYPE 0
-
-#define PPMF_TYPE_PMF 0
-#define PPMF_TYPE_GNUC_PMF_CONV 1
-#define PPMF_TYPE_INTERNAL 2
-
-#if defined(__GNUC__)
- /* does not work in versions over 4.7.x of 32bit MINGW */
- #if defined(__MINGW32__) && !defined(__x86_64) && defined(__i386__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)))
- #define PHAS_PMF_INTERNAL 0
- #elif defined(__MINGW32__) && !defined(__x86_64) && defined(__i386__)
- #define PHAS_PMF_INTERNAL 1
- #define MEMBER_ABI _thiscall
- #elif defined(__clang__) && defined(__i386__) && defined(_WIN32)
- #define PHAS_PMF_INTERNAL 0
- #elif defined(__arm__) || defined(__ARMEL__) || defined(__aarch64__) || defined(__MIPSEL__) || defined(__mips_isa_rev) || defined(__mips64) || defined(__EMSCRIPTEN__)
- #define PHAS_PMF_INTERNAL 2
- #else
- #define PHAS_PMF_INTERNAL 1
- #endif
-#elif defined(_MSC_VER) && defined (_M_X64)
- #define PHAS_PMF_INTERNAL 3
-#else
- #define PHAS_PMF_INTERNAL 0
-#endif
-
-#ifndef MEMBER_ABI
- #define MEMBER_ABI
-#endif
-
-#ifndef PPMF_TYPE
- #if (PHAS_PMF_INTERNAL > 0)
- #define PPMF_TYPE PPMF_TYPE_INTERNAL
- #else
- #define PPMF_TYPE PPMF_TYPE_PMF
- #endif
-#else
- #undef PHAS_PMF_INTERNAL
- #define PHAS_PMF_INTERNAL 0
- #undef MEMBER_ABI
- #define MEMBER_ABI
-#endif
//============================================================
// WARNINGS
diff --git a/src/lib/netlist/plib/ppmf.h b/src/lib/netlist/plib/ppmf.h
index 8c8c6582579..4ff49911d63 100644
--- a/src/lib/netlist/plib/ppmf.h
+++ b/src/lib/netlist/plib/ppmf.h
@@ -41,6 +41,54 @@
*
*/
+//============================================================
+// Macro magic
+//============================================================
+
+//#define PPMF_TYPE 0
+
+#define PPMF_TYPE_PMF 0
+#define PPMF_TYPE_GNUC_PMF_CONV 1
+#define PPMF_TYPE_INTERNAL 2
+
+#if defined(__GNUC__)
+ /* does not work in versions over 4.7.x of 32bit MINGW */
+ #if defined(__MINGW32__) && !defined(__x86_64) && defined(__i386__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)))
+ #define PHAS_PMF_INTERNAL 0
+ #elif defined(__MINGW32__) && !defined(__x86_64) && defined(__i386__)
+ #define PHAS_PMF_INTERNAL 1
+ #define MEMBER_ABI _thiscall
+ #elif defined(__clang__) && defined(__i386__) && defined(_WIN32)
+ #define PHAS_PMF_INTERNAL 0
+ #elif defined(__arm__) || defined(__ARMEL__) || defined(__aarch64__) || defined(__MIPSEL__) || defined(__mips_isa_rev) || defined(__mips64) || defined(__EMSCRIPTEN__)
+ #define PHAS_PMF_INTERNAL 2
+ #else
+ #define PHAS_PMF_INTERNAL 1
+ #endif
+#elif defined(_MSC_VER) && defined (_M_X64)
+ #define PHAS_PMF_INTERNAL 3
+#else
+ #define PHAS_PMF_INTERNAL 0
+#endif
+
+#ifndef MEMBER_ABI
+ #define MEMBER_ABI
+#endif
+
+#ifndef PPMF_TYPE
+ #if (PHAS_PMF_INTERNAL > 0)
+ #define PPMF_TYPE PPMF_TYPE_INTERNAL
+ #else
+ #define PPMF_TYPE PPMF_TYPE_PMF
+ #endif
+#else
+ #undef PHAS_PMF_INTERNAL
+ #define PHAS_PMF_INTERNAL 0
+ #undef MEMBER_ABI
+ #define MEMBER_ABI
+#endif
+
+
#if (PPMF_TYPE == PPMF_TYPE_GNUC_PMF_CONV)
#pragma GCC diagnostic ignored "-Wpmf-conversions"
#endif
diff --git a/src/lib/netlist/plib/ptypes.h b/src/lib/netlist/plib/ptypes.h
index bda62099150..c3c1c5fc7c6 100644
--- a/src/lib/netlist/plib/ptypes.h
+++ b/src/lib/netlist/plib/ptypes.h
@@ -14,11 +14,12 @@
#include <string>
#include <type_traits>
+// noexcept on move operator -> issue with macosx clang
#define COPYASSIGNMOVE(name, def) \
name(const name &) = def; \
- name(name &&) noexcept = def; \
+ name(name &&) /*noexcept*/ = def; \
name &operator=(const name &) = def; \
- name &operator=(name &&) noexcept = def;
+ name &operator=(name &&) /*noexcept*/ = def;
#define COPYASSIGN(name, def) \
name(const name &) = def; \