README.md

November 15, 2022 · View on GitHub

deterministic_float

  • Cross-platform deterministic float point, fast soft float point.

  • Fast soft float point for deterministic computing, That you can make deterministic plugin by use GFloat to replace float-point. like:

    • Physics Engine (Bullet、PhysX)
    • AI Path Finding (Recast Navigation)
    • AI Engine
  • Compare the overall performance of hard float IEEE-754 and GFloat numbers, They differ by no more than 500%, Refer to the multiply-add instructions for measuring the computing power of the graphics card. compare multiply and add function:

  • 跨平台的确定性浮点数,高性能的软件浮点数

  • 你可以使用GFloat替代各种中间件的浮点数,从而实现带确定性的计算,实现帧同步游戏逻辑,也可以实现加密货币计算逻辑,例如:

    • 物理引擎(Bullet、PhysX)
    • AI 寻路(Recast Navigation)
    • AI 引擎
  • 整体上GFloat与IEEE754的硬件浮点数float,性能差距在500%以内。参考显卡衡量计算能力的乘加指令,主要比较乘法和加法函数的性能:

IEEE-754 float & GFloat

  • IEEE-754 float

    sign exponents(8 bits) fractions(23 bits)
    31 3029...2423 2221...10
    • XIEEE754=(1)sign×(1.fraction)×2exponent127\mathbf{X}_{IEEE754} = (-1)^\mathbf{sign} \times (1.\mathbf{fraction}) \times 2 ^{\mathbf{exponent} - 127}
  • GFloat

    sign fractions(23 bits) exponents(8 bits)
    31 3029...98 76...10
    • XGFloat=(1)sign×(fraction)×2exponent127\mathbf{X}_{GFloat} = (-1)^\mathbf{sign} \times (\mathbf{fraction}) \times 2 ^{\mathbf{exponent} - 127}

Performance float(IEEE-754) vs GFloat

  • Several important functions compare, for more information to view TestAndBenchMark
  • Call every function 1000000 Times, get the float vs GFloat time
PlatformWin64Win64iOSOSXAndroid
CPURyzen-5950Xi9-12900HApple A15Apple M1ProHiSilicon-KIRIN-990
float vs GFloatfloat vs GFloatfloat vs GFloatfloat vs GFloatfloat vs GFloat
Add0.63 vs 2.63 ms0.44 vs 1.48ms0.43 vs 1.85 ms0.34 vs 2.24 ms0.89 vs 8.76 ms
Mul0.70 vs 1.14 ms0.52 vs 0.79 ms0.42 vs 0.78 ms0.34 vs 0.93 ms0.62 vs 2.10 ms
Sin10.20 vs 8.39 ms8.6 vs 3.15 ms3.6 vs 4.9 ms2.29 vs 5.28 ms11.58 vs 15.75 ms
Sqrt1.08 vs 9.29 ms0.7 vs 6.2 ms0.83 vs 5.64 ms0.64 vs 6.06 ms0.65 vs 15.77 ms
Exp2.06 vs 10.83ms2.15 vs 24.52ms5.52 vs 7.03 ms5.75 vs 6.52 ms6.06 vs 20.90 ms

How to start

  • Four OS platform projects for fast and easy to start test&benchmark
Target PlatformCompilerProject
WinVisual Studio 2022deterministic/deterministic_float.sln
MacOSXCode 13.4deterministic/deterministic_float.xcodeproj
iOSXCode 13.4deterministic/deterministic_float_ios.xcodeproj
AndroidAndroid studio 4.0deterministic/deterministic_float_android

Current Support Platform For Test&Benchmark

Operation SystemWin64MacOSiOSAndroid
\checkmark\checkmark\checkmark\checkmark