Adding tuning formulas for tanu, cosu and sinu, fix #112#114
Adding tuning formulas for tanu, cosu and sinu, fix #112#114pavpanchekha merged 4 commits intomainfrom
tanu, cosu and sinu, fix #112#114Conversation
| [(list `(sinu ,n) x) (list (ival-sinu n) x)] | ||
| [(list `(tanu ,n) x) (list (ival-tanu n) x)] | ||
| [(list `(cosu ,n) x) | ||
| (when i |
There was a problem hiding this comment.
We also export this fn->ival-fn to baseline, and baseline does not need to know about these constants, therefore, an ugly fix for that is to use it only in Rival
There was a problem hiding this comment.
Yeah I'm not too worried about baseline.
| (list (ival-sinu n) x)] | ||
| [(list `(tanu ,n) x) | ||
| (when i | ||
| (vector-set! constants i (exact-floor (log n)))) |
There was a problem hiding this comment.
Here I execute the constant for angle to be (exact-floor (log n)). We do it only once at compile time and seems to be fine? rather than do this every tuning pass we can do it once.
It slows down Rival's compilation and if someone will use Rival for really few points per expressions - probably they better not to optimize the original expressions. Thus, cosu, tanu, sinu will not arise at all
There was a problem hiding this comment.
Sure. I think this doesn't matter very much either way, it just can't really be that slow.
By the way, we might want integer-length instead of log? It might be faster?
There was a problem hiding this comment.
Hmm, we can, I tried to find a cheaper way, maybe integer-length indeed can work
tanu, cosu and sinutanu, cosu and sinu, fix #112
| [(list `(sinu ,n) x) (list (ival-sinu n) x)] | ||
| [(list `(tanu ,n) x) (list (ival-tanu n) x)] | ||
| [(list `(cosu ,n) x) | ||
| (when i |
There was a problem hiding this comment.
Yeah I'm not too worried about baseline.
| (list (ival-sinu n) x)] | ||
| [(list `(tanu ,n) x) | ||
| (when i | ||
| (vector-set! constants i (exact-floor (log n)))) |
There was a problem hiding this comment.
Sure. I think this doesn't matter very much either way, it just can't really be that slow.
By the way, we might want integer-length instead of log? It might be faster?
This PR introduces changes to Rival's exponent tricks.
Particularly speaking, tuning formulas for
tanu,cosuandsinuhave been added.It is quite interesting that we never ran into this before. One of the reasons why is that Linux uses an older version of MPFR - and we mostly use Linux.
The bug was discovered by @JonasRegehr when using Rival on MacOS.
The new exponent tricks are pretty straight forward, but the fact that the angle for
tanu, etc. is not stored as anivalmakes the code slightly tricky, as this angle needs to be stored somewhere since it participates in precision tuning.I store this angle constant into a new
rival-machinefield calledconstant-lookup- this is a vector to where we can add constants like this now on that do not participate in evaluation, but do participate in precision tuning.