Don't use -ffast-math or other unsafe math optimizations
Godot supports many different compilers and for production releases we
have to support 3 currently: GCC8, Clang6, and MSVC2017. These compilers
all do slightly different things with -ffast-math and it is causing
issues now. See #24841, #24540, #10758, #10070. And probably other
complaints about physics differences between release and release_debug
builds.
I've done some performance comparisons on Linux x86_64. All tests are
ran 20 times.
Bunnymark: (higher is better)
(bunnies) min max stdev average
fast-math 7332 7597 71 7432
this pr 7379 7779 108 7621 (102%)
FPBench (gdscript port http://fpbench.org/) (lower is better)
(ms)
fast-math 15441 16127 192 15764
this pr 15671 16855 326 16001 (99%)
Float_add (adding floats in a tight loop) (lower is better)
(sec)
fast-math 5.49 5.78 0.07 5.65
this pr 5.65 5.90 0.06 5.76 (98%)
Float_div (dividing floats in a tight loop) (lower is better)
(sec)
fast-math 11.70 12.36 0.18 11.99
this pr 11.92 12.32 0.12 12.12 (99%)
Float_mul (multiplying floats in a tight loop) (lower is better)
(sec)
fast-math 11.72 12.17 0.12 11.93
this pr 12.01 12.62 0.17 12.26 (97%)
I have also looked at FPS numbers for tps-demo, 3d platformer, 2d
platformer, and sponza and could not find any measurable difference.
I believe that given the issues and oft-reported (physics) glitches on
release builds I believe that the couple of percent of tight-loop
floating point performance regression is well worth it.
This fixes #24540 and fixes #24841
(cherry picked from commit e5b335d367
)
This commit is contained in:
parent
c6cc6c86e5
commit
cada03eedb
|
@ -36,7 +36,3 @@ env_etc.add_source_files(env.modules_sources, "*.cpp")
|
||||||
# upstream uses c++11
|
# upstream uses c++11
|
||||||
if (not env_etc.msvc):
|
if (not env_etc.msvc):
|
||||||
env_etc.Append(CCFLAGS="-std=c++11")
|
env_etc.Append(CCFLAGS="-std=c++11")
|
||||||
# -ffast-math seems to be incompatible with ec2comp on recent versions of
|
|
||||||
# GCC and Clang
|
|
||||||
if '-ffast-math' in env_etc['CCFLAGS']:
|
|
||||||
env_etc['CCFLAGS'].remove('-ffast-math')
|
|
||||||
|
|
|
@ -150,7 +150,7 @@ def configure(env):
|
||||||
|
|
||||||
if (env["target"].startswith("release")):
|
if (env["target"].startswith("release")):
|
||||||
env.Append(LINKFLAGS=['-O2'])
|
env.Append(LINKFLAGS=['-O2'])
|
||||||
env.Append(CPPFLAGS=['-O2', '-DNDEBUG', '-ffast-math', '-funsafe-math-optimizations', '-fomit-frame-pointer'])
|
env.Append(CPPFLAGS=['-O2', '-DNDEBUG', '-fomit-frame-pointer'])
|
||||||
if (can_vectorize):
|
if (can_vectorize):
|
||||||
env.Append(CPPFLAGS=['-ftree-vectorize'])
|
env.Append(CPPFLAGS=['-ftree-vectorize'])
|
||||||
if (env["target"] == "release_debug"):
|
if (env["target"] == "release_debug"):
|
||||||
|
|
|
@ -37,14 +37,14 @@ def configure(env):
|
||||||
## Build type
|
## Build type
|
||||||
|
|
||||||
if (env["target"] == "release"):
|
if (env["target"] == "release"):
|
||||||
env.Prepend(CCFLAGS=['-O3', '-ffast-math'])
|
env.Prepend(CCFLAGS=['-O3'])
|
||||||
if (env["debug_symbols"] == "yes"):
|
if (env["debug_symbols"] == "yes"):
|
||||||
env.Prepend(CCFLAGS=['-g1'])
|
env.Prepend(CCFLAGS=['-g1'])
|
||||||
if (env["debug_symbols"] == "full"):
|
if (env["debug_symbols"] == "full"):
|
||||||
env.Prepend(CCFLAGS=['-g2'])
|
env.Prepend(CCFLAGS=['-g2'])
|
||||||
|
|
||||||
elif (env["target"] == "release_debug"):
|
elif (env["target"] == "release_debug"):
|
||||||
env.Prepend(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED'])
|
env.Prepend(CCFLAGS=['-O2', '-DDEBUG_ENABLED'])
|
||||||
if (env["debug_symbols"] == "yes"):
|
if (env["debug_symbols"] == "yes"):
|
||||||
env.Prepend(CCFLAGS=['-g1'])
|
env.Prepend(CCFLAGS=['-g1'])
|
||||||
if (env["debug_symbols"] == "full"):
|
if (env["debug_symbols"] == "full"):
|
||||||
|
|
|
@ -47,7 +47,7 @@ def configure(env):
|
||||||
|
|
||||||
if (env["target"].startswith("release")):
|
if (env["target"].startswith("release")):
|
||||||
env.Append(CPPFLAGS=['-DNDEBUG', '-DNS_BLOCK_ASSERTIONS=1'])
|
env.Append(CPPFLAGS=['-DNDEBUG', '-DNS_BLOCK_ASSERTIONS=1'])
|
||||||
env.Append(CPPFLAGS=['-O2', '-ftree-vectorize', '-fomit-frame-pointer', '-ffast-math', '-funsafe-math-optimizations'])
|
env.Append(CPPFLAGS=['-O2', '-ftree-vectorize', '-fomit-frame-pointer'])
|
||||||
env.Append(LINKFLAGS=['-O2'])
|
env.Append(LINKFLAGS=['-O2'])
|
||||||
|
|
||||||
if env["target"] == "release_debug":
|
if env["target"] == "release_debug":
|
||||||
|
|
|
@ -39,7 +39,7 @@ def configure(env):
|
||||||
## Build type
|
## Build type
|
||||||
|
|
||||||
if (env["target"] == "release"):
|
if (env["target"] == "release"):
|
||||||
env.Prepend(CCFLAGS=['-O3', '-ffast-math', '-fomit-frame-pointer', '-ftree-vectorize', '-msse2'])
|
env.Prepend(CCFLAGS=['-O3', '-fomit-frame-pointer', '-ftree-vectorize', '-msse2'])
|
||||||
if (env["debug_symbols"] == "yes"):
|
if (env["debug_symbols"] == "yes"):
|
||||||
env.Prepend(CCFLAGS=['-g1'])
|
env.Prepend(CCFLAGS=['-g1'])
|
||||||
if (env["debug_symbols"] == "full"):
|
if (env["debug_symbols"] == "full"):
|
||||||
|
|
|
@ -39,10 +39,10 @@ def configure(env):
|
||||||
## Build type
|
## Build type
|
||||||
|
|
||||||
if (env["target"] == "release"):
|
if (env["target"] == "release"):
|
||||||
env.Append(CCFLAGS=['-O2', '-ffast-math', '-fomit-frame-pointer'])
|
env.Append(CCFLAGS=['-O2', '-fomit-frame-pointer'])
|
||||||
|
|
||||||
elif (env["target"] == "release_debug"):
|
elif (env["target"] == "release_debug"):
|
||||||
env.Append(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED'])
|
env.Append(CCFLAGS=['-O2', '-DDEBUG_ENABLED'])
|
||||||
|
|
||||||
elif (env["target"] == "debug"):
|
elif (env["target"] == "debug"):
|
||||||
env.Append(CCFLAGS=['-g2', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
|
env.Append(CCFLAGS=['-g2', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
|
||||||
|
|
|
@ -70,16 +70,14 @@ def configure(env):
|
||||||
## Build type
|
## Build type
|
||||||
|
|
||||||
if (env["target"] == "release"):
|
if (env["target"] == "release"):
|
||||||
# -O3 -ffast-math is identical to -Ofast. We need to split it out so we can selectively disable
|
env.Prepend(CCFLAGS=['-O3'])
|
||||||
# -ffast-math in code for which it generates wrong results.
|
|
||||||
env.Prepend(CCFLAGS=['-O3', '-ffast-math'])
|
|
||||||
if (env["debug_symbols"] == "yes"):
|
if (env["debug_symbols"] == "yes"):
|
||||||
env.Prepend(CCFLAGS=['-g1'])
|
env.Prepend(CCFLAGS=['-g1'])
|
||||||
if (env["debug_symbols"] == "full"):
|
if (env["debug_symbols"] == "full"):
|
||||||
env.Prepend(CCFLAGS=['-g2'])
|
env.Prepend(CCFLAGS=['-g2'])
|
||||||
|
|
||||||
elif (env["target"] == "release_debug"):
|
elif (env["target"] == "release_debug"):
|
||||||
env.Prepend(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED'])
|
env.Prepend(CCFLAGS=['-O2', '-DDEBUG_ENABLED'])
|
||||||
if (env["debug_symbols"] == "yes"):
|
if (env["debug_symbols"] == "yes"):
|
||||||
env.Prepend(CCFLAGS=['-g1'])
|
env.Prepend(CCFLAGS=['-g1'])
|
||||||
if (env["debug_symbols"] == "full"):
|
if (env["debug_symbols"] == "full"):
|
||||||
|
|
Loading…
Reference in New Issue