Why is std.math slower than the C baseline?

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Jun 8 18:55:42 UTC 2020


On Mon, Jun 08, 2020 at 08:13:20PM +0200, Timon Gehr via Digitalmars-d wrote:
> On 08.06.20 05:05, data pulverizer wrote:
> > On Thursday, 4 June 2020 at 14:14:22 UTC, Andrei Alexandrescu wrote:
> > > D should just use the C functions when they offer better speed.
> > > 
> > > https://www.reddit.com/r/programming/comments/gvuy59/a_look_at_chapel_d_and_julia_using_kernel_matrix/fsr4w5o/
> > > 
> > 
> > If it's any help or informative I explicitly benchmark a selection
> > of mathematics functions from `std.math`, `core.stdc.math`, and
> > `LDC_intrinsic` here:
> > https://github.com/dataPulverizer/DMathBench/blob/master/report.md
> 
> > many important processes rely on their performance and accuracy.
> 
> This is true, but you only measured performance, not accuracy.

Case in point: the `sin` intrinsic in dmd is broken, because it uses the
x87 fsin instruction, which is buggy:

	https://issues.dlang.org/show_bug.cgi?id=15854

Certainly, using fsin is faster than a software implementation of
sin(x), but at the cost of a pretty badly-off result.


T

-- 
Do not reason with the unreasonable; you lose by definition.


More information about the Digitalmars-d mailing list