Jump to page: 1 2 3
Thread overview
I wonder how fast we'd do
May 28, 2019
Nicholas Wilson
May 28, 2019
Mike Franklin
May 28, 2019
Mike Franklin
May 28, 2019
Walter Bright
May 28, 2019
Mike Franklin
May 28, 2019
Uknown
May 28, 2019
Marco de Wild
May 28, 2019
KnightMare
May 28, 2019
KnightMare
May 28, 2019
Marco de Wild
May 28, 2019
KnightMare
May 28, 2019
KnightMare
May 28, 2019
Atila Neves
May 28, 2019
Guillaume Piolat
May 28, 2019
Nicholas Wilson
May 29, 2019
Atila Neves
May 30, 2019
H. S. Teoh
May 28, 2019
Walter Bright
May 29, 2019
H. S. Teoh
May 29, 2019
Walter Bright
May 28, 2019
KnightMare
May 28, 2019
KnightMare
May 28, 2019
https://jackmott.github.io/programming/2016/07/22/making-obvious-fast.html
May 28, 2019
On Tuesday, 28 May 2019 at 04:38:32 UTC, Andrei Alexandrescu wrote:
> https://jackmott.github.io/programming/2016/07/22/making-obvious-fast.html

The DMD numbers will be crap because it doesn't autovectorise.  LDC should be the same as clang and GDC should be the same as gcc.
May 28, 2019
On Tuesday, 28 May 2019 at 04:38:32 UTC, Andrei Alexandrescu wrote:
> https://jackmott.github.io/programming/2016/07/22/making-obvious-fast.html

Here's a comparison between LDC, GCC 9.1, and CLang 8.0 in Compiler Explorer.  The GCC code looks awfully compact.  The LDC and CLang code look quite similar.

I tried to test at https://explore.dgnu.org/ also, but when I attempted, the service was down :(

Mike
May 28, 2019
On Tuesday, 28 May 2019 at 05:17:09 UTC, Mike Franklin wrote:
> On Tuesday, 28 May 2019 at 04:38:32 UTC, Andrei Alexandrescu wrote:
>> https://jackmott.github.io/programming/2016/07/22/making-obvious-fast.html
>
> Here's a comparison between LDC, GCC 9.1, and CLang 8.0 in Compiler Explorer.  The GCC code looks awfully compact.  The LDC and CLang code look quite similar.
>
> I tried to test at https://explore.dgnu.org/ also, but when I attempted, the service was down :(

And DMD with -O -release to get rid of bounds checking:

https://run.dlang.io/is/4QmXkO

Doesn't look as good as the others.

Mike


May 28, 2019
On Tuesday, 28 May 2019 at 04:38:32 UTC, Andrei Alexandrescu wrote:
> https://jackmott.github.io/programming/2016/07/22/making-obvious-fast.html

I tested 3 D variants :

---ver1.d
double sum = 0.0;
for (int i = 0; i < values.length; i++)
{
	double v = values[i] * values[i];
	sum += v;
}


---ver2.d
double sum = 0.0;
foreach (v; values)
        sum += v * v;
return sum;


---ver3.d
import std.algorithm : sum;
double[] squares;
squares[] = values[] * values[];
return squares.sum;

All 3 were the exact same with LDC. https://run.dlang.io/is/6pjEud
May 28, 2019
On Tuesday, 28 May 2019 at 05:17:09 UTC, Mike Franklin wrote:
> On Tuesday, 28 May 2019 at 04:38:32 UTC, Andrei Alexandrescu wrote:
>> https://jackmott.github.io/programming/2016/07/22/making-obvious-fast.html
>
> Here's a comparison between LDC, GCC 9.1, and CLang 8.0 in Compiler Explorer.  The GCC code looks awfully compact.  The LDC and CLang code look quite similar.

Forgot the link. oops.  https://godbolt.org/z/Unj9Kk

Mike


May 28, 2019
On Tuesday, 28 May 2019 at 05:20:14 UTC, Uknown wrote:
> On Tuesday, 28 May 2019 at 04:38:32 UTC, Andrei Alexandrescu wrote:
>> https://jackmott.github.io/programming/2016/07/22/making-obvious-fast.html
>
> I tested 3 D variants :
>
> ---ver1.d
> double sum = 0.0;
> for (int i = 0; i < values.length; i++)
> {
> 	double v = values[i] * values[i];
> 	sum += v;
> }
>
>
> ---ver2.d
> double sum = 0.0;
> foreach (v; values)
>         sum += v * v;
> return sum;
>
>
> ---ver3.d
> import std.algorithm : sum;
> double[] squares;
> squares[] = values[] * values[];
> return squares.sum;
>
> All 3 were the exact same with LDC. https://run.dlang.io/is/6pjEud

When the blog post released I wrote a few benchmarks. Surprisingly, using

values.map!(x => x*x).sum

was the fastest (faster than v1). It got around to 20 us on my machine.

May 28, 2019
On 5/27/2019 10:20 PM, Mike Franklin wrote:
> Doesn't look as good as the others.

It did unroll the loop, though!
May 28, 2019
>> https://run.dlang.io/is/6pjEud

I doubgt about results on my machine:
t1 : 42 ms, 858 ╬╝s, and 7 hnsecs       1.06672e+09
t2 : 42 ms, 647 ╬╝s, and 8 hnsecs       1.06672e+09
t3 : 0 hnsecs   0

// without printing results LDC drops calcs at all
// ldc2 -release -O3 times2.d
writeln("t1 : ", t1 / n, " \t", r1/n );
writeln("t2 : ", t2 / n, " \t", r2/n );
writeln("t3 : ", t3 / n, " \t", r3/n );


offtopic:
123╬╝s better change to 123us (for Windows sure)
May 28, 2019
> I doubgt about results on my machine:
> t1 : 42 ms, 858 ╬╝s, and 7 hnsecs       1.06672e+09
> t2 : 42 ms, 647 ╬╝s, and 8 hnsecs       1.06672e+09
> t3 : 0 hnsecs   0

my CPU is i7-3615QM (Ivy Bridge, no AVX2)
« First   ‹ Prev
1 2 3