Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimizations for power operator a^b #9

Closed
MikePall opened this issue Aug 18, 2015 · 1 comment
Closed

Optimizations for power operator a^b #9

MikePall opened this issue Aug 18, 2015 · 1 comment

Comments

@MikePall
Copy link
Member

The current narrowing and strength reduction for a^b aka math.pow(a, b) is problematic.

The a^i integer narrowing is definitely useful:

  • It opens other optimization opportunities (unrolling).
  • It gives more precise results than the exp/log method in some important cases, like 3^i.
  • But it may give different results than calling the libm pow() function. Whichever is more accurate is a question of the libm implementation and some debate. Especially when some intermediate step and/or the final result overflows FP precision.

The split into exp2(b*log2(a)) is of questionable utility and more troublesome:

  • It mainly benefits some silly benchmarks, where log2(a) can be hoisted out.
  • It doesn't give proper results for NaN, Inf and other special cases. Whether the libm implementation does that is often questionable, though.
  • It adds a dependency on C99 exp2() and log2(), which (still) aren't part of some libm implementations.
  • And/or their and our exp2() and log2() workaround implementations suck: exp(x_k) and log(x_k) are hopelessly imprecise.
  • All JIT backends have to do some weird dance to join these back together to pow() in the hope that this fixes some of these issues.

Definitely needs further discussion and analysis.

akopytov pushed a commit to akopytov/LuaJIT that referenced this issue Oct 15, 2016
Add tests for IR_CALLN and IR_CALLXS.
gut pushed a commit to PPC64/LuaJIT that referenced this issue Aug 30, 2017
Removed the complicated handling of lj_vm_ffi_call (it was a variable
size frame) and now backtrace works all over (e.g:)

 #0  0x00003fffb7d4875c in __libc_send (fd=32, buf=0x3fffb09a0028, len=8192, flags=0) at ../sysdeps/unix/sysv/linux/send.c:31
 #1  0x00003fffb7bea214 in socket_send (ps=0x3fffb7bc7778, data=0x3fffb09a0028 'A' <repeats 200 times>..., count=8192, sent=0x3fffffffee60, tm=0x3fffb7bc97d8) at usocket.c:205
 #2  0x00003fffb7be4ef8 in sendraw (buf=0x3fffb7bc77a0, data=0x3fffb09a0028 'A' <repeats 200 times>..., count=52428800, sent=0x3fffffffeee8) at buffer.c:176
 #3  0x00003fffb7be4960 in buffer_meth_send (L=0x3fffb7f6d280, buf=0x3fffb7bc77a0) at buffer.c:87
 LuaJIT#4  0x00003fffb7bec3f4 in meth_send (L=0x3fffb7f6d280) at tcp.c:130
 LuaJIT#5  0x0000000010042d44 in lj_BC_FUNCC ()
 LuaJIT#6  0x0000000010043f24 in lj_ff_coroutine_resume ()
 LuaJIT#7  0x000000001001d7d4 in lua_pcall (L=0x3fffb7f60378, nargs=0, nresults=-1, errfunc=2) at lj_api.c:1129
 LuaJIT#8  0x00000000100045e8 in docall (L=0x3fffb7f60378, narg=0, clear=0) at luajit.c:121
 LuaJIT#9  0x00000000100053ec in handle_script (L=0x3fffb7f60378, argx=0x3ffffffffa40) at luajit.c:291
 LuaJIT#10 0x0000000010006600 in pmain (L=0x3fffb7f60378) at luajit.c:551
 LuaJIT#11 0x0000000010042d44 in lj_BC_FUNCC ()
 LuaJIT#12 0x000000001001da40 in lua_cpcall (L=0x3fffb7f60378, func=0x10006334 <pmain>, ud=0x0) at lj_api.c:1153
 LuaJIT#13 0x00000000100067a4 in main (argc=2, argv=0x3ffffffffa38) at luajit.c:580
fsfod pushed a commit to fsfod/LuaJIT that referenced this issue Jan 2, 2018
Allow the hotcount table size to be overridden at compile time
@MikePall MikePall added enhancement and removed bug labels May 23, 2020
@MikePall
Copy link
Member Author

Done.

vittorioromeo pushed a commit to vittorioromeo/LuaJIT that referenced this issue Mar 26, 2021
Adding CMake build by @LuiJinghua
@eligo eligo mentioned this issue May 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant