Bug 19732 – make std.complex.expi fast.

Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-03-12T22:43:39Z
Last change time
2019-10-01T19:17:52Z
Assigned to
No Owner
Creator
Bastiaan Veelo

Comments

Comment #0 by Bastiaan — 2019-03-12T22:43:39Z
std.math.expi is deprecated, one is advised to use std.complex.expi instead. But, unlike the former, std.complex.expi does not make use of fsincos[1] when available. (And it's documentation refers to deprecated std.math.expi for a faster implementation, which is a bit silly.) [1] https://github.com/dlang/phobos/blob/d28a879fecbb7b478e660541bc94c402d38c913d/std/math.d#L3214
Comment #1 by Bastiaan — 2019-03-12T22:52:03Z
Comment #2 by Bastiaan — 2019-10-01T09:56:05Z
Nowadays, the x87 instruction fsincos is slower, not faster, than computing sin and cos separately. https://stackoverflow.com/questions/12485190/calling-fsincos-instruction-in-llvm-slower-than-calling-libc-sin-cos-functions Therefore, there is no need for assembly in the expi() implementation, which was removed in https://github.com/dlang/phobos/commit/029440c2f9008ff2fe8803c97900394bfe9b4e4e.
Comment #3 by kinke — 2019-10-01T14:09:34Z
(In reply to Bastiaan Veelo from comment #2) > Nowadays, the x87 instruction fsincos is slower, not faster, than computing > sin and cos separately. > > https://stackoverflow.com/questions/12485190/calling-fsincos-instruction-in- > llvm-slower-than-calling-libc-sin-cos-functions Have you actually tested this on your box? I recently came to completely different results with LDC on my i5-3550: https://github.com/ldc-developers/ldc/pull/2855#issuecomment-491560143 Note that `long double` is extremely rare in C(++), but ubiquitous in D.
Comment #4 by Bastiaan — 2019-10-01T19:14:28Z
(In reply to kinke from comment #3) > (In reply to Bastiaan Veelo from comment #2) > > Nowadays, the x87 instruction fsincos is slower, not faster, than computing > > sin and cos separately. > > > > https://stackoverflow.com/questions/12485190/calling-fsincos-instruction-in- > > llvm-slower-than-calling-libc-sin-cos-functions > > Have you actually tested this on your box? I recently came to completely > different results with LDC on my i5-3550: > https://github.com/ldc-developers/ldc/pull/2855#issuecomment-491560143 > > Note that `long double` is extremely rare in C(++), but ubiquitous in D. No I have not. What I'd like to know is why fsincos was removed from std.complex.expi in 2012, and why it wasn't readed when std.math.expi was deprecated last year. Feel free to reopen, as you have done the test.
Comment #5 by Bastiaan — 2019-10-01T19:17:52Z
Maybe there should be a std.math.sincos that does not depend on complex numbers at all?