mirror of
https://github.com/holub/mame
synced 2025-04-22 00:11:58 +03:00
Netlist refactoring:
- OPENMP refactored. All OPENMP operations are now templatized in pomp.h - We don't need thread-safe priority queue. Event code updating analog outputs now runs outside the parallel code. (nw)
This commit is contained in:
parent
01f8ace296
commit
bc29593982
@ -62,13 +62,14 @@ project "netlist"
|
||||
MAME_DIR .. "src/lib/netlist/plib/plists.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pdynlib.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pdynlib.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pmain.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pmain.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pmain.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pmain.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pomp.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/poptions.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/plib/poptions.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pparser.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pparser.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/ppmf.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/ppmf.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pstate.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pstate.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pstring.cpp",
|
||||
@ -86,11 +87,11 @@ project "netlist"
|
||||
MAME_DIR .. "src/lib/netlist/analog/nld_bjt.h",
|
||||
MAME_DIR .. "src/lib/netlist/analog/nlid_fourterm.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/analog/nlid_fourterm.h",
|
||||
MAME_DIR .. "src/lib/netlist/analog/nld_fourterm.h",
|
||||
MAME_DIR .. "src/lib/netlist/analog/nld_fourterm.h",
|
||||
MAME_DIR .. "src/lib/netlist/analog/nld_switches.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/analog/nld_switches.h",
|
||||
MAME_DIR .. "src/lib/netlist/analog/nlid_twoterm.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/analog/nlid_twoterm.h",
|
||||
MAME_DIR .. "src/lib/netlist/analog/nlid_twoterm.h",
|
||||
MAME_DIR .. "src/lib/netlist/analog/nld_twoterm.h",
|
||||
MAME_DIR .. "src/lib/netlist/analog/nld_opamps.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/analog/nld_opamps.h",
|
||||
|
@ -147,7 +147,7 @@ const logic_family_desc_t *family_CD4XXX()
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
detail::queue_t::queue_t(netlist_t &nl)
|
||||
: timed_queue<pqentry_t<net_t *, netlist_time>>(512)
|
||||
: timed_queue<pqentry_t<net_t *, netlist_time>, false>(512)
|
||||
, netlist_ref(nl)
|
||||
, plib::state_manager_t::callback_t()
|
||||
, m_qsize(0)
|
||||
|
@ -1186,8 +1186,11 @@ namespace netlist
|
||||
// queue_t
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/* We don't need a thread-safe queue currently. Parallel processing of
|
||||
* solvers will update inputs after parallel processing.
|
||||
*/
|
||||
class detail::queue_t :
|
||||
public timed_queue<pqentry_t<net_t *, netlist_time>>,
|
||||
public timed_queue<pqentry_t<net_t *, netlist_time>, false>,
|
||||
public detail::netlist_ref,
|
||||
public plib::state_manager_t::callback_t
|
||||
{
|
||||
|
@ -77,7 +77,9 @@
|
||||
// General
|
||||
//============================================================
|
||||
|
||||
// The following adds about 10% performance ...
|
||||
/* The following adds about 10% to 20% performance for analog
|
||||
* netlists like kidniki.
|
||||
*/
|
||||
|
||||
#if !defined(USE_OPENMP)
|
||||
#define USE_OPENMP (0)
|
||||
@ -85,9 +87,10 @@
|
||||
|
||||
// Use nano-second resolution - Sufficient for now
|
||||
#define NETLIST_INTERNAL_RES (UINT64_C(1000000000))
|
||||
//#define NETLIST_INTERNAL_RES (UINT64_C(1000000000000))
|
||||
|
||||
#define NETLIST_CLOCK (NETLIST_INTERNAL_RES)
|
||||
//#define NETLIST_INTERNAL_RES (UINT64_C(1000000000000))
|
||||
//#define NETLIST_CLOCK (UINT64_C(1000000000))
|
||||
|
||||
|
||||
//#define nl_double float
|
||||
//#define NL_FCONST(x) (x ## f)
|
||||
|
@ -26,7 +26,15 @@
|
||||
// timed queue
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* Use -DUSE_HEAP=1 to use stdc++ heap functions instead of linear processing.
|
||||
*
|
||||
* This slows down processing by about 25% on a Kaby Lake.
|
||||
*/
|
||||
|
||||
#ifndef USE_HEAP
|
||||
#define USE_HEAP (0)
|
||||
#endif
|
||||
|
||||
namespace netlist
|
||||
{
|
||||
@ -92,7 +100,8 @@ namespace netlist
|
||||
};
|
||||
|
||||
#if !USE_HEAP
|
||||
template <class T, class QueueOp = typename T::QueueOp>
|
||||
/* Use TS = true for a threadsafe queue */
|
||||
template <class T, bool TS, class QueueOp = typename T::QueueOp>
|
||||
class timed_queue : plib::nocopyassignmove
|
||||
{
|
||||
public:
|
||||
@ -183,11 +192,7 @@ namespace netlist
|
||||
constexpr std::size_t size() const noexcept { return static_cast<std::size_t>(m_end - &m_list[1]); }
|
||||
constexpr const T & operator[](const std::size_t index) const noexcept { return m_list[ 1 + index]; }
|
||||
private:
|
||||
#if HAS_OPENMP && USE_OPENMP
|
||||
using tqmutex = pspin_mutex<true>;
|
||||
#else
|
||||
using tqmutex = pspin_mutex<false>;
|
||||
#endif
|
||||
using tqmutex = pspin_mutex<TS>;
|
||||
using tqlock = std::lock_guard<tqmutex>;
|
||||
|
||||
tqmutex m_lock;
|
||||
@ -200,7 +205,7 @@ namespace netlist
|
||||
nperfcount_t m_prof_call;
|
||||
};
|
||||
#else
|
||||
template <class T, class QueueOp = typename T::QueueOp>
|
||||
template <class T, bool TS, class QueueOp = typename T::QueueOp>
|
||||
class timed_queue : plib::nocopyassignmove
|
||||
{
|
||||
public:
|
||||
@ -282,11 +287,7 @@ namespace netlist
|
||||
constexpr std::size_t size() const noexcept { return m_list.size(); }
|
||||
constexpr const T & operator[](const std::size_t index) const { return m_list[ 0 + index]; }
|
||||
private:
|
||||
#if HAS_OPENMP && USE_OPENMP
|
||||
using tqmutex = pspin_mutex<true>;
|
||||
#else
|
||||
using tqmutex = pspin_mutex<false>;
|
||||
#endif
|
||||
using tqmutex = pspin_mutex<TS>;
|
||||
using tqlock = std::lock_guard<tqmutex>;
|
||||
|
||||
tqmutex m_lock;
|
||||
|
60
src/lib/netlist/plib/pomp.h
Normal file
60
src/lib/netlist/plib/pomp.h
Normal file
@ -0,0 +1,60 @@
|
||||
// license:GPL-2.0+
|
||||
// copyright-holders:Couriersud
|
||||
/*
|
||||
* pomp.h
|
||||
*
|
||||
* Wrap all OPENMP stuff here in a hopefully c++ compliant way.
|
||||
*/
|
||||
|
||||
#ifndef POMP_H_
|
||||
#define POMP_H_
|
||||
|
||||
#include "pconfig.h"
|
||||
|
||||
#if HAS_OPENMP
|
||||
#include "omp.h"
|
||||
#endif
|
||||
|
||||
namespace plib {
|
||||
namespace omp {
|
||||
|
||||
template <class T>
|
||||
void for_static(const int start, const int end, const T &what)
|
||||
{
|
||||
#if HAS_OPENMP && USE_OPENMP
|
||||
#pragma omp parallel
|
||||
#endif
|
||||
{
|
||||
#if HAS_OPENMP && USE_OPENMP
|
||||
#pragma omp for schedule(static)
|
||||
#endif
|
||||
for (int i = start; i < end; i++)
|
||||
what(i);
|
||||
}
|
||||
}
|
||||
|
||||
inline void set_num_threads(const int threads)
|
||||
{
|
||||
#if HAS_OPENMP && USE_OPENMP
|
||||
omp_set_num_threads(threads);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline int get_max_threads()
|
||||
{
|
||||
#if HAS_OPENMP && USE_OPENMP
|
||||
return omp_get_max_threads();
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// pdynlib: dynamic loading of libraries ...
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* PSTRING_H_ */
|
@ -102,7 +102,7 @@ NETLIB_UPDATE(solver)
|
||||
if (nthreads > 1 && t_cnt > 1)
|
||||
{
|
||||
plib::omp::set_num_threads(nthreads);
|
||||
plib::omp::for_static(0, t_cnt, [this, solv](int i) { ATTR_UNUSED const netlist_time ts = this->m_mat_solvers[solv[i]]->solve(); });
|
||||
plib::omp::for_static(0, t_cnt, [this, &solv](int i) { ATTR_UNUSED const netlist_time ts = this->m_mat_solvers[solv[i]]->solve(); });
|
||||
}
|
||||
else
|
||||
for (auto & solver : m_mat_solvers)
|
||||
|
Loading…
Reference in New Issue
Block a user