<p dir="ltr">I'd suspect stdc.math to be SSE3/SSE4 optimised assembly, where as std.math uses a very generic (works on almost every float format) implementation that is at least 'pure'.</p>
<p dir="ltr">Iain.</p>
<div class="gmail_quote">On 24 Mar 2015 00:30, "weaselcat via Digitalmars-d" <<a href="mailto:digitalmars-d@puremagic.com">digitalmars-d@puremagic.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Friday, 20 June 2014 at 12:32:39 UTC, Nick Treleaven wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
A Perlin noise benchmark was quoted in this reddit thread:<br>
<br>
<a href="http://www.reddit.com/r/rust/comments/289enx/c0de517e_where_is_my_c_replacement/cibn6sr" target="_blank">http://www.reddit.com/r/rust/<u></u>comments/289enx/c0de517e_<u></u>where_is_my_c_replacement/<u></u>cibn6sr</a><br>
<br>
It apparently shows the 3 main D compilers producing slower code than Go, Rust, gcc, clang, Nimrod:<br>
<br>
<a href="https://github.com/nsf/pnoise#readme" target="_blank">https://github.com/nsf/pnoise#<u></u>readme</a><br>
<br>
I initially wondered about std.random, but got this response:<br>
<br>
"Yeah, but std.random is not used in that benchmark, it just initializes 256 random vectors and permutates 256 sequential integers. What spins in a loop is just plain FP math and array read/writes. I'm sure it can be done faster, maybe D compilers are bad at automatic inlining or something. "<br>
<br>
Obviously this is only one person's benchmark, but I wondered if people would like to check their code and suggest reasons for the speed deficit.<br>
</blockquote>
<br>
I saw this thread when searching for something on the site, been a few months since anyone posted-<br>
<br>
I fixed the D flags, gdc is now about 15% faster than the second fastest in the benchmark(C - gcc) which obviously puts D in first.<br>
some notes:<br>
<br>
LDC is missing _tons_ of inline opportunities, killing it in comparison to GDC. I think GDC inlined pretty much everything. LDC is about 50% slower.<br>
<br>
Also, AFAICT there's no fast-math switch for LDC(enabling this for GDC might actually be compromising it though : ) )<br>
<br>
I think LDC turns the floor in std.math into the same as the stdc one, but GDC does not. std.math.floor is still abysmally slow, I thought it was because it was still using reals but that does not seem to be the case. GDC slows to a crawl(10-20x slower) if you replace the stdc floor with the one in std.math(just remove the alias)<br>
<br>
I thought this might be interesting to someone(i.e, LDC/GDC folks or phobos math folks)<br>
<br>
bye.<br>
</blockquote></div>