summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatarGravatar couriersud <couriersud@gmx.org>2020-06-08 03:10:58 +0200
committerGravatarGravatar couriersud <couriersud@gmx.org>2020-06-08 03:10:58 +0200
commitd041e74e2c36a79a1201fbd658b022e61731fd10 (patch) (github)
tree222a0533871b6f1971a988a8b8605f94dea09b86
parent1c635c1bfd50098acb12e690672c883a4e4026c7 (diff)
downloadmame-d041e74e2c36a79a1201fbd658b022e61731fd10.tar.bz2
mame-d041e74e2c36a79a1201fbd658b022e61731fd10.zip
netlist: allow selection of base arena for pmempool_arena. (nw)
-rw-r--r--src/lib/netlist/nltypes.h4
-rw-r--r--src/lib/netlist/plib/palloc.h2
-rw-r--r--src/lib/netlist/plib/pmempool.h26
-rw-r--r--src/lib/netlist/solver/nld_solver.cpp4
4 files changed, 23 insertions, 13 deletions
diff --git a/src/lib/netlist/nltypes.h b/src/lib/netlist/nltypes.h
index 42479e0636b..8ee9da300b2 100644
--- a/src/lib/netlist/nltypes.h
+++ b/src/lib/netlist/nltypes.h
@@ -78,7 +78,9 @@ namespace netlist
/// \note This is not the right location yet.
///
- using device_arena = std::conditional<NL_USE_MEMPOOL, plib::mempool_arena, plib::aligned_arena>::type;
+ using device_arena = std::conditional<NL_USE_MEMPOOL,
+ plib::mempool_arena<plib::aligned_arena>,
+ plib::aligned_arena>::type;
using host_arena = plib::aligned_arena;
/// \brief Interface definition for netlist callbacks into calling code
diff --git a/src/lib/netlist/plib/palloc.h b/src/lib/netlist/plib/palloc.h
index 1e103577da4..045461c8418 100644
--- a/src/lib/netlist/plib/palloc.h
+++ b/src/lib/netlist/plib/palloc.h
@@ -221,7 +221,7 @@ namespace plib {
//~arena_allocator() noexcept = default;
- explicit arena_allocator(const arena_type & a) noexcept : m_a(a)
+ explicit arena_allocator(arena_type & a) noexcept : m_a(a)
{
}
diff --git a/src/lib/netlist/plib/pmempool.h b/src/lib/netlist/plib/pmempool.h
index 07987f4e830..441595d9e58 100644
--- a/src/lib/netlist/plib/pmempool.h
+++ b/src/lib/netlist/plib/pmempool.h
@@ -27,13 +27,20 @@ namespace plib {
// Memory pool
//============================================================
- class mempool_arena : public arena_base<mempool_arena, true, false>
+ template <typename BASEARENA>
+ class mempool_arena : public arena_base<mempool_arena<BASEARENA>, false, false>
{
public:
+ using size_type = typename BASEARENA::size_type;
+ using base_type = arena_base<mempool_arena<BASEARENA>, false, false>;
+ template <class T>
+ using base_allocator_type = typename BASEARENA::template allocator_type<T>;
+
mempool_arena(size_t min_alloc = (1<<21), size_t min_align = PALIGN_CACHELINE)
: m_min_alloc(min_alloc)
, m_min_align(min_align)
+ , m_blocks(base_allocator_type<block *>(m_arena))
{
icount()++;
}
@@ -50,7 +57,7 @@ namespace plib {
plib::perrlogger("Found {} info blocks\n", sinfo().size());
plib::perrlogger("Found block with {} dangling allocations\n", b->m_num_alloc);
}
- aligned_arena::free(b);
+ m_arena.free(b);
//::operator delete(b->m_data);
}
if (icount()-- == 1)
@@ -88,14 +95,14 @@ namespace plib {
sinfo().insert({ ret, info(b, b->m_cur)});
rs -= (capacity - size);
b->m_cur += rs;
- m_stat_cur_alloc() += size;
- if (m_stat_max_alloc() < m_stat_cur_alloc())
- m_stat_max_alloc() = m_stat_cur_alloc();
+ base_type::m_stat_cur_alloc() += size;
+ if (base_type::m_stat_max_alloc() < base_type::m_stat_cur_alloc())
+ base_type::m_stat_max_alloc() = base_type::m_stat_cur_alloc();
return ret;
}
- static void deallocate(void *ptr, size_t size) noexcept
+ /*static */ void deallocate(void *ptr, size_t size) noexcept
{
auto it = sinfo().find(ptr);
@@ -116,7 +123,7 @@ namespace plib {
plib::terminate("mempool::free - block not found");
mp.m_blocks.erase(itb);
- aligned_arena::free(b);
+ m_arena.free(b);
}
sinfo().erase(it);
}
@@ -173,7 +180,7 @@ namespace plib {
block * new_block(size_type min_bytes)
{
- auto *b = aligned_arena::alloc<block>(*this, min_bytes);
+ auto *b = m_arena.template alloc<block>(*this, min_bytes);
m_blocks.push_back(b);
return b;
}
@@ -192,8 +199,9 @@ namespace plib {
size_t m_min_alloc;
size_t m_min_align;
+ BASEARENA m_arena;
- plib::aligned_vector<block *> m_blocks;
+ std::vector<block *, typename BASEARENA::template allocator_type<block *>> m_blocks;
};
diff --git a/src/lib/netlist/solver/nld_solver.cpp b/src/lib/netlist/solver/nld_solver.cpp
index c7e8242d83a..8787247e505 100644
--- a/src/lib/netlist/solver/nld_solver.cpp
+++ b/src/lib/netlist/solver/nld_solver.cpp
@@ -306,7 +306,7 @@ namespace devices
switch (m_params.m_fp_type())
{
case solver::matrix_fp_type_e::FLOAT:
- if (NL_USE_FLOAT_MATRIX)
+ if (!NL_USE_FLOAT_MATRIX)
log().info("FPTYPE {1} not supported. Using DOUBLE", m_params.m_fp_type().name());
ms = create_solvers<std::conditional_t<NL_USE_FLOAT_MATRIX,float, double>>(sname, grp);
break;
@@ -314,7 +314,7 @@ namespace devices
ms = create_solvers<double>(sname, grp);
break;
case solver::matrix_fp_type_e::LONGDOUBLE:
- if (NL_USE_LONG_DOUBLE_MATRIX)
+ if (!NL_USE_LONG_DOUBLE_MATRIX)
log().info("FPTYPE {1} not supported. Using DOUBLE", m_params.m_fp_type().name());
ms = create_solvers<std::conditional_t<NL_USE_LONG_DOUBLE_MATRIX, long double, double>>(sname, grp);
break;