Re:Implementing Cosine in C from Scratch (2020)
by jhgb on Tuesday March 29, 2022 @04:22PM
(#30847868)
FSIN only works on x87 registers which you will rarely use on AMD64 systems -- you really want to use at least scalar SSE2 today (since that is whence you receive your inputs as per typical AMD64 calling conventions anyway). Moving data from SSE registers to the FP stack just to calculate FSIN and then moving it back to SSE will probably kill your performance even if your FSIN implementation is good. If you're vectorizing your computation over 4 double floats or 8 single floats in an AVX register, it gets even worse for FSIN.
[ Parent
| on HN ]
Re:Implementing Cosine in C from Scratch (2020)
by stephencanon on Tuesday March 29, 2022 @04:48PM
(#30848165)
Moving between x87 and xmm registers is actually fairly cheap (it's through memory, so it's not free, but it's also not _that_ bad). FSIN itself is catastrophically slow.