Is super-accuracy matters?
|
10-11-2023, 12:21 AM
(This post was last modified: 10-13-2023 04:52 PM by Albert Chan.)
Post: #16
|
|||
|
|||
RE: Is super-accuracy matters?
(10-09-2023 07:24 PM)johnb Wrote: "how do you convince others that additional accuracy/precision is/is-not needed?" It may be hard to show benefit, but we can go for how little cost it take. Example, I recently upgraded old luajit 1.1.8 with openlibm, for better accuracy. Old luajit was using msvcrt.dll FSIN/FCOS/FPTAN, with only 68 bits of pi see Intel Underestimates Error Bounds by 1.3 quintillion Code: OLD NEW = luajit + openlibm Adding openlibm code to luajit (*) does not bloat up dll's. (and, no cheating! libopenlibm.a is a static library) I don't quite understand how angle reduction code work, but result is amazing! Performance is OK, see Accurate trigonometric functions for large arguments lua> x = 1e22 lua> sin(x), dtoh(x) -0.8522008497671888 +0x1.0f0cf064dd592p+73 lua> !spigot --printf "%.17g" sin(0x1.0f0cf064dd592p+73) -0.8522008497671888 lua> x = 1e308 lua> sin(x), dtoh(x) 0.4533964905016491 +0x1.1ccf385ebc8a0p+1023 lua> !spigot --printf "%.17g" sin(0x1.1ccf385ebc8a0p+1023) 0.45339649050164912 Last 2 numbers actually matched. luajit use dtoa-fast for numeric output. Default is output minimum digits that round-trip, same as python 3. (*) the reason math related code move *inside* lua is due to mingw compiler design. If openlibm is *inside* lua51.dll, its code should get picked first, before msvcrt.dll Luajit 1.1.8, -O2 or higher, use hardware FSIN/FCOS/FPTAN for speed. Below patch would remove this optimization, and use libm versions instead. ljit_x86.h add sin/cos/tan (exact order!) partially inlined math functions. (patch in bold) Then, remove jit_inline_math() sin/cos/tan cases, and use default (libm) instead. ljit_x86.h Wrote:/* Partially inlined math functions. */ Proper way is to patch ljit_x86_inline.dash, then auto-generate ljit_x86.h But, that required working lua is available. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)