On Wednesday, 22 May 2019 at 00:55:37 UTC, Adam D. Ruppe wrote:
On Wednesday, 22 May 2019 at 00:22:09 UTC, JS wrote:
I am trying to create some fast sin, sinc, and exponential
routines to speed up some code by using tables... but it seems
it's slower than the function itself?!?
There's intrinsic cpu instructions for some of those that can
do the math faster than waiting on memory access.
It is quite likely calculating it is actually faster. Even
carefully written and optimized tables tend to just have a very
small win relative to the cpu nowadays.
Exactly, and by the way this is old feature already.
I remember like long time ago when I was studying/writing some
games and I decided to test pre-computed arrays (LUT) for SIN/COS
vs functions, and the later would beat the arrays pretty easily.
And by the way when porting old games, sometimes you usually (If
not change the game logic too much), get rid of the LUT and use
functions directly.
Matheus.