summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/nl_config.h
diff options
context:
space:
mode:
author couriersud <couriersud@gmx.org>2020-04-20 20:52:21 +0200
committer couriersud <couriersud@gmx.org>2020-04-20 20:52:21 +0200
commit3243efee70dce118e01effd8093d465ee750eecb (patch)
tree22a283d70cbe0798092ed6565d749f1164cfb9f8 /src/lib/netlist/nl_config.h
parent4c9e3dc171ed4f1d27be16947a442383085c2d3d (diff)
netlist: code maintenance and edge case fixes. (nw)
"Edge cases" are compiles were the floting point type used for the core may be different from the one used by solvers, e.g. double/float. This does not happen in MAME, here currently this is always double/double. Since floats are better suited for GPUs whose double performance is limited it was time to review the code. This commit fixes warnings about type conversions and precision loss. In addition there is better support for INT128 and FLOAT128. The MAT solver has seen some minor performance increases.
Diffstat (limited to 'src/lib/netlist/nl_config.h')
-rw-r--r--src/lib/netlist/nl_config.h38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/lib/netlist/nl_config.h b/src/lib/netlist/nl_config.h
index e08065dd47e..a60c316b206 100644
--- a/src/lib/netlist/nl_config.h
+++ b/src/lib/netlist/nl_config.h
@@ -55,10 +55,12 @@
/// \brief Compile in academic solvers
///
-/// Set to 0 to disable compiling in the following solvers:
+/// Set to 0 to disable compiling the following solvers:
///
/// Sherman-Morrison, Woodbury, SOR and GMRES
///
+/// In addition, compilation of FLOAT, LONGDOUBLE and FLOATQ128 matrix
+/// solvers will be disabled.
/// GMRES may be added to productive solvers in the future
/// again. Compiling in all solvers may increase compile
/// time significantly.
@@ -113,18 +115,20 @@
/// \brief Support float type for matrix calculations.
///
-/// Defaults to off to provide faster build times
+/// Defaults to NL_USE_ACADEMIC_SOLVERS to provide faster build times
#ifndef NL_USE_FLOAT_MATRIX
-#define NL_USE_FLOAT_MATRIX (0)
+#define NL_USE_FLOAT_MATRIX (NL_USE_ACADEMIC_SOLVERS)
+//#define NL_USE_FLOAT_MATRIX 1
#endif
/// \brief Support long double type for matrix calculations.
///
-/// Defaults to off to provide faster build times
+/// Defaults to NL_USE_ACADEMIC_SOLVERS to provide faster build times
#ifndef NL_USE_LONG_DOUBLE_MATRIX
-#define NL_USE_LONG_DOUBLE_MATRIX (0)
+#define NL_USE_LONG_DOUBLE_MATRIX (NL_USE_ACADEMIC_SOLVERS)
+//#define NL_USE_LONG_DOUBLE_MATRIX 1
#endif
//============================================================
@@ -187,6 +191,8 @@ static constexpr const int NETLIST_CLOCK = 1'000'000'000;
///
using nl_fptype = double;
+//using nl_fptype = long double;
+//using nl_fptype = float;
namespace netlist
{
@@ -244,27 +250,27 @@ namespace netlist
};
#if (NL_USE_FLOAT128)
- /// \brief Specific constants for __float128 floating point type
+ /// \brief Specific constants for FLOAT128 floating point type
///
template <>
- struct fp_constants<__float128>
+ struct fp_constants<FLOAT128>
{
#if 0
// MAME compile doesn't support Q
- static inline constexpr __float128 DIODE_MAXDIFF() noexcept { return 1e100Q; }
- static inline constexpr __float128 DIODE_MAXVOLT() noexcept { return 300.0Q; }
+ static inline constexpr FLOAT128 DIODE_MAXDIFF() noexcept { return 1e100Q; }
+ static inline constexpr FLOAT128 DIODE_MAXVOLT() noexcept { return 300.0Q; }
- static inline constexpr __float128 TIMESTEP_MAXDIFF() noexcept { return 1e100Q; }
- static inline constexpr __float128 TIMESTEP_MINDIV() noexcept { return 1e-60Q; }
+ static inline constexpr FLOAT128 TIMESTEP_MAXDIFF() noexcept { return 1e100Q; }
+ static inline constexpr FLOAT128 TIMESTEP_MINDIV() noexcept { return 1e-60Q; }
- static inline constexpr const char * name() noexcept { return "__float128"; }
+ static inline constexpr const char * name() noexcept { return "FLOAT128"; }
static inline constexpr const char * suffix() noexcept { return "Q"; }
#else
- static inline constexpr __float128 DIODE_MAXDIFF() noexcept { return static_cast<__float128>(1e100L); }
- static inline constexpr __float128 DIODE_MAXVOLT() noexcept { return static_cast<__float128>(300.0L); }
+ static inline constexpr FLOAT128 DIODE_MAXDIFF() noexcept { return static_cast<FLOAT128>(1e100L); }
+ static inline constexpr FLOAT128 DIODE_MAXVOLT() noexcept { return static_cast<FLOAT128>(300.0L); }
- static inline constexpr __float128 TIMESTEP_MAXDIFF() noexcept { return static_cast<__float128>(1e100L); }
- static inline constexpr __float128 TIMESTEP_MINDIV() noexcept { return static_cast<__float128>(1e-60L); }
+ static inline constexpr FLOAT128 TIMESTEP_MAXDIFF() noexcept { return static_cast<FLOAT128>(1e100L); }
+ static inline constexpr FLOAT128 TIMESTEP_MINDIV() noexcept { return static_cast<FLOAT128>(1e-60L); }
static inline constexpr const char * name() noexcept { return "__float128"; }
static inline constexpr const char * suffix() noexcept { return "Q"; }