From e949e9c29de82ee7c32692e7b65da05dd22bdc9d Mon Sep 17 00:00:00 2001 From: couriersud Date: Sat, 13 Jun 2020 15:49:35 +0200 Subject: netlist: Performance improvement and refactoring. [Couriersud] Kidniki now achieves up to 910% when run with static solvers and with nltool. That is significant better than the 860% we have seen previously. This increase is driven by using a global memory pool in the solver code. In addition the following refactoring and code maintenance work is included. Please excuse the large commit, some of this took interfered with other work and the detail development steps were ugly. - gsl support: This commit adds pgsl.h which implements a very limited number of the functionality of the gsl header described in the c++ core guidelines. - clang-tidy fixes - A significant refactoring of palloc.h. Aligned hints were removed, they added complexity without a significant performance gain. Vector operations should better be done on special spans/views. The code has been tested on linux with g++-7, g++-9, clang-11. On Windows mingw-10 and VS2019, OSX clang-11. --- src/lib/netlist/plib/pfunction.cpp | 50 +++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'src/lib/netlist/plib/pfunction.cpp') diff --git a/src/lib/netlist/plib/pfunction.cpp b/src/lib/netlist/plib/pfunction.cpp index c5e011dfbb9..3a360c7a33f 100644 --- a/src/lib/netlist/plib/pfunction.cpp +++ b/src/lib/netlist/plib/pfunction.cpp @@ -25,26 +25,26 @@ namespace plib { { static std::map units_si_stat = { - //{ "Y", static_cast(1e24) }, // NOLINT: Yotta - //{ "Z", static_cast(1e21) }, // NOLINT: Zetta - //{ "E", static_cast(1e18) }, // NOLINT: Exa - { "P", static_cast(1e15) }, // NOLINT: Peta - { "T", static_cast(1e12) }, // NOLINT: Tera - { "G", static_cast( 1e9) }, // NOLINT: Giga - { "M", static_cast( 1e6) }, // NOLINT: Mega - { "k", static_cast( 1e3) }, // NOLINT: Kilo - { "h", static_cast( 1e2) }, // NOLINT: Hekto - //{ "da", static_cast(1e1) }, // NOLINT: Deka - { "d", static_cast(1e-1) }, // NOLINT: Dezi - { "c", static_cast(1e-2) }, // NOLINT: Zenti - { "m", static_cast(1e-3) }, // NOLINT: Milli - { "μ", static_cast(1e-6) }, // NOLINT: Mikro - { "n", static_cast(1e-9) }, // NOLINT: Nano - { "p", static_cast(1e-12) }, // NOLINT: Piko - { "f", static_cast(1e-15) }, // NOLINT: Femto - { "a", static_cast(1e-18) }, // NOLINT: Atto - { "z", static_cast(1e-21) }, // NOLINT: Zepto - { "y", static_cast(1e-24) }, // NOLINT: Yokto + //{ "Y", narrow_cast(1e24) }, // NOLINT: Yotta + //{ "Z", narrow_cast(1e21) }, // NOLINT: Zetta + //{ "E", narrow_cast(1e18) }, // NOLINT: Exa + { "P", narrow_cast(1e15) }, // NOLINT: Peta + { "T", narrow_cast(1e12) }, // NOLINT: Tera + { "G", narrow_cast( 1e9) }, // NOLINT: Giga + { "M", narrow_cast( 1e6) }, // NOLINT: Mega + { "k", narrow_cast( 1e3) }, // NOLINT: Kilo + { "h", narrow_cast( 1e2) }, // NOLINT: Hekto + //{ "da", narrow_cast(1e1) }, // NOLINT: Deka + { "d", narrow_cast(1e-1) }, // NOLINT: Dezi + { "c", narrow_cast(1e-2) }, // NOLINT: Zenti + { "m", narrow_cast(1e-3) }, // NOLINT: Milli + { "μ", narrow_cast(1e-6) }, // NOLINT: Mikro + { "n", narrow_cast(1e-9) }, // NOLINT: Nano + { "p", narrow_cast(1e-12) }, // NOLINT: Piko + { "f", narrow_cast(1e-15) }, // NOLINT: Femto + { "a", narrow_cast(1e-18) }, // NOLINT: Atto + { "z", narrow_cast(1e-21) }, // NOLINT: Zepto + { "y", narrow_cast(1e-24) }, // NOLINT: Yokto }; return units_si_stat; } @@ -105,7 +105,7 @@ namespace plib { if (inputs[i] == cmd) { rc.m_cmd = PUSH_INPUT; - rc.m_param = static_cast(i); + rc.m_param = narrow_cast(i); stk += 1; break; } @@ -128,7 +128,7 @@ namespace plib { } if (stk < 1) throw pexception(plib::pfmt("pfunction: stack underflow on token <{1}> in <{2}>")(cmd)(expr)); - if (stk >= static_cast(MAX_STACK)) + if (stk >= narrow_cast(MAX_STACK)) throw pexception(plib::pfmt("pfunction: stack overflow on token <{1}> in <{2}>")(cmd)(expr)); m_precompiled.push_back(rc); } @@ -286,7 +286,7 @@ namespace plib { lfsr >>= 1; if (lsb) lfsr ^= 0xB400U; // NOLINT: taps 15, 13, 12, 10 - return static_cast(lfsr) / static_cast(0xffffU); // NOLINT + return narrow_cast(lfsr) / narrow_cast(0xffffU); // NOLINT } template @@ -297,7 +297,7 @@ namespace plib { lfsr >>= 1; if (lsb) lfsr ^= 0xB400U; // NOLINT: taps 15, 13, 12, 10 - return static_cast(lfsr); + return narrow_cast(lfsr); } #define ST1 stack[ptr] @@ -333,7 +333,7 @@ namespace plib { stack[ptr++] = lfsr_random(m_lfsr); break; case PUSH_INPUT: - stack[ptr++] = values[static_cast(rc.m_param)]; + stack[ptr++] = values[narrow_cast(rc.m_param)]; break; case PUSH_CONST: stack[ptr++] = rc.m_param; -- cgit v1.2.3-70-g09d2