netlist: include file refactoring.

The purpose of this ongoing exercise is to remove unnecessary
dependencies in header files. netlist implementations should only have
access to what they need. The same applies to device implementations.

Core stuff will be moved to the core subdirectory going forward.
This commit is contained in:
couriersud 2020-06-28 13:14:16 +02:00
parent 3fcdfa0a9b
commit ab31af569f
45 changed files with 260 additions and 258 deletions

View File

@ -19,6 +19,9 @@
//#include "netlist/devices/nlid_system.h"
#include "netlist/plib/palloc.h"
#include "netlist/plib/pmempool.h"
#include "netlist/plib/pdynlib.h"
#include "netlist/plib/pstonum.h"
#include "debugger.h"
#include "romload.h"
@ -116,10 +119,10 @@ protected:
}
}
netlist::host_arena::unique_ptr<plib::dynlib_base> static_solver_lib() const noexcept override
std::unique_ptr<plib::dynlib_base> static_solver_lib() const noexcept override
{
//return plib::make_unique<plib::dynlib_static>(nullptr);
return plib::make_unique<plib::dynlib_static, netlist::host_arena>(nl_static_solver_syms);
return std::make_unique<plib::dynlib_static>(nl_static_solver_syms);
}
private:
@ -159,9 +162,9 @@ protected:
}
}
netlist::host_arena::unique_ptr<plib::dynlib_base> static_solver_lib() const noexcept override
std::unique_ptr<plib::dynlib_base> static_solver_lib() const noexcept override
{
return plib::make_unique<plib::dynlib_static, netlist::host_arena>(nullptr);
return std::make_unique<plib::dynlib_static>(nullptr);
}
private:
@ -966,11 +969,11 @@ void netlist_mame_device::common_dev_start(netlist::netlist_state_t *lnetlist) c
}
}
netlist::host_arena::unique_ptr<netlist::netlist_state_t> netlist_mame_device::base_validity_check(validity_checker &valid) const
std::unique_ptr<netlist::netlist_state_t> netlist_mame_device::base_validity_check(validity_checker &valid) const
{
try
{
auto lnetlist = plib::make_unique<netlist::netlist_state_t, netlist::host_arena>("netlist",
auto lnetlist = std::make_unique<netlist::netlist_state_t>("netlist",
plib::make_unique<netlist_validate_callbacks_t, netlist::host_arena>());
// enable validation mode
lnetlist->set_extended_validation(true);
@ -1002,7 +1005,7 @@ netlist::host_arena::unique_ptr<netlist::netlist_state_t> netlist_mame_device::b
{
osd_printf_error("%s\n", err.what());
}
return netlist::host_arena::unique_ptr<netlist::netlist_state_t>(nullptr);
return std::unique_ptr<netlist::netlist_state_t>(nullptr);
}
void netlist_mame_device::device_validity_check(validity_checker &valid) const

View File

@ -111,7 +111,7 @@ protected:
virtual void device_pre_save() override;
virtual void device_clock_changed() override;
netlist::host_arena::unique_ptr<netlist::netlist_state_t> base_validity_check(validity_checker &valid) const;
std::unique_ptr<netlist::netlist_state_t> base_validity_check(validity_checker &valid) const;
attotime m_cur_time;
attotime m_attotime_per_clock;

View File

@ -11,6 +11,7 @@
#include "netlist/nl_base.h"
#include "netlist/nl_factory.h"
#include "netlist/plib/prandom.h"
#include "netlist/plib/pstonum.h"
#include "netlist/plib/putil.h"
#include <random>

View File

@ -1,6 +1,9 @@
// license:GPL-2.0+
// copyright-holders:Couriersud
#include "plib/pstonum.h"
#include "plib/pstrutil.h"
#include "nl_base.h"
#include "nl_factory.h"
#include "nlid_truthtable.h"

View File

@ -8,6 +8,7 @@
#include "plib/pfmtlog.h"
#include "plib/pmempool.h"
#include "plib/putil.h"
#include "plib/pdynlib.h"
#include "devices/nlid_proxy.h"
#include "devices/nlid_system.h"
@ -25,9 +26,9 @@ namespace netlist
// callbacks_t
// ----------------------------------------------------------------------------------------
host_arena::unique_ptr<plib::dynlib_base> callbacks_t:: static_solver_lib() const
std::unique_ptr<plib::dynlib_base> callbacks_t:: static_solver_lib() const
{
return plib::make_unique<plib::dynlib_static, host_arena>(nullptr);
return std::make_unique<plib::dynlib_static>(nullptr);
}
// ----------------------------------------------------------------------------------------

View File

@ -13,17 +13,12 @@
#endif
#include "plib/palloc.h" // owned_ptr
#include "plib/pdynlib.h"
#include "plib/pexception.h"
#include "plib/pfmtlog.h"
#include "plib/pfunction.h"
#include "plib/plists.h"
#include "plib/pmempool.h"
#include "plib/ppmf.h"
#include "plib/pstate.h"
#include "plib/pstonum.h"
#include "plib/pstream.h"
#include "plib/ptime.h"
#include "plib/pstate.h"
#include "plib/ptimed_queue.h"
#include "plib/ptypes.h"
@ -90,7 +85,7 @@ class NETLIB_NAME(name) : public delegator_t<base_device_t>
/// #NETLIB_OBJECT for an example.
#define NETLIB_CONSTRUCTOR(cname) \
using this_type = NETLIB_NAME(cname); \
public: template <class CLASS> NETLIB_NAME(cname)(CLASS &owner, const pstring &name) \
public: template <class CLASS> NETLIB_NAME(cname)(CLASS &owner, const pstring &name)\
: base_type(owner, name)
/// \brief Used to define the constructor of a netlist device and define a default model.
@ -203,55 +198,13 @@ class NETLIB_NAME(name) : public delegator_t<base_device_t>
namespace netlist
{
/// \brief Delegate type for device notification.
///
using nldelegate = plib::pmfp<void>;
using nldelegate_ts = plib::pmfp<void, nl_fptype>;
using nldelegate_dyn = plib::pmfp<void>;
// -----------------------------------------------------------------------------
// forward definitions
// -----------------------------------------------------------------------------
namespace devices
{
class NETLIB_NAME(solver);
class NETLIB_NAME(mainclock);
class NETLIB_NAME(base_proxy);
class NETLIB_NAME(base_d_to_a_proxy);
class NETLIB_NAME(base_a_to_d_proxy);
} // namespace devices
namespace solver
{
class matrix_solver_t;
} // namespace solver
class logic_output_t;
class logic_input_t;
class analog_net_t;
class logic_net_t;
class setup_t;
class nlparse_t;
class netlist_t;
class netlist_state_t;
class core_device_t;
class device_t;
template <class CX>
class delegator_t : public CX
{
protected:
using base_type = delegator_t<CX>;
using delegated_type = CX;
using delegated_type::delegated_type;
};
namespace detail
{
class net_t;
} // namespace detail
//============================================================
// Exceptions
//============================================================
@ -263,7 +216,7 @@ namespace netlist
{
public:
/// \brief Constructor.
/// Allows a descriptive text to be assed to the exception
/// Allows a descriptive text to be passed to the exception
explicit nl_exception(const pstring &text //!< text to be passed
)
@ -996,8 +949,6 @@ namespace netlist
{
public:
using list_t = plib::aligned_vector<analog_net_t *>;
analog_net_t(netlist_state_t &nl, const pstring &aname, detail::core_terminal_t *railterminal = nullptr);
nl_fptype Q_Analog() const noexcept { return m_cur_Analog; }
@ -1482,8 +1433,8 @@ namespace netlist
void connect(const detail::core_terminal_t &t1, const detail::core_terminal_t &t2);
protected:
NETLIB_UPDATEI() { }
NETLIB_UPDATE_TERMINALSI() { }
//NETLIB_UPDATEI() { }
//NETLIB_UPDATE_TERMINALSI() { }
private:
};
@ -1513,11 +1464,11 @@ namespace netlist
~device_t() noexcept override = default;
//nldelegate default_delegate() { return nldelegate(&device_t::update, this); }
nldelegate default_delegate() { return { &device_t::update, this }; }
nldelegate default_delegate() { return { &core_device_t::update, dynamic_cast<core_device_t *>(this) }; }
protected:
NETLIB_UPDATEI() { }
NETLIB_UPDATE_TERMINALSI() { }
//NETLIB_UPDATEI() { }
//NETLIB_UPDATE_TERMINALSI() { }
private:
param_model_t m_model;
@ -1799,8 +1750,8 @@ namespace netlist
device_arena m_pool; // must be deleted last!
device_arena::unique_ptr<netlist_t> m_netlist;
host_arena::unique_ptr<plib::dynlib_base> m_lib;
plib::state_manager_t m_state;
std::unique_ptr<plib::dynlib_base> m_lib;
plib::state_manager_t m_state;
host_arena::unique_ptr<callbacks_t> m_callbacks;
log_type m_log;
@ -2205,13 +2156,6 @@ namespace netlist
// logic_input_t
// -----------------------------------------------------------------------------
#if 0
template <class D>
logic_input_t::logic_input_t(D &dev, const pstring &aname)
: logic_input_t(dev, aname, STATE_INP_ACTIVE, nldelegate(&D :: update, &dev))
{
}
#endif
inline void logic_input_t::inactivate() noexcept
{
if (!is_state(STATE_INP_PASSIVE))

View File

@ -44,6 +44,17 @@
#define NL_USE_MEMPOOL (1)
#endif
/// brief default minimum alignment of mempool_arena
///
/// 256 is the best compromise between logic applications like MAME
/// TTL games (e.g. pong) and analog applications like e.g. kidnikik sound.
///
/// Best performance for pong is achieved with a value of 16, but this degrades
/// kidniki performance by ~10%.
///
/// More work is needed here.
#define NL_MEMPOOL_ALIGN (16)
/// \brief Enable queue statistics.
///
/// Queue statistics come at a performance cost. Although

View File

@ -12,6 +12,7 @@
#include "plib/palloc.h"
#include "plib/ptypes.h"
#include "plib/putil.h"
#include "plib/pmempool.h"
#include <tuple>
#include <utility>
@ -38,8 +39,6 @@
factory::constructor_ptr_t decl_ ## p_alias = NETLIB_NAME(p_alias ## _c);
namespace netlist {
class core_device_t;
class netlist_state_t;
namespace factory {

View File

@ -13,9 +13,9 @@
#include "plib/ppreprocessor.h"
#include "plib/pstream.h"
#include "plib/pstring.h"
#include "plib/putil.h"
#include "nl_config.h"
// FIXME: avoid including factory
#include "nl_factory.h"
#include "nltypes.h"
@ -134,25 +134,6 @@ void NETLIST_NAME(name)(netlist::nlparse_t &setup) \
namespace netlist
{
namespace detail {
class core_terminal_t;
class net_t;
} // namespace detail
namespace devices {
class nld_base_proxy;
class nld_netlistparams;
} // namespace devices
class core_device_t;
class param_t;
class nlparse_t;
class setup_t;
class netlist_state_t;
class netlist_t;
class logic_family_desc_t;
class terminal_t;
// -----------------------------------------------------------------------------
// truthtable desc
// -----------------------------------------------------------------------------
@ -191,32 +172,6 @@ namespace netlist
param_t *m_param;
};
// ----------------------------------------------------------------------------------------
// Specific netlist psource_t implementations
// ----------------------------------------------------------------------------------------
class source_netlist_t : public plib::psource_t
{
public:
source_netlist_t() = default;
PCOPYASSIGNMOVE(source_netlist_t, delete)
~source_netlist_t() noexcept override = default;
virtual bool parse(nlparse_t &setup, const pstring &name);
};
class source_data_t : public plib::psource_t
{
public:
source_data_t() = default;
PCOPYASSIGNMOVE(source_data_t, delete)
~source_data_t() noexcept override = default;
};
// ----------------------------------------------------------------------------------------
// Collection of models
// ----------------------------------------------------------------------------------------
@ -500,9 +455,31 @@ namespace netlist
};
// ----------------------------------------------------------------------------------------
// base sources
// Specific netlist psource_t implementations
// ----------------------------------------------------------------------------------------
class source_netlist_t : public plib::psource_t
{
public:
source_netlist_t() = default;
PCOPYASSIGNMOVE(source_netlist_t, delete)
~source_netlist_t() noexcept override = default;
virtual bool parse(nlparse_t &setup, const pstring &name);
};
class source_data_t : public plib::psource_t
{
public:
source_data_t() = default;
PCOPYASSIGNMOVE(source_data_t, delete)
~source_data_t() noexcept override = default;
};
class source_string_t : public source_netlist_t
{
public:

View File

@ -13,19 +13,94 @@
#define NLTYPES_H_
#include "nl_config.h"
#include "plib/pchrono.h"
#include "plib/pdynlib.h"
#include "plib/pfmtlog.h"
#include "plib/pmempool.h"
#include "plib/pstate.h"
//#include "plib/pchrono.h"
#include "plib/ptypes.h"
#include "plib/pstring.h"
#include "plib/ptime.h"
#include "plib/putil.h"
#include <unordered_map>
#include <memory>
// FIXME: Move to ptypes
namespace plib
{
// FORWARD declarations
template <typename BASEARENA, std::size_t MINALIGN>
class mempool_arena;
struct aligned_arena;
class dynlib_base;
template<class T, bool debug_enabled>
class plog_base;
struct plog_level;
}
namespace netlist
{
// -----------------------------------------------------------------------------
// forward definitions
// -----------------------------------------------------------------------------
class logic_output_t;
class logic_input_t;
class analog_net_t;
class logic_net_t;
class setup_t;
class nlparse_t;
class netlist_t;
class netlist_state_t;
class core_device_t;
class device_t;
class netlist_state_t;
class param_t;
class logic_family_desc_t;
class terminal_t;
namespace devices
{
class nld_solver;
class nld_mainclock;
class nld_base_proxy;
class nld_base_d_to_a_proxy;
class nld_base_a_to_d_proxy;
class nld_netlistparams;
} // namespace devices
namespace solver
{
class matrix_solver_t;
} // namespace solver
namespace detail
{
class core_terminal_t;
class net_t;
} // namespace detail
namespace factory
{
class list_t;
class element_t;
struct properties;
} // namespace factory
template <class CX>
class delegator_t : public CX
{
protected:
using base_type = delegator_t<CX>;
using delegated_type = CX;
using delegated_type::delegated_type;
};
} // namespace netlist
namespace netlist
{
/// \brief Constants and const calculations for the library
///
template<typename T>
@ -79,7 +154,7 @@ namespace netlist
///
using device_arena = std::conditional_t<config::use_mempool::value,
plib::mempool_arena<plib::aligned_arena>,
plib::mempool_arena<plib::aligned_arena, NL_MEMPOOL_ALIGN>,
plib::aligned_arena>;
using host_arena = plib::aligned_arena;
@ -109,7 +184,7 @@ namespace netlist
/// of a callbacks_t implementation to optionally provide such a collection
/// of symbols.
///
virtual host_arena::unique_ptr<plib::dynlib_base> static_solver_lib() const;
virtual std::unique_ptr<plib::dynlib_base> static_solver_lib() const;
};
using log_type = plib::plog_base<callbacks_t, NL_DEBUG>;

View File

@ -249,8 +249,8 @@ namespace plib
A[k] = src.A[k];
}
index_type * nzbd(index_type row) { return m_nzbd[row]; }
index_type nzbd_count(index_type row) { return m_nzbd.colcount(row) - 1; }
index_type * nzbd(std::size_t row) { return m_nzbd[row]; }
std::size_t nzbd_count(std::size_t row) { return m_nzbd.colcount(row) - 1; }
protected:
// FIXME: this should be private
// NOLINTNEXTLINE
@ -320,14 +320,9 @@ namespace plib
std::size_t pi = base::diag[i];
auto f = reciprocal(base::A[pi++]);
const std::size_t piie = base::row_idx[i+1];
#if 0
const auto &nz = base::m_nzbd[i];
while (auto j = nz[nzbdp++]) // NOLINT(bugprone-infinite-loop)
#else
const auto *nz = base::m_nzbd[i];
while (auto j = nz[nzbdp++]) // NOLINT(bugprone-infinite-loop)
#endif
{
// proceed to column i

View File

@ -10,8 +10,7 @@
#include "pconfig.h"
#include "pgsl.h"
#include "pmath.h"
#include "pstring.h"
#include "pmath.h" // FIXME: only uses lcm ... move to ptypes.
#include "ptypes.h"
#include <algorithm>
@ -254,6 +253,8 @@ namespace plib {
//~arena_allocator() noexcept = default;
PCOPYASSIGNMOVE(arena_allocator, default)
explicit arena_allocator(arena_type & a) noexcept : m_a(a)
{
}

View File

@ -74,17 +74,6 @@
#define PALIGNAS_CACHELINE() PALIGNAS(PALIGN_CACHELINE)
#define PALIGNAS_VECTOROPT() PALIGNAS(PALIGN_VECTOROPT)
/// brief default minimum alignment of mempool_arena
///
/// 256 is the best compromise between logic applications like MAME
/// TTL games (e.g. pong) and analog applications like e.g. kidnikik sound.
///
/// Best performance for pong is achieved with a value of 16, but this degrades
/// kidniki performance by ~10%.
///
/// More work is needed here.
#define PMEMPOOL_ALIGN (256)
// FIXME: Breaks mame build on windows mingw due to -Wattribute
// also triggers -Wattribute on ARM
// This is fixed on mingw version 10

View File

@ -9,8 +9,6 @@
///
#include "pstring.h"
#include "pstrutil.h"
#include "putil.h"
namespace plib
{

View File

@ -5,13 +5,12 @@
/// \file pfmtlog.h
///
#ifndef PFMT_H_
#define PFMT_H_
#ifndef PFMTLOG_H_
#define PFMTLOG_H_
#include "penum.h"
#include "pstring.h"
#include "ptypes.h"
#include "putil.h"
#include <limits>
#include <locale>
@ -423,4 +422,4 @@ namespace plib {
template<typename T>
plib::pfmt& operator<<(plib::pfmt &p, T&& val) { return p(std::forward<T>(val)); }
#endif // PSTRING_H_
#endif // PFMT_LOG_H_

View File

@ -10,7 +10,6 @@
#include "pmath.h"
#include "pstring.h"
#include "putil.h"
#include <vector>

View File

@ -8,9 +8,7 @@
/// \file plists.h
///
#include "palloc.h"
#include "pchrono.h"
#include "pstring.h"
#include "ptypes.h"
#include <algorithm>
#include <array>

View File

@ -154,6 +154,8 @@ namespace plib
m_v.resize(N); //FIXME
}
PCOPYASSIGNMOVE(pmatrix2d_vrl, default)
void resize(size_type N, size_type M)
{
m_N = N;

View File

@ -10,10 +10,10 @@
#include "palloc.h"
#include "pconfig.h"
#include "pstream.h"
#include "pstring.h"
#include "pstream.h" // perrlogger
//#include "pstring.h"
#include "ptypes.h"
#include "putil.h"
//#include "putil.h"
#include <algorithm>
#include <memory>
@ -27,13 +27,13 @@ namespace plib {
// Memory pool
//============================================================
template <typename BASEARENA, std::size_t MINALIGN = PMEMPOOL_ALIGN>
class mempool_arena : public arena_base<mempool_arena<BASEARENA>, false, false>
template <typename BASEARENA, std::size_t MINALIGN = PALIGN_MIN_SIZE>
class mempool_arena : public arena_base<mempool_arena<BASEARENA, MINALIGN>, false, false>
{
public:
using size_type = typename BASEARENA::size_type;
using base_type = arena_base<mempool_arena<BASEARENA>, false, false>;
using base_type = arena_base<mempool_arena<BASEARENA, MINALIGN>, false, false>;
template <class T>
using base_allocator_type = typename BASEARENA::template allocator_type<T>;

View File

@ -34,7 +34,6 @@
#include "pconfig.h"
#include "ptypes.h"
#include "putil.h"
#include <algorithm>
#include <cstdint> // uintptr_t

View File

@ -5,6 +5,7 @@
#include "palloc.h"
#include "pstonum.h"
#include "putil.h"
#include "pstrutil.h"
namespace plib {

View File

@ -8,7 +8,6 @@
/// \file pstate.h
///
#include "palloc.h"
#include "pstring.h"
#include "ptypes.h"
@ -54,7 +53,7 @@ public:
plib::is_floating_point<T>::value);
}
class callback_t
struct callback_t
{
public:
using list_t = std::vector<callback_t *>;
@ -201,7 +200,6 @@ private:
save_state_ptr( owner, stname, dtype<C>(), 1, &state);
}
template<typename C>
std::enable_if_t<!(plib::is_integral<C>::value || std::is_enum<C>::value
|| plib::is_floating_point<C>::value)>

View File

@ -9,12 +9,10 @@
/// \file pstream.h
///
#include "palloc.h"
#include "pconfig.h"
#include "pexception.h"
#include "pfmtlog.h"
#include "pstring.h"
#include "pstrutil.h"
#include "pgsl.h"
#include <array>
#include <fstream>
@ -34,7 +32,6 @@ namespace plib {
{
using ct = typename S::char_type;
static_assert((sizeof(T) % sizeof(ct)) == 0, "istream_read sizeof issue");
// FIXME: throw on
return is.read(reinterpret_cast<ct *>(data), gsl::narrow<std::streamsize>(len * sizeof(T)));
}
@ -45,7 +42,6 @@ namespace plib {
{
using ct = typename S::char_type;
static_assert((sizeof(T) % sizeof(ct)) == 0, "ostream_write sizeof issue");
// FIXME: throw on
return os.write(reinterpret_cast<const ct *>(data), gsl::narrow<std::streamsize>(len * sizeof(T)));
}
@ -155,7 +151,8 @@ public:
{
// NOLINTNEXTLINE(performance-unnecessary-copy-initialization)
const putf8string conv_utf8(text);
m_strm->write(conv_utf8.c_str(), static_cast<std::streamsize>(plib::strlen(conv_utf8.c_str())));
//m_strm->write(conv_utf8.c_str(), static_cast<std::streamsize>(plib::strlen(conv_utf8.c_str() )));
ostream_write(*m_strm, conv_utf8.c_str(), string_info<pstring>::mem_size(conv_utf8));
}
void write(const pstring::value_type c) const

View File

@ -209,10 +209,9 @@ public:
static constexpr const size_type npos = static_cast<size_type>(-1);
// the following are extensions to <string>
private:
// FIXME: remove those
size_type mem_t_size() const noexcept { return m_str.size(); }
private:
string_type m_str;
};
@ -254,6 +253,7 @@ struct putf_traits<1, CT>
}
return ret;
}
static std::size_t codelen(const mem_t *p) noexcept
{
const auto *p1 = reinterpret_cast<const unsigned char *>(p);
@ -460,6 +460,28 @@ using putf16string = pstring_t<putf16_traits>;
using putf32string = pstring_t<putf32_traits>;
using pwstring = pstring_t<pwchar_traits>;
namespace plib
{
template<class T>
struct string_info
{
};
template<typename T>
struct string_info<pstring_t<T>>
{
using mem_t = typename T::mem_t;
static std::size_t mem_size(const pstring_t<T> &s) { return s.mem_t_size(); }
};
template<typename T>
struct string_info<std::basic_string<T>>
{
using mem_t = T;
static std::size_t mem_size(const std::string &s) { return s.size(); }
};
} // namespace plib
// custom specialization of std::hash can be injected in namespace std
namespace std
{

View File

@ -21,18 +21,6 @@
namespace plib
{
template<class T>
struct string_info
{
using mem_t = typename T::mem_t;
};
template<>
struct string_info<std::string>
{
using mem_t = char;
};
template<typename T>
pstring to_string(const T &v)
{

View File

@ -8,10 +8,9 @@
/// \file ptimed_queue.h
///
#include "palloc.h"
#include "pchrono.h"
#include "pmulti_threading.h"
#include "pstring.h"
#include "ptypes.h"
#include <algorithm>
#include <mutex>

View File

@ -23,19 +23,17 @@
#endif
// noexcept on move operator -> issue with macosx clang
#define PCOPYASSIGNMOVE(name, def) \
name(const name &) = def; \
name(name &&) noexcept = def; \
name &operator=(const name &) = def; \
name &operator=(name &&) noexcept = def;
#define PCOPYASSIGNMOVE(name, def) \
PCOPYASSIGN(name, def) \
PMOVEASSIGN(name, def)
#define PCOPYASSIGN(name, def) \
name(const name &) = def; \
name &operator=(const name &) = def; \
name(const name &) = def; \
name &operator=(const name &) = def;
#define PMOVEASSIGN(name, def) \
name(name &&) noexcept = def; \
name &operator=(name &&) noexcept = def;
name(name &&) /*noexcept*/ = def; \
name &operator=(name &&) /*noexcept*/ = def;
namespace plib
{
@ -261,12 +259,34 @@ namespace plib
using type = typename fast_type_for_size<size_for_bits<bits>::value>::type;
};
//============================================================
// Avoid unused variable warnings
//============================================================
/// \brief mark arguments as not used for compiler
///
/// @tparam Ts unsused parameters
///
template<typename... Ts>
inline void unused_var(Ts&&...) noexcept {} // NOLINT(readability-named-parameter)
/// \brief copy type S to type D byte by byte
///
/// The purpose of this copy function is to suppress compiler warnings.
/// Use at your own risk. This is dangerous.
///
/// \param s Source object
/// \param d Destination object
/// \tparam S Type of source object
/// \tparam D Type of destination object
template <typename S, typename D>
void reinterpret_copy(S &s, D &d)
{
static_assert(sizeof(D) >= sizeof(S), "size mismatch");
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
auto *dp = reinterpret_cast<std::uint8_t *>(&d);
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
const auto *sp = reinterpret_cast<std::uint8_t *>(&s);
std::copy(sp, sp + sizeof(S), dp);
}
} // namespace plib
//============================================================

View File

@ -249,26 +249,6 @@ namespace plib
list_t m_collection;
};
/// \brief copy type S to type D byte by byte
///
/// The purpose of this copy function is to suppress compiler warnings.
/// Use at your own risk. This is dangerous.
///
/// \param s Source object
/// \param d Destination object
/// \tparam S Type of source object
/// \tparam D Type of destination object
template <typename S, typename D>
void reinterpret_copy(S &s, D &d)
{
static_assert(sizeof(D) >= sizeof(S), "size mismatch");
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
auto *dp = reinterpret_cast<std::uint8_t *>(&d);
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
const auto *sp = reinterpret_cast<std::uint8_t *>(&s);
std::copy(sp, sp + sizeof(S), dp);
}
namespace util
{
pstring basename(const pstring &filename, const pstring &suffix = "");

View File

@ -9,6 +9,7 @@
//
// ***************************************************************************
#include "netlist/plib/pdynlib.h"
#include "netlist/plib/pmain.h"
#include "netlist/devices/net_lib.h"
#include "netlist/nl_errstr.h"
@ -222,17 +223,17 @@ public:
void vlog(const plib::plog_level &l, const pstring &ls) const noexcept override;
netlist::host_arena::unique_ptr<plib::dynlib_base> static_solver_lib() const override
std::unique_ptr<plib::dynlib_base> static_solver_lib() const override
{
if (m_boostlib == "builtin")
return plib::make_unique<plib::dynlib_static, netlist::host_arena>(nl_static_solver_syms);
return std::make_unique<plib::dynlib_static>(nl_static_solver_syms);
if (m_boostlib == "generic")
return plib::make_unique<plib::dynlib_static, netlist::host_arena>(nullptr);
return std::make_unique<plib::dynlib_static>(nullptr);
if (NL_DISABLE_DYNAMIC_LOAD)
throw netlist::nl_exception("Dynamic library loading not supported due to project security concerns.");
//pstring libpath = plib::util::environment("NL_BOOSTLIB", plib::util::buildpath({".", "nlboost.so"}));
return plib::make_unique<plib::dynlib, netlist::host_arena>(m_boostlib);
return std::make_unique<plib::dynlib>(m_boostlib);
}
private:

View File

@ -1,10 +1,10 @@
// license:GPL-2.0+
// copyright-holders:Couriersud
#include "netlist/plib/pstring.h"
//#include "netlist/nl_setup.h"
#include "netlist/plib/pmain.h"
#include "netlist/plib/ppmf.h"
#include "netlist/plib/pstream.h"
#include "netlist/plib/pstrutil.h"
#include <cstdio>

View File

@ -37,7 +37,7 @@ namespace solver
// ----------------------------------------------------------------------------------------
matrix_solver_t::matrix_solver_t(netlist_state_t &anetlist, const pstring &name,
const analog_net_t::list_t &nets,
const net_list_t &nets,
const solver_parameters_t *params)
: device_t(anetlist, name)
, m_params(*params)
@ -67,7 +67,7 @@ namespace solver
return &state().setup().get_connected_terminal(*term)->net();
}
void matrix_solver_t::setup_base(setup_t &setup, const analog_net_t::list_t &nets)
void matrix_solver_t::setup_base(setup_t &setup, const net_list_t &nets)
{
log().debug("New solver setup\n");
std::vector<core_device_t *> step_devices;

View File

@ -186,6 +186,7 @@ namespace solver
using list_t = std::vector<matrix_solver_t *>;
using fptype = nl_fptype;
using arena_type = plib::mempool_arena<plib::aligned_arena, PALIGN_VECTOROPT>;
using net_list_t = plib::aligned_vector<analog_net_t *>;
// after every call to solve, update inputs must be called.
// this can be done as well as a batch to ease parallel processing.
@ -266,7 +267,7 @@ namespace solver
protected:
matrix_solver_t(netlist_state_t &anetlist, const pstring &name,
const analog_net_t::list_t &nets,
const net_list_t &nets,
const solver_parameters_t *params);
virtual void vsolve_non_dynamic() = 0;
@ -289,7 +290,7 @@ namespace solver
private:
// base setup - called from constructor
void setup_base(setup_t &setup, const analog_net_t::list_t &nets) noexcept(false);
void setup_base(setup_t &setup, const net_list_t &nets) noexcept(false);
void sort_terms(matrix_sort_type_e sort);

View File

@ -25,7 +25,7 @@ namespace solver
using float_type = FT;
matrix_solver_ext_t(netlist_state_t &anetlist, const pstring &name,
const analog_net_t::list_t &nets,
const net_list_t &nets,
const solver_parameters_t *params, const std::size_t size)
: matrix_solver_t(anetlist, name, nets, params)
, m_new_V(size)

View File

@ -30,7 +30,7 @@ namespace solver
using float_type = FT;
matrix_solver_direct_t(netlist_state_t &anetlist, const pstring &name,
const analog_net_t::list_t &nets,
const matrix_solver_t::net_list_t &nets,
const solver_parameters_t *params, std::size_t size);
void reset() override { matrix_solver_t::reset(); }
@ -189,7 +189,7 @@ namespace solver
template <typename FT, int SIZE>
matrix_solver_direct_t<FT, SIZE>::matrix_solver_direct_t(netlist_state_t &anetlist, const pstring &name,
const analog_net_t::list_t &nets,
const matrix_solver_t::net_list_t &nets,
const solver_parameters_t *params,
std::size_t size)
: matrix_solver_ext_t<FT, SIZE>(anetlist, name, nets, params, size)

View File

@ -25,7 +25,7 @@ namespace solver
using base_type = matrix_solver_direct_t<FT, 1>;
matrix_solver_direct1_t(netlist_state_t &anetlist, const pstring &name,
const analog_net_t::list_t &nets,
const matrix_solver_t::net_list_t &nets,
const solver_parameters_t *params)
: matrix_solver_direct_t<FT, 1>(anetlist, name, nets, params, 1)
{}

View File

@ -29,7 +29,7 @@ namespace solver
using float_type = FT;
matrix_solver_direct2_t(netlist_state_t &anetlist, const pstring &name,
const analog_net_t::list_t &nets,
const matrix_solver_t::net_list_t &nets,
const solver_parameters_t *params)
: matrix_solver_direct_t<FT, 2>(anetlist, name, nets, params, 2)
{}

View File

@ -36,7 +36,7 @@ namespace solver
using fptype = typename base_type::fptype;
matrix_solver_GCR_t(netlist_state_t &anetlist, const pstring &name,
const analog_net_t::list_t &nets,
const matrix_solver_t::net_list_t &nets,
const solver_parameters_t *params, const std::size_t size)
: matrix_solver_ext_t<FT, SIZE>(anetlist, name, nets, params, size)
, mat(static_cast<typename mat_type::index_type>(size))

View File

@ -35,7 +35,7 @@ namespace solver
// This is already preconditioning.
matrix_solver_GMRES_t(netlist_state_t &anetlist, const pstring &name,
analog_net_t::list_t &nets,
matrix_solver_t::net_list_t &nets,
const solver_parameters_t *params,
const std::size_t size)
: matrix_solver_direct_t<FT, SIZE>(anetlist, name, nets, params, size)

View File

@ -55,7 +55,7 @@ namespace solver
static constexpr const std::size_t storage_N = 100;
matrix_solver_sm_t(netlist_state_t &anetlist, const pstring &name,
const analog_net_t::list_t &nets,
const matrix_solver_t::net_list_t &nets,
const solver_parameters_t *params, const std::size_t size)
: matrix_solver_ext_t<FT, SIZE>(anetlist, name, nets, params, size)
, m_cnt(0)

View File

@ -30,7 +30,7 @@ namespace solver
using float_type = FT;
matrix_solver_SOR_t(netlist_state_t &anetlist, const pstring &name,
analog_net_t::list_t &nets,
matrix_solver_t::net_list_t &nets,
const solver_parameters_t *params, const std::size_t size)
: matrix_solver_direct_t<FT, SIZE>(anetlist, name, nets, params, size)
, m_lp_fact(*this, "m_lp_fact", 0)

View File

@ -30,7 +30,7 @@ namespace solver
using float_type = FT;
matrix_solver_SOR_mat_t(netlist_state_t &anetlist, const pstring &name,
const analog_net_t::list_t &nets,
const matrix_solver_t::net_list_t &nets,
const solver_parameters_t *params, std::size_t size)
: matrix_solver_direct_t<FT, SIZE>(anetlist, name, nets, params, size)
, m_omega(*this, "m_omega", static_cast<float_type>(params->m_gs_sor))

View File

@ -61,7 +61,7 @@ namespace solver
static constexpr const std::size_t storage_N = 100;
matrix_solver_w_t(netlist_state_t &anetlist, const pstring &name,
const analog_net_t::list_t &nets,
const matrix_solver_t::net_list_t &nets,
const solver_parameters_t *params, const std::size_t size)
: matrix_solver_ext_t<FT, SIZE>(anetlist, name, nets, params, size)
, m_cnt(0)
@ -79,7 +79,6 @@ namespace solver
template <typename T>
void LE_compute_x(T & x);
template <typename T1, typename T2>
float_ext_type &A(const T1 &r, const T2 &c) { return m_A[r][c]; }
template <typename T1, typename T2>

View File

@ -86,7 +86,7 @@ namespace devices
// FIXME: should be created in device space
template <class C>
NETLIB_NAME(solver)::solver_ptr create_it(netlist_state_t &nl, pstring name,
analog_net_t::list_t &nets,
NETLIB_NAME(solver)::net_list_t &nets,
solver::solver_parameters_t &params, std::size_t size)
{
return plib::make_unique<C, host_arena>(nl, name, nets, &params, size);
@ -96,7 +96,7 @@ namespace devices
template <typename FT, int SIZE>
NETLIB_NAME(solver)::solver_ptr NETLIB_NAME(solver)::create_solver(std::size_t size,
const pstring &solvername,
analog_net_t::list_t &nets)
NETLIB_NAME(solver)::net_list_t &nets)
{
switch (m_params.m_method())
{
@ -133,7 +133,7 @@ namespace devices
template <typename FT>
NETLIB_NAME(solver)::solver_ptr NETLIB_NAME(solver)::create_solvers(
const pstring &sname,
analog_net_t::list_t &nets)
net_list_t &nets)
{
std::size_t net_count = nets.size();
switch (net_count)
@ -200,7 +200,7 @@ namespace devices
auto &n = dynamic_cast<analog_net_t &>(*net);
if (!already_processed(n))
{
groupspre.emplace_back(analog_net_t::list_t());
groupspre.emplace_back(NETLIB_NAME(solver)::net_list_t());
process_net(netlist, n);
}
}
@ -210,7 +210,7 @@ namespace devices
groups.push_back(g);
}
std::vector<analog_net_t::list_t> groups;
std::vector<NETLIB_NAME(solver)::net_list_t> groups;
private:
@ -280,7 +280,7 @@ namespace devices
}
}
std::vector<analog_net_t::list_t> groupspre;
std::vector<NETLIB_NAME(solver)::net_list_t> groupspre;
};
void NETLIB_NAME(solver)::post_start()

View File

@ -49,6 +49,7 @@ namespace devices
//using solver_ptr = device_arena::unique_ptr<solver::matrix_solver_t>;
using solver_ptr = host_arena::unique_ptr<solver::matrix_solver_t>;
using net_list_t = solver::matrix_solver_t::net_list_t;
private:
logic_input_t m_fb_step;
@ -63,11 +64,11 @@ namespace devices
template <typename FT, int SIZE>
solver_ptr create_solver(std::size_t size,
const pstring &solvername, analog_net_t::list_t &nets);
const pstring &solvername, net_list_t &nets);
template <typename FT>
solver_ptr create_solvers(
const pstring &sname, analog_net_t::list_t &nets);
const pstring &sname, net_list_t &nets);
};
} // namespace devices

View File

@ -4,6 +4,7 @@
#include "plib/palloc.h"
#include "plib/pstonum.h"
#include "plib/putil.h"
#include "plib/pstrutil.h"
#include "nl_convert.h"