mirror of
https://github.com/holub/mame
synced 2025-04-16 13:34:55 +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"}));
|
||||
|
||||
m_lib = palloc(pdynlib(libpath));
|
||||
m_lib = palloc<plib::dynlib>(libpath);
|
||||
|
||||
/* make sure the solver and parameters are started first! */
|
||||
|
||||
|
@ -161,9 +161,9 @@
|
||||
#include "nl_lists.h"
|
||||
#include "nl_time.h"
|
||||
#include "nl_util.h"
|
||||
#include "plib/pdynlib.h"
|
||||
#include "plib/pstate.h"
|
||||
#include "plib/pfmtlog.h"
|
||||
#include "plib/pdynlib.h"
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
@ -1039,7 +1039,7 @@ namespace netlist
|
||||
|
||||
#if (NL_KEEP_STATISTICS)
|
||||
/* stats */
|
||||
osd_ticks_t stat_total_time;
|
||||
pticks_t stat_total_time;
|
||||
INT32 stat_update_count;
|
||||
INT32 stat_call_count;
|
||||
#endif
|
||||
@ -1266,7 +1266,7 @@ namespace netlist
|
||||
|
||||
virtual void reset();
|
||||
|
||||
ATTR_COLD pdynlib &lib() { return *m_lib; }
|
||||
ATTR_COLD plib::dynlib &lib() { return *m_lib; }
|
||||
|
||||
void print_stats() const;
|
||||
|
||||
@ -1303,7 +1303,7 @@ protected:
|
||||
pstring m_name;
|
||||
setup_t *m_setup;
|
||||
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_KEEP_STATISTICS (0)
|
||||
#define NL_KEEP_STATISTICS (1)
|
||||
|
||||
//============================================================
|
||||
// General Macros
|
||||
@ -132,8 +132,8 @@
|
||||
#include "eminline.h"
|
||||
#define add_to_stat(v,x) do { v += (x); } while (0)
|
||||
#define inc_stat(v) add_to_stat(v, 1)
|
||||
#define begin_timing(v) do { v -= get_profile_ticks(); } while (0)
|
||||
#define end_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 += pprofile_ticks(); } while (0)
|
||||
#else
|
||||
#define add_to_stat(v,x) do { } while (0)
|
||||
#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");
|
||||
// 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);
|
||||
anet->register_con(t2);
|
||||
anet->register_con(t1);
|
||||
|
@ -19,42 +19,6 @@ pexception::pexception(const pstring &text)
|
||||
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)
|
||||
: m_min_alloc(min_alloc), m_min_align(min_align)
|
||||
{
|
||||
|
@ -50,76 +50,32 @@ private:
|
||||
#define ATTR_ALIGN
|
||||
#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 pfree(_ptr) delete _ptr
|
||||
|
||||
#define palloc_array(T, N) new T[N]
|
||||
#define pfree_array(_ptr) delete[] _ptr
|
||||
#endif
|
||||
#else
|
||||
#include "corealloc.h"
|
||||
|
||||
#define ATTR_ALIGN
|
||||
|
||||
#define palloc(T) global_alloc(T)
|
||||
#define pfree(_ptr) global_free(_ptr)
|
||||
template<typename T, typename... Args>
|
||||
T *palloc(Args&&... args)
|
||||
{
|
||||
return new T(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
#define palloc_array(T, N) global_alloc_array(T, N)
|
||||
#define pfree_array(_ptr) global_free_array(_ptr)
|
||||
template<typename T>
|
||||
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
|
||||
|
||||
|
@ -9,6 +9,8 @@
|
||||
#define PCONFIG_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
#ifndef PSTANDALONE
|
||||
#define PSTANDALONE (0)
|
||||
@ -25,6 +27,8 @@ typedef __uint128_t UINT128;
|
||||
typedef __int128_t INT128;
|
||||
#endif
|
||||
|
||||
#define PLIB_NAMESPACE_START() namespace plib {
|
||||
#define PLIB_NAMESPACE_END() }
|
||||
|
||||
#if !(PSTANDALONE)
|
||||
#include "osdcomm.h"
|
||||
@ -135,6 +139,29 @@ typedef int64_t INT64;
|
||||
|
||||
#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.
|
||||
* It derives a pointer to a member function.
|
||||
|
@ -1,18 +1,20 @@
|
||||
// license:GPL-2.0+
|
||||
// copyright-holders:Couriersud
|
||||
/*
|
||||
* pdynlib.c
|
||||
* dynlib.c
|
||||
*
|
||||
*/
|
||||
|
||||
#include "pdynlib.h"
|
||||
#include <plib/pdynlib.h>
|
||||
#ifdef _WIN32
|
||||
#include "windows.h"
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
pdynlib::pdynlib(const pstring libname)
|
||||
PLIB_NAMESPACE_START()
|
||||
|
||||
dynlib::dynlib(const pstring libname)
|
||||
: m_isLoaded(false), m_lib(nullptr)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
@ -38,7 +40,7 @@ pdynlib::pdynlib(const pstring libname)
|
||||
#endif
|
||||
}
|
||||
|
||||
pdynlib::pdynlib(const pstring path, const pstring libname)
|
||||
dynlib::dynlib(const pstring path, const pstring libname)
|
||||
: m_isLoaded(false), m_lib(nullptr)
|
||||
{
|
||||
// printf("win: loading <%s>\n", libname.cstr());
|
||||
@ -68,7 +70,7 @@ pdynlib::pdynlib(const pstring path, const pstring libname)
|
||||
#endif
|
||||
}
|
||||
|
||||
pdynlib::~pdynlib()
|
||||
dynlib::~dynlib()
|
||||
{
|
||||
if (m_lib != nullptr)
|
||||
{
|
||||
@ -80,12 +82,12 @@ pdynlib::~pdynlib()
|
||||
}
|
||||
}
|
||||
|
||||
bool pdynlib::isLoaded() const
|
||||
bool dynlib::isLoaded() const
|
||||
{
|
||||
return m_isLoaded;
|
||||
}
|
||||
|
||||
void *pdynlib::getsym_p(const pstring name)
|
||||
void *dynlib::getsym_p(const pstring name)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
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());
|
||||
#endif
|
||||
}
|
||||
|
||||
PLIB_NAMESPACE_END()
|
||||
|
@ -13,16 +13,18 @@
|
||||
#include "pconfig.h"
|
||||
#include "pstring.h"
|
||||
|
||||
PLIB_NAMESPACE_START()
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// pdynlib: dynamic loading of libraries ...
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
class pdynlib
|
||||
class dynlib
|
||||
{
|
||||
public:
|
||||
pdynlib(const pstring libname);
|
||||
pdynlib(const pstring path, const pstring libname);
|
||||
~pdynlib();
|
||||
dynlib(const pstring libname);
|
||||
dynlib(const pstring path, const pstring libname);
|
||||
~dynlib();
|
||||
|
||||
bool isLoaded() const;
|
||||
|
||||
@ -38,4 +40,6 @@ private:
|
||||
void *m_lib;
|
||||
};
|
||||
|
||||
PLIB_NAMESPACE_END()
|
||||
|
||||
#endif /* _PSTRING_H_ */
|
||||
|
@ -23,7 +23,7 @@ pfmt::pfmt(const pstring &fmt)
|
||||
if (l>sizeof(m_str_buf))
|
||||
{
|
||||
m_allocated = 2 * l;
|
||||
m_str = palloc_array(char, 2 * l);
|
||||
m_str = palloc_array<char>(2 * l);
|
||||
}
|
||||
memcpy(m_str, fmt.cstr(), l);
|
||||
}
|
||||
@ -35,7 +35,7 @@ pfmt::pfmt(const char *fmt)
|
||||
if (l>sizeof(m_str_buf))
|
||||
{
|
||||
m_allocated = 2 * l;
|
||||
m_str = palloc_array(char, 2 * l);
|
||||
m_str = palloc_array<char>(2 * 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;
|
||||
while (new_size > m_allocated)
|
||||
m_allocated *= 2;
|
||||
char *np = palloc_array(char, m_allocated);
|
||||
char *np = palloc_array<char>(m_allocated);
|
||||
memcpy(np, m_str, old_alloc);
|
||||
p = np + (p - m_str);
|
||||
if (m_str != m_str_buf)
|
||||
|
@ -73,7 +73,7 @@ protected:
|
||||
if (m_list != nullptr)
|
||||
pfree_array(m_list);
|
||||
if (new_capacity > 0)
|
||||
m_list = palloc_array(_ListClass, new_capacity);
|
||||
m_list = palloc_array<_ListClass>(new_capacity);
|
||||
else
|
||||
m_list = nullptr;
|
||||
m_capacity = new_capacity;
|
||||
|
@ -306,7 +306,7 @@ pimemstream::pos_type pimemstream::vtell()
|
||||
pomemstream::pomemstream()
|
||||
: 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()
|
||||
@ -321,7 +321,7 @@ void pomemstream::vwrite(const void *buf, const unsigned n)
|
||||
while (m_pos + n >= m_capacity)
|
||||
m_capacity *= 2;
|
||||
char *o = m_mem;
|
||||
m_mem = palloc_array(char, m_capacity);
|
||||
m_mem = palloc_array<char>(m_capacity);
|
||||
if (m_mem == nullptr)
|
||||
{
|
||||
set_flag(FLAG_ERROR);
|
||||
@ -345,7 +345,7 @@ void pomemstream::vseek(const pos_type n)
|
||||
while (m_size >= m_capacity)
|
||||
m_capacity *= 2;
|
||||
char *o = m_mem;
|
||||
m_mem = palloc_array(char, m_capacity);
|
||||
m_mem = palloc_array<char>(m_capacity);
|
||||
if (m_mem == nullptr)
|
||||
{
|
||||
set_flag(FLAG_ERROR);
|
||||
|
@ -373,12 +373,12 @@ template<typename F>
|
||||
pstr_t *pstring_t<F>::salloc(int n)
|
||||
{
|
||||
if (stk == nullptr)
|
||||
stk = palloc_array(std::stack<pstr_t *>, 17);
|
||||
stk = palloc_array<std::stack<pstr_t *>>(17);
|
||||
pstr_t *p;
|
||||
unsigned sn= ((32 - countleadbits(n)) + 1) / 2;
|
||||
unsigned size = sizeof(pstr_t) + ((UINT64) 1<<(sn * 2)) + 1;
|
||||
if (stk[sn].empty())
|
||||
p = (pstr_t *) palloc_array(char, size);
|
||||
p = (pstr_t *) palloc_array<char>(size);
|
||||
else
|
||||
{
|
||||
p = stk[sn].top();
|
||||
@ -543,7 +543,7 @@ void pstringbuffer::resize(const std::size_t size)
|
||||
m_size = DEFAULT_SIZE;
|
||||
while (m_size <= size)
|
||||
m_size *= 2;
|
||||
m_ptr = palloc_array(char, m_size);
|
||||
m_ptr = palloc_array<char>(m_size);
|
||||
*m_ptr = 0;
|
||||
m_len = 0;
|
||||
}
|
||||
@ -551,7 +551,7 @@ void pstringbuffer::resize(const std::size_t size)
|
||||
{
|
||||
while (m_size < size)
|
||||
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);
|
||||
pfree_array(m_ptr);
|
||||
m_ptr = new_buf;
|
||||
|
@ -26,19 +26,6 @@
|
||||
#include "devices/net_lib.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
|
||||
{
|
||||
public:
|
||||
@ -103,7 +90,7 @@ public:
|
||||
|
||||
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)
|
||||
@ -205,7 +192,7 @@ struct input_t
|
||||
|
||||
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 != "")
|
||||
{
|
||||
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)
|
||||
{
|
||||
netlist_tool_t nt("netlist");
|
||||
osd_ticks_t t = osd_ticks();
|
||||
pticks_t t = pticks();
|
||||
|
||||
nt.m_opts = &opts;
|
||||
nt.init();
|
||||
@ -241,9 +228,9 @@ static void run(tool_options_t &opts)
|
||||
|
||||
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");
|
||||
t = osd_ticks();
|
||||
t = pticks();
|
||||
|
||||
unsigned pos = 0;
|
||||
netlist::netlist_time nlt = netlist::netlist_time::zero;
|
||||
@ -259,7 +246,7 @@ static void run(tool_options_t &opts)
|
||||
nt.stop();
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -14,11 +14,11 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "plib/pdynlib.h"
|
||||
#include "solver/mat_cr.h"
|
||||
#include "solver/nld_ms_direct.h"
|
||||
#include "solver/nld_solver.h"
|
||||
#include "solver/vector_base.h"
|
||||
#include "plib/pdynlib.h"
|
||||
#include "plib/pstream.h"
|
||||
|
||||
#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)
|
||||
{
|
||||
m_nets.push_back(net);
|
||||
m_terms.push_back(palloc(terms_t));
|
||||
m_rails_temp.push_back(palloc(terms_t));
|
||||
m_terms.push_back(palloc<terms_t>());
|
||||
m_rails_temp.push_back(palloc<terms_t>());
|
||||
}
|
||||
|
||||
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,
|
||||
// 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);
|
||||
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());
|
||||
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)
|
||||
return palloc(matrix_solver_direct2_t(netlist(), solvername, &m_params));
|
||||
return palloc<matrix_solver_direct2_t>(netlist(), solvername, &m_params);
|
||||
else
|
||||
{
|
||||
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))
|
||||
{
|
||||
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))
|
||||
{
|
||||
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))
|
||||
{
|
||||
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))
|
||||
{
|
||||
/* Sherman-Morrison Formula */
|
||||
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))
|
||||
{
|
||||
/* Woodbury Formula */
|
||||
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))
|
||||
{
|
||||
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))
|
||||
{
|
||||
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
|
||||
{
|
||||
@ -680,7 +680,7 @@ matrix_solver_t * NETLIB_NAME(solver)::create_solver(int size, const bool use_sp
|
||||
else
|
||||
{
|
||||
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