mirror of
https://github.com/holub/mame
synced 2025-10-06 09:00:04 +03:00
Remove dependency on osd_ticks. Converted palloc and friends into
templates. First effort on a separate plib namespace. (nw)
This commit is contained in:
parent
0522e44d2f
commit
111c5a3dc0
@ -253,7 +253,7 @@ ATTR_COLD void netlist_t::start()
|
|||||||
|
|
||||||
pstring libpath = nl_util::environment("NL_BOOSTLIB", nl_util::buildpath({".", "nlboost.so"}));
|
pstring libpath = nl_util::environment("NL_BOOSTLIB", nl_util::buildpath({".", "nlboost.so"}));
|
||||||
|
|
||||||
m_lib = palloc(pdynlib(libpath));
|
m_lib = palloc<plib::dynlib>(libpath);
|
||||||
|
|
||||||
/* make sure the solver and parameters are started first! */
|
/* make sure the solver and parameters are started first! */
|
||||||
|
|
||||||
|
@ -161,9 +161,9 @@
|
|||||||
#include "nl_lists.h"
|
#include "nl_lists.h"
|
||||||
#include "nl_time.h"
|
#include "nl_time.h"
|
||||||
#include "nl_util.h"
|
#include "nl_util.h"
|
||||||
|
#include "plib/pdynlib.h"
|
||||||
#include "plib/pstate.h"
|
#include "plib/pstate.h"
|
||||||
#include "plib/pfmtlog.h"
|
#include "plib/pfmtlog.h"
|
||||||
#include "plib/pdynlib.h"
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
// Type definitions
|
// Type definitions
|
||||||
@ -1039,7 +1039,7 @@ namespace netlist
|
|||||||
|
|
||||||
#if (NL_KEEP_STATISTICS)
|
#if (NL_KEEP_STATISTICS)
|
||||||
/* stats */
|
/* stats */
|
||||||
osd_ticks_t stat_total_time;
|
pticks_t stat_total_time;
|
||||||
INT32 stat_update_count;
|
INT32 stat_update_count;
|
||||||
INT32 stat_call_count;
|
INT32 stat_call_count;
|
||||||
#endif
|
#endif
|
||||||
@ -1266,7 +1266,7 @@ namespace netlist
|
|||||||
|
|
||||||
virtual void reset();
|
virtual void reset();
|
||||||
|
|
||||||
ATTR_COLD pdynlib &lib() { return *m_lib; }
|
ATTR_COLD plib::dynlib &lib() { return *m_lib; }
|
||||||
|
|
||||||
void print_stats() const;
|
void print_stats() const;
|
||||||
|
|
||||||
@ -1303,7 +1303,7 @@ protected:
|
|||||||
pstring m_name;
|
pstring m_name;
|
||||||
setup_t *m_setup;
|
setup_t *m_setup;
|
||||||
plog_base<NL_DEBUG> m_log;
|
plog_base<NL_DEBUG> m_log;
|
||||||
pdynlib *m_lib; // external lib needs to be loaded as long as netlist exists
|
plib::dynlib *m_lib; // external lib needs to be loaded as long as netlist exists
|
||||||
};
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -112,7 +112,7 @@
|
|||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
#define NL_DEBUG (false)
|
#define NL_DEBUG (false)
|
||||||
#define NL_KEEP_STATISTICS (0)
|
#define NL_KEEP_STATISTICS (1)
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
// General Macros
|
// General Macros
|
||||||
@ -132,8 +132,8 @@
|
|||||||
#include "eminline.h"
|
#include "eminline.h"
|
||||||
#define add_to_stat(v,x) do { v += (x); } while (0)
|
#define add_to_stat(v,x) do { v += (x); } while (0)
|
||||||
#define inc_stat(v) add_to_stat(v, 1)
|
#define inc_stat(v) add_to_stat(v, 1)
|
||||||
#define begin_timing(v) do { v -= get_profile_ticks(); } while (0)
|
#define begin_timing(v) do { v -= pprofile_ticks(); } while (0)
|
||||||
#define end_timing(v) do { v += get_profile_ticks(); } while (0)
|
#define end_timing(v) do { v += pprofile_ticks(); } while (0)
|
||||||
#else
|
#else
|
||||||
#define add_to_stat(v,x) do { } while (0)
|
#define add_to_stat(v,x) do { } while (0)
|
||||||
#define inc_stat(v) add_to_stat(v, 1)
|
#define inc_stat(v) add_to_stat(v, 1)
|
||||||
|
@ -632,7 +632,7 @@ void setup_t::connect_terminals(core_terminal_t &t1, core_terminal_t &t2)
|
|||||||
{
|
{
|
||||||
log().debug("adding analog net ...\n");
|
log().debug("adding analog net ...\n");
|
||||||
// FIXME: Nets should have a unique name
|
// FIXME: Nets should have a unique name
|
||||||
analog_net_t::ptr_t anet = palloc(analog_net_t(netlist(),"net." + t1.name()));
|
analog_net_t::ptr_t anet = palloc<analog_net_t>(netlist(),"net." + t1.name());
|
||||||
t1.set_net(anet);
|
t1.set_net(anet);
|
||||||
anet->register_con(t2);
|
anet->register_con(t2);
|
||||||
anet->register_con(t1);
|
anet->register_con(t1);
|
||||||
|
@ -19,42 +19,6 @@ pexception::pexception(const pstring &text)
|
|||||||
fprintf(stderr, "%s\n", m_text.cstr());
|
fprintf(stderr, "%s\n", m_text.cstr());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (PSTANDALONE)
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <xmmintrin.h>
|
|
||||||
|
|
||||||
class pmemory_pool
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
pmemory_pool() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
static pmemory_pool sppool;
|
|
||||||
|
|
||||||
pmemory_pool *ppool = &sppool;
|
|
||||||
|
|
||||||
void* operator new(std::size_t size, pmemory_pool *pool) throw (std::bad_alloc)
|
|
||||||
{
|
|
||||||
return palloc_raw(size);;
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator delete(void *ptr, pmemory_pool *pool)
|
|
||||||
{
|
|
||||||
if (ptr != nullptr)
|
|
||||||
pfree_raw(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *palloc_raw(const size_t size)
|
|
||||||
{
|
|
||||||
return _mm_malloc(size, 64);
|
|
||||||
}
|
|
||||||
|
|
||||||
void pfree_raw(void *p)
|
|
||||||
{
|
|
||||||
_mm_free(p);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
pmempool::pmempool(int min_alloc, int min_align)
|
pmempool::pmempool(int min_alloc, int min_align)
|
||||||
: m_min_alloc(min_alloc), m_min_align(min_align)
|
: m_min_alloc(min_alloc), m_min_align(min_align)
|
||||||
{
|
{
|
||||||
|
@ -50,76 +50,32 @@ private:
|
|||||||
#define ATTR_ALIGN
|
#define ATTR_ALIGN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class pmemory_pool;
|
|
||||||
|
|
||||||
extern pmemory_pool *ppool;
|
|
||||||
|
|
||||||
void *palloc_raw(const size_t size);
|
|
||||||
void pfree_raw(void *p);
|
|
||||||
|
|
||||||
void* operator new(std::size_t size, pmemory_pool *pool) throw (std::bad_alloc);
|
|
||||||
|
|
||||||
void operator delete(void *ptr, pmemory_pool *pool);
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline void pfree_t(T *p)
|
|
||||||
{
|
|
||||||
p->~T();
|
|
||||||
pfree_raw(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline T *palloc_array_t(size_t N)
|
|
||||||
{
|
|
||||||
char *buf = reinterpret_cast<char *>(palloc_raw(N * sizeof(T) + 64*2));
|
|
||||||
size_t *s = reinterpret_cast<size_t *>(buf);
|
|
||||||
*s = N;
|
|
||||||
buf += 64;
|
|
||||||
T *p = reinterpret_cast<T *>(buf);
|
|
||||||
for (size_t i = 0; i < N; i++)
|
|
||||||
new(reinterpret_cast<void *>(&p[i])) T();
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline void pfree_array_t(T *p)
|
|
||||||
{
|
|
||||||
char *buf = reinterpret_cast<char *>(p);
|
|
||||||
buf -= 64;
|
|
||||||
size_t *s = reinterpret_cast<size_t *>(buf);
|
|
||||||
size_t N = *s;
|
|
||||||
while (N > 0)
|
|
||||||
{
|
|
||||||
p->~T();
|
|
||||||
p++;
|
|
||||||
N--;
|
|
||||||
}
|
|
||||||
pfree_raw(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
#define palloc(T) new(ppool) T
|
|
||||||
#define pfree(_ptr) pfree_t(_ptr)
|
|
||||||
|
|
||||||
#define palloc_array(T, N) palloc_array_t<T>(N)
|
|
||||||
#define pfree_array(_ptr) pfree_array_t(_ptr)
|
|
||||||
#else
|
|
||||||
#define palloc(T) new T
|
#define palloc(T) new T
|
||||||
#define pfree(_ptr) delete _ptr
|
#define pfree(_ptr) delete _ptr
|
||||||
|
|
||||||
#define palloc_array(T, N) new T[N]
|
#define palloc_array(T, N) new T[N]
|
||||||
#define pfree_array(_ptr) delete[] _ptr
|
#define pfree_array(_ptr) delete[] _ptr
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
#include "corealloc.h"
|
|
||||||
|
|
||||||
#define ATTR_ALIGN
|
#define ATTR_ALIGN
|
||||||
|
|
||||||
#define palloc(T) global_alloc(T)
|
template<typename T, typename... Args>
|
||||||
#define pfree(_ptr) global_free(_ptr)
|
T *palloc(Args&&... args)
|
||||||
|
{
|
||||||
|
return new T(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
#define palloc_array(T, N) global_alloc_array(T, N)
|
template<typename T>
|
||||||
#define pfree_array(_ptr) global_free_array(_ptr)
|
void pfree(T *ptr) { delete ptr; }
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline T* palloc_array(std::size_t num)
|
||||||
|
{
|
||||||
|
return new T[num]();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void pfree_array(T *ptr) { delete [] ptr; }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
#define PCONFIG_H_
|
#define PCONFIG_H_
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <thread>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#ifndef PSTANDALONE
|
#ifndef PSTANDALONE
|
||||||
#define PSTANDALONE (0)
|
#define PSTANDALONE (0)
|
||||||
@ -25,6 +27,8 @@ typedef __uint128_t UINT128;
|
|||||||
typedef __int128_t INT128;
|
typedef __int128_t INT128;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define PLIB_NAMESPACE_START() namespace plib {
|
||||||
|
#define PLIB_NAMESPACE_END() }
|
||||||
|
|
||||||
#if !(PSTANDALONE)
|
#if !(PSTANDALONE)
|
||||||
#include "osdcomm.h"
|
#include "osdcomm.h"
|
||||||
@ -135,6 +139,29 @@ typedef int64_t INT64;
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
using pticks_t = INT64;
|
||||||
|
|
||||||
|
inline pticks_t pticks()
|
||||||
|
{
|
||||||
|
return std::chrono::high_resolution_clock::now().time_since_epoch().count();
|
||||||
|
}
|
||||||
|
inline pticks_t pticks_per_second()
|
||||||
|
{
|
||||||
|
return std::chrono::high_resolution_clock::period::den / std::chrono::high_resolution_clock::period::num;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 1 && defined(__x86_64__)
|
||||||
|
|
||||||
|
static inline pticks_t pprofile_ticks()
|
||||||
|
{
|
||||||
|
unsigned hi, lo;
|
||||||
|
__asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
|
||||||
|
return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
inline pticks_t pprofile_ticks() { return pticks(); }
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The following class was derived from the MAME delegate.h code.
|
* The following class was derived from the MAME delegate.h code.
|
||||||
* It derives a pointer to a member function.
|
* It derives a pointer to a member function.
|
||||||
|
@ -1,18 +1,20 @@
|
|||||||
// license:GPL-2.0+
|
// license:GPL-2.0+
|
||||||
// copyright-holders:Couriersud
|
// copyright-holders:Couriersud
|
||||||
/*
|
/*
|
||||||
* pdynlib.c
|
* dynlib.c
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pdynlib.h"
|
#include <plib/pdynlib.h>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
#else
|
#else
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pdynlib::pdynlib(const pstring libname)
|
PLIB_NAMESPACE_START()
|
||||||
|
|
||||||
|
dynlib::dynlib(const pstring libname)
|
||||||
: m_isLoaded(false), m_lib(nullptr)
|
: m_isLoaded(false), m_lib(nullptr)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -38,7 +40,7 @@ pdynlib::pdynlib(const pstring libname)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
pdynlib::pdynlib(const pstring path, const pstring libname)
|
dynlib::dynlib(const pstring path, const pstring libname)
|
||||||
: m_isLoaded(false), m_lib(nullptr)
|
: m_isLoaded(false), m_lib(nullptr)
|
||||||
{
|
{
|
||||||
// printf("win: loading <%s>\n", libname.cstr());
|
// printf("win: loading <%s>\n", libname.cstr());
|
||||||
@ -68,7 +70,7 @@ pdynlib::pdynlib(const pstring path, const pstring libname)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
pdynlib::~pdynlib()
|
dynlib::~dynlib()
|
||||||
{
|
{
|
||||||
if (m_lib != nullptr)
|
if (m_lib != nullptr)
|
||||||
{
|
{
|
||||||
@ -80,12 +82,12 @@ pdynlib::~pdynlib()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pdynlib::isLoaded() const
|
bool dynlib::isLoaded() const
|
||||||
{
|
{
|
||||||
return m_isLoaded;
|
return m_isLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *pdynlib::getsym_p(const pstring name)
|
void *dynlib::getsym_p(const pstring name)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return (void *) GetProcAddress((HMODULE) m_lib, name.cstr());
|
return (void *) GetProcAddress((HMODULE) m_lib, name.cstr());
|
||||||
@ -93,3 +95,5 @@ void *pdynlib::getsym_p(const pstring name)
|
|||||||
return dlsym(m_lib, name.cstr());
|
return dlsym(m_lib, name.cstr());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PLIB_NAMESPACE_END()
|
||||||
|
@ -13,16 +13,18 @@
|
|||||||
#include "pconfig.h"
|
#include "pconfig.h"
|
||||||
#include "pstring.h"
|
#include "pstring.h"
|
||||||
|
|
||||||
|
PLIB_NAMESPACE_START()
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
// pdynlib: dynamic loading of libraries ...
|
// pdynlib: dynamic loading of libraries ...
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
class pdynlib
|
class dynlib
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
pdynlib(const pstring libname);
|
dynlib(const pstring libname);
|
||||||
pdynlib(const pstring path, const pstring libname);
|
dynlib(const pstring path, const pstring libname);
|
||||||
~pdynlib();
|
~dynlib();
|
||||||
|
|
||||||
bool isLoaded() const;
|
bool isLoaded() const;
|
||||||
|
|
||||||
@ -38,4 +40,6 @@ private:
|
|||||||
void *m_lib;
|
void *m_lib;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PLIB_NAMESPACE_END()
|
||||||
|
|
||||||
#endif /* _PSTRING_H_ */
|
#endif /* _PSTRING_H_ */
|
||||||
|
@ -23,7 +23,7 @@ pfmt::pfmt(const pstring &fmt)
|
|||||||
if (l>sizeof(m_str_buf))
|
if (l>sizeof(m_str_buf))
|
||||||
{
|
{
|
||||||
m_allocated = 2 * l;
|
m_allocated = 2 * l;
|
||||||
m_str = palloc_array(char, 2 * l);
|
m_str = palloc_array<char>(2 * l);
|
||||||
}
|
}
|
||||||
memcpy(m_str, fmt.cstr(), l);
|
memcpy(m_str, fmt.cstr(), l);
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ pfmt::pfmt(const char *fmt)
|
|||||||
if (l>sizeof(m_str_buf))
|
if (l>sizeof(m_str_buf))
|
||||||
{
|
{
|
||||||
m_allocated = 2 * l;
|
m_allocated = 2 * l;
|
||||||
m_str = palloc_array(char, 2 * l);
|
m_str = palloc_array<char>(2 * l);
|
||||||
}
|
}
|
||||||
memcpy(m_str, fmt, l);
|
memcpy(m_str, fmt, l);
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ void pfmt::format_element(const char *f, const char *l, const char *fmt_spec, .
|
|||||||
m_allocated = old_alloc;
|
m_allocated = old_alloc;
|
||||||
while (new_size > m_allocated)
|
while (new_size > m_allocated)
|
||||||
m_allocated *= 2;
|
m_allocated *= 2;
|
||||||
char *np = palloc_array(char, m_allocated);
|
char *np = palloc_array<char>(m_allocated);
|
||||||
memcpy(np, m_str, old_alloc);
|
memcpy(np, m_str, old_alloc);
|
||||||
p = np + (p - m_str);
|
p = np + (p - m_str);
|
||||||
if (m_str != m_str_buf)
|
if (m_str != m_str_buf)
|
||||||
|
@ -73,7 +73,7 @@ protected:
|
|||||||
if (m_list != nullptr)
|
if (m_list != nullptr)
|
||||||
pfree_array(m_list);
|
pfree_array(m_list);
|
||||||
if (new_capacity > 0)
|
if (new_capacity > 0)
|
||||||
m_list = palloc_array(_ListClass, new_capacity);
|
m_list = palloc_array<_ListClass>(new_capacity);
|
||||||
else
|
else
|
||||||
m_list = nullptr;
|
m_list = nullptr;
|
||||||
m_capacity = new_capacity;
|
m_capacity = new_capacity;
|
||||||
|
@ -306,7 +306,7 @@ pimemstream::pos_type pimemstream::vtell()
|
|||||||
pomemstream::pomemstream()
|
pomemstream::pomemstream()
|
||||||
: postream(FLAG_SEEKABLE), m_pos(0), m_capacity(1024), m_size(0)
|
: postream(FLAG_SEEKABLE), m_pos(0), m_capacity(1024), m_size(0)
|
||||||
{
|
{
|
||||||
m_mem = palloc_array(char, m_capacity);
|
m_mem = palloc_array<char>(m_capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
pomemstream::~pomemstream()
|
pomemstream::~pomemstream()
|
||||||
@ -321,7 +321,7 @@ void pomemstream::vwrite(const void *buf, const unsigned n)
|
|||||||
while (m_pos + n >= m_capacity)
|
while (m_pos + n >= m_capacity)
|
||||||
m_capacity *= 2;
|
m_capacity *= 2;
|
||||||
char *o = m_mem;
|
char *o = m_mem;
|
||||||
m_mem = palloc_array(char, m_capacity);
|
m_mem = palloc_array<char>(m_capacity);
|
||||||
if (m_mem == nullptr)
|
if (m_mem == nullptr)
|
||||||
{
|
{
|
||||||
set_flag(FLAG_ERROR);
|
set_flag(FLAG_ERROR);
|
||||||
@ -345,7 +345,7 @@ void pomemstream::vseek(const pos_type n)
|
|||||||
while (m_size >= m_capacity)
|
while (m_size >= m_capacity)
|
||||||
m_capacity *= 2;
|
m_capacity *= 2;
|
||||||
char *o = m_mem;
|
char *o = m_mem;
|
||||||
m_mem = palloc_array(char, m_capacity);
|
m_mem = palloc_array<char>(m_capacity);
|
||||||
if (m_mem == nullptr)
|
if (m_mem == nullptr)
|
||||||
{
|
{
|
||||||
set_flag(FLAG_ERROR);
|
set_flag(FLAG_ERROR);
|
||||||
|
@ -373,12 +373,12 @@ template<typename F>
|
|||||||
pstr_t *pstring_t<F>::salloc(int n)
|
pstr_t *pstring_t<F>::salloc(int n)
|
||||||
{
|
{
|
||||||
if (stk == nullptr)
|
if (stk == nullptr)
|
||||||
stk = palloc_array(std::stack<pstr_t *>, 17);
|
stk = palloc_array<std::stack<pstr_t *>>(17);
|
||||||
pstr_t *p;
|
pstr_t *p;
|
||||||
unsigned sn= ((32 - countleadbits(n)) + 1) / 2;
|
unsigned sn= ((32 - countleadbits(n)) + 1) / 2;
|
||||||
unsigned size = sizeof(pstr_t) + ((UINT64) 1<<(sn * 2)) + 1;
|
unsigned size = sizeof(pstr_t) + ((UINT64) 1<<(sn * 2)) + 1;
|
||||||
if (stk[sn].empty())
|
if (stk[sn].empty())
|
||||||
p = (pstr_t *) palloc_array(char, size);
|
p = (pstr_t *) palloc_array<char>(size);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p = stk[sn].top();
|
p = stk[sn].top();
|
||||||
@ -543,7 +543,7 @@ void pstringbuffer::resize(const std::size_t size)
|
|||||||
m_size = DEFAULT_SIZE;
|
m_size = DEFAULT_SIZE;
|
||||||
while (m_size <= size)
|
while (m_size <= size)
|
||||||
m_size *= 2;
|
m_size *= 2;
|
||||||
m_ptr = palloc_array(char, m_size);
|
m_ptr = palloc_array<char>(m_size);
|
||||||
*m_ptr = 0;
|
*m_ptr = 0;
|
||||||
m_len = 0;
|
m_len = 0;
|
||||||
}
|
}
|
||||||
@ -551,7 +551,7 @@ void pstringbuffer::resize(const std::size_t size)
|
|||||||
{
|
{
|
||||||
while (m_size < size)
|
while (m_size < size)
|
||||||
m_size *= 2;
|
m_size *= 2;
|
||||||
char *new_buf = palloc_array(char, m_size);
|
char *new_buf = palloc_array<char>(m_size);
|
||||||
std::memcpy(new_buf, m_ptr, m_len + 1);
|
std::memcpy(new_buf, m_ptr, m_len + 1);
|
||||||
pfree_array(m_ptr);
|
pfree_array(m_ptr);
|
||||||
m_ptr = new_buf;
|
m_ptr = new_buf;
|
||||||
|
@ -26,19 +26,6 @@
|
|||||||
#include "devices/net_lib.h"
|
#include "devices/net_lib.h"
|
||||||
#include "tools/nl_convert.h"
|
#include "tools/nl_convert.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef PSTANDALONE_PROVIDED
|
|
||||||
|
|
||||||
#include <ctime>
|
|
||||||
|
|
||||||
#define osd_ticks_t clock_t
|
|
||||||
|
|
||||||
inline osd_ticks_t osd_ticks_per_second() { return CLOCKS_PER_SEC; }
|
|
||||||
|
|
||||||
osd_ticks_t osd_ticks(void) { return clock(); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
class tool_options_t : public poptions
|
class tool_options_t : public poptions
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -103,7 +90,7 @@ public:
|
|||||||
|
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
m_setup = palloc(netlist::setup_t(*this));
|
m_setup = palloc<netlist::setup_t>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_netlist(const pstring &filename, const pstring &name)
|
void read_netlist(const pstring &filename, const pstring &name)
|
||||||
@ -205,7 +192,7 @@ struct input_t
|
|||||||
|
|
||||||
pvector_t<input_t> *read_input(netlist::netlist_t *netlist, pstring fname)
|
pvector_t<input_t> *read_input(netlist::netlist_t *netlist, pstring fname)
|
||||||
{
|
{
|
||||||
pvector_t<input_t> *ret = palloc(pvector_t<input_t>());
|
pvector_t<input_t> *ret = palloc<pvector_t<input_t>>();
|
||||||
if (fname != "")
|
if (fname != "")
|
||||||
{
|
{
|
||||||
pifilestream f(fname);
|
pifilestream f(fname);
|
||||||
@ -225,7 +212,7 @@ pvector_t<input_t> *read_input(netlist::netlist_t *netlist, pstring fname)
|
|||||||
static void run(tool_options_t &opts)
|
static void run(tool_options_t &opts)
|
||||||
{
|
{
|
||||||
netlist_tool_t nt("netlist");
|
netlist_tool_t nt("netlist");
|
||||||
osd_ticks_t t = osd_ticks();
|
pticks_t t = pticks();
|
||||||
|
|
||||||
nt.m_opts = &opts;
|
nt.m_opts = &opts;
|
||||||
nt.init();
|
nt.init();
|
||||||
@ -241,9 +228,9 @@ static void run(tool_options_t &opts)
|
|||||||
|
|
||||||
double ttr = opts.opt_ttr();
|
double ttr = opts.opt_ttr();
|
||||||
|
|
||||||
pout("startup time ==> {1:5.3f}\n", (double) (osd_ticks() - t) / (double) osd_ticks_per_second() );
|
pout("startup time ==> {1:5.3f}\n", (double) (pticks() - t) / (double) pticks_per_second() );
|
||||||
pout("runnning ...\n");
|
pout("runnning ...\n");
|
||||||
t = osd_ticks();
|
t = pticks();
|
||||||
|
|
||||||
unsigned pos = 0;
|
unsigned pos = 0;
|
||||||
netlist::netlist_time nlt = netlist::netlist_time::zero;
|
netlist::netlist_time nlt = netlist::netlist_time::zero;
|
||||||
@ -259,7 +246,7 @@ static void run(tool_options_t &opts)
|
|||||||
nt.stop();
|
nt.stop();
|
||||||
pfree(inps);
|
pfree(inps);
|
||||||
|
|
||||||
double emutime = (double) (osd_ticks() - t) / (double) osd_ticks_per_second();
|
double emutime = (double) (pticks() - t) / (double) pticks_per_second();
|
||||||
pout("{1:f} seconds emulation took {2:f} real time ==> {3:5.2f}%\n", ttr, emutime, ttr/emutime*100.0);
|
pout("{1:f} seconds emulation took {2:f} real time ==> {3:5.2f}%\n", ttr, emutime, ttr/emutime*100.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,11 +14,11 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "plib/pdynlib.h"
|
||||||
#include "solver/mat_cr.h"
|
#include "solver/mat_cr.h"
|
||||||
#include "solver/nld_ms_direct.h"
|
#include "solver/nld_ms_direct.h"
|
||||||
#include "solver/nld_solver.h"
|
#include "solver/nld_solver.h"
|
||||||
#include "solver/vector_base.h"
|
#include "solver/vector_base.h"
|
||||||
#include "plib/pdynlib.h"
|
|
||||||
#include "plib/pstream.h"
|
#include "plib/pstream.h"
|
||||||
|
|
||||||
#define NL_USE_SSE 0
|
#define NL_USE_SSE 0
|
||||||
|
@ -114,8 +114,8 @@ ATTR_COLD void matrix_solver_t::setup_base(analog_net_t::list_t &nets)
|
|||||||
for (auto & net : nets)
|
for (auto & net : nets)
|
||||||
{
|
{
|
||||||
m_nets.push_back(net);
|
m_nets.push_back(net);
|
||||||
m_terms.push_back(palloc(terms_t));
|
m_terms.push_back(palloc<terms_t>());
|
||||||
m_rails_temp.push_back(palloc(terms_t));
|
m_rails_temp.push_back(palloc<terms_t>());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::size_t k = 0; k < nets.size(); k++)
|
for (std::size_t k = 0; k < nets.size(); k++)
|
||||||
@ -159,7 +159,7 @@ ATTR_COLD void matrix_solver_t::setup_base(analog_net_t::list_t &nets)
|
|||||||
//net_proxy_output = palloc(analog_output_t(*this,
|
//net_proxy_output = palloc(analog_output_t(*this,
|
||||||
// this->name() + "." + pfmt("m{1}")(m_inps.size())));
|
// this->name() + "." + pfmt("m{1}")(m_inps.size())));
|
||||||
|
|
||||||
net_proxy_output = palloc(analog_output_t(*this, this->name() + "." + pfmt("m{1}")(m_inps.size())));
|
net_proxy_output = palloc<analog_output_t>(*this, this->name() + "." + pfmt("m{1}")(m_inps.size()));
|
||||||
m_inps.push_back(net_proxy_output);
|
m_inps.push_back(net_proxy_output);
|
||||||
net_proxy_output->m_proxied_net = &p->net().as_analog();
|
net_proxy_output->m_proxied_net = &p->net().as_analog();
|
||||||
}
|
}
|
||||||
@ -627,9 +627,9 @@ matrix_solver_t * NETLIB_NAME(solver)::create_solver(int size, const bool use_sp
|
|||||||
{
|
{
|
||||||
pstring solvername = pfmt("Solver_{1}")(m_mat_solvers.size());
|
pstring solvername = pfmt("Solver_{1}")(m_mat_solvers.size());
|
||||||
if (use_specific && m_N == 1)
|
if (use_specific && m_N == 1)
|
||||||
return palloc(matrix_solver_direct1_t(netlist(), solvername, &m_params));
|
return palloc<matrix_solver_direct1_t>(netlist(), solvername, &m_params);
|
||||||
else if (use_specific && m_N == 2)
|
else if (use_specific && m_N == 2)
|
||||||
return palloc(matrix_solver_direct2_t(netlist(), solvername, &m_params));
|
return palloc<matrix_solver_direct2_t>(netlist(), solvername, &m_params);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (size >= m_gs_threshold)
|
if (size >= m_gs_threshold)
|
||||||
@ -637,39 +637,39 @@ matrix_solver_t * NETLIB_NAME(solver)::create_solver(int size, const bool use_sp
|
|||||||
if (pstring("SOR_MAT").equals(m_iterative_solver))
|
if (pstring("SOR_MAT").equals(m_iterative_solver))
|
||||||
{
|
{
|
||||||
typedef matrix_solver_SOR_mat_t<m_N,_storage_N> solver_sor_mat;
|
typedef matrix_solver_SOR_mat_t<m_N,_storage_N> solver_sor_mat;
|
||||||
return palloc(solver_sor_mat(netlist(), solvername, &m_params, size));
|
return palloc<solver_sor_mat>(netlist(), solvername, &m_params, size);
|
||||||
}
|
}
|
||||||
else if (pstring("MAT_CR").equals(m_iterative_solver))
|
else if (pstring("MAT_CR").equals(m_iterative_solver))
|
||||||
{
|
{
|
||||||
typedef matrix_solver_GCR_t<m_N,_storage_N> solver_mat;
|
typedef matrix_solver_GCR_t<m_N,_storage_N> solver_mat;
|
||||||
return palloc(solver_mat(netlist(), solvername, &m_params, size));
|
return palloc<solver_mat>(netlist(), solvername, &m_params, size);
|
||||||
}
|
}
|
||||||
else if (pstring("MAT").equals(m_iterative_solver))
|
else if (pstring("MAT").equals(m_iterative_solver))
|
||||||
{
|
{
|
||||||
typedef matrix_solver_direct_t<m_N,_storage_N> solver_mat;
|
typedef matrix_solver_direct_t<m_N,_storage_N> solver_mat;
|
||||||
return palloc(solver_mat(netlist(), solvername, &m_params, size));
|
return palloc<solver_mat>(netlist(), solvername, &m_params, size);
|
||||||
}
|
}
|
||||||
else if (pstring("SM").equals(m_iterative_solver))
|
else if (pstring("SM").equals(m_iterative_solver))
|
||||||
{
|
{
|
||||||
/* Sherman-Morrison Formula */
|
/* Sherman-Morrison Formula */
|
||||||
typedef matrix_solver_sm_t<m_N,_storage_N> solver_mat;
|
typedef matrix_solver_sm_t<m_N,_storage_N> solver_mat;
|
||||||
return palloc(solver_mat(netlist(), solvername, &m_params, size));
|
return palloc<solver_mat>(netlist(), solvername, &m_params, size);
|
||||||
}
|
}
|
||||||
else if (pstring("W").equals(m_iterative_solver))
|
else if (pstring("W").equals(m_iterative_solver))
|
||||||
{
|
{
|
||||||
/* Woodbury Formula */
|
/* Woodbury Formula */
|
||||||
typedef matrix_solver_w_t<m_N,_storage_N> solver_mat;
|
typedef matrix_solver_w_t<m_N,_storage_N> solver_mat;
|
||||||
return palloc(solver_mat(netlist(), solvername, &m_params, size));
|
return palloc<solver_mat>(netlist(), solvername, &m_params, size);
|
||||||
}
|
}
|
||||||
else if (pstring("SOR").equals(m_iterative_solver))
|
else if (pstring("SOR").equals(m_iterative_solver))
|
||||||
{
|
{
|
||||||
typedef matrix_solver_SOR_t<m_N,_storage_N> solver_GS;
|
typedef matrix_solver_SOR_t<m_N,_storage_N> solver_GS;
|
||||||
return palloc(solver_GS(netlist(), solvername, &m_params, size));
|
return palloc<solver_GS>(netlist(), solvername, &m_params, size);
|
||||||
}
|
}
|
||||||
else if (pstring("GMRES").equals(m_iterative_solver))
|
else if (pstring("GMRES").equals(m_iterative_solver))
|
||||||
{
|
{
|
||||||
typedef matrix_solver_GMRES_t<m_N,_storage_N> solver_GMRES;
|
typedef matrix_solver_GMRES_t<m_N,_storage_N> solver_GMRES;
|
||||||
return palloc(solver_GMRES(netlist(), solvername, &m_params, size));
|
return palloc<solver_GMRES>(netlist(), solvername, &m_params, size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -680,7 +680,7 @@ matrix_solver_t * NETLIB_NAME(solver)::create_solver(int size, const bool use_sp
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
typedef matrix_solver_direct_t<m_N,_storage_N> solver_D;
|
typedef matrix_solver_direct_t<m_N,_storage_N> solver_D;
|
||||||
return palloc(solver_D(netlist(), solvername, &m_params, size));
|
return palloc<solver_D>(netlist(), solvername, &m_params, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user