Re: pi benchmark on ldc and dmd

2011-08-02 Thread Walter Bright
On 8/2/2011 3:23 PM, Trass3r wrote: Any reason for all those mov x,x 's? No. They'll get removed shortly. I see three problems with dmd's codegen here: 1. those redundant moves 2. failing to merge a couple divides 3. replacing a mul with an add/lea I'll see about taking care of them. (2) is

Re: pi benchmark on ldc and dmd

2011-08-02 Thread bearophile
Marco Leise: > Am 02.08.2011, 22:35 Uhr, schrieb bearophile : > > > pidgits n = 0 % (0 # (1,0,1)) where > > i%ds > > | i >= n = [] > > | True = (concat h ++ "\t:" ++ show j ++ "\n") ++ j%t > > where k = i+10; j = min n k > > (h,t) | k > n = (take (n`mod`10) ds ++ replicate (k-n) "

Re: pi benchmark on ldc and dmd

2011-08-02 Thread Trass3r
Am 02.08.2011, 22:38 Uhr, schrieb Walter Bright : L2E:inc R11 lea R9D,[00h][RSI*2] mov R9,R9 ... mov R9,RAX mov R9,R9 ... mov R12,RDX mov R12,R12

Re: pi benchmark on ldc and dmd

2011-08-02 Thread Marco Leise
Am 02.08.2011, 22:35 Uhr, schrieb bearophile : pidgits n = 0 % (0 # (1,0,1)) where i%ds | i >= n = [] | True = (concat h ++ "\t:" ++ show j ++ "\n") ++ j%t where k = i+10; j = min n k (h,t) | k > n = (take (n`mod`10) ds ++ replicate (k-n) " ",[]) | True = splitAt 10

Re: pi benchmark on ldc and dmd

2011-08-02 Thread Brad Roberts
https://github.com/D-Programming-Language/dmd/pull/287 Before pulling this, though, the current win32 compilation failure should be fixed to avoid compounding problems: https://github.com/D-Programming-Language/dmd/pull/288 Later, Brad On Tue, 2 Aug 2011, Brad Roberts wrote: > Ok.. I'm pret

Re: pi benchmark on ldc and dmd

2011-08-02 Thread Brad Roberts
Ok.. I'm pretty sure that's a bug I discovered the other day in the initilization code of asm blocks. I've already got a fix for it and will be sending a pull request shortly. The asm semantic code calls the 32bit initialization code of the backend unconditionally, which is just wrong. On Tue

Re: pi benchmark on ldc and dmd

2011-08-02 Thread simendsjo
On 02.08.2011 22:36, Andrew Wiley wrote: On Tue, Aug 2, 2011 at 1:31 PM, Iain Buclaw mailto:ibuc...@ubuntu.com>> wrote: == Quote from KennyTM~ (kenn...@gmail.com )'s article > On Aug 2, 11 20:00, Jason House wrote: > > The post says they did "dmd -O".

Re: pi benchmark on ldc and dmd

2011-08-02 Thread Adam D. Ruppe
Walter Bright wrote: > All I did with your example was replace BigInt with long. hmm this is my error, but might be a bug too. Take that same program and add some inline asm to it. void main() { asm { nop; } [... the rest is identical ...] } Now compile it and check the output. With the

Re: pi benchmark on ldc and dmd

2011-08-02 Thread Walter Bright
On 8/2/2011 12:49 PM, Adam D. Ruppe wrote: So I'm pretty sure the difference is caused by dmd not using the new registers in x64. The other differences look trivial to my eyes. When I compile it, it uses the registers: L2E:inc R11 lea R9D,[00h][RSI*2]

Re: pi benchmark on ldc and dmd

2011-08-02 Thread bearophile
Adam D. Ruppe: > Here's the program. It's based on one of the Python ones. The D code is about 2.8 times slower than the Haskell version, and it has a bug, shown here: import std.stdio, std.bigint; void main() { int x = 100; writefln("%010d", x); BigInt bx = x; writefln("%010d",

Re: pi benchmark on ldc and dmd

2011-08-02 Thread Andrew Wiley
On Tue, Aug 2, 2011 at 1:31 PM, Iain Buclaw wrote: > == Quote from KennyTM~ (kenn...@gmail.com)'s article > > On Aug 2, 11 20:00, Jason House wrote: > > > The post says they did "dmd -O". They did not mention "-inline > -noboundscheck > -release". There may be extra flags that are required. > > >

Re: pi benchmark on ldc and dmd

2011-08-02 Thread Iain Buclaw
== Quote from KennyTM~ (kenn...@gmail.com)'s article > On Aug 2, 11 20:00, Jason House wrote: > > The post says they did "dmd -O". They did not mention "-inline > > -noboundscheck -release". There may be extra flags that are required. > > > > Walter Bright Wrote: > > > >> http://www.reddit.com/r/p

Re: pi benchmark on ldc and dmd

2011-08-02 Thread Walter Bright
On 8/2/2011 12:49 PM, Adam D. Ruppe wrote: So I'm pretty sure the difference is caused by dmd not using the new registers in x64. The other differences look trivial to my eyes. dmd does use all the registers on the x64, but it seems to not be enregistering here. I'll have a look see.

Re: pi benchmark on ldc and dmd

2011-08-02 Thread Adam D. Ruppe
On the flags: I did use them, but didn't write it all out and tried to make them irrelevant (by avoiding functions and arrays). But, if the same ones are passed to each compiler, it shouldn't matter anyway... the idea is to get an apples to apples comparison between the two D implementations, not

Re: pi benchmark on ldc and dmd

2011-08-02 Thread KennyTM~
On Aug 2, 11 20:00, Jason House wrote: The post says they did "dmd -O". They did not mention "-inline -noboundscheck -release". There may be extra flags that are required. Walter Bright Wrote: http://www.reddit.com/r/programming/comments/j48tf/how_is_c_better_than_d/c29do98 Anyone care to ex

Re: pi benchmark on ldc and dmd

2011-08-02 Thread Andrew Wiley
On Tue, Aug 2, 2011 at 7:08 AM, Adam D. Ruppe wrote: > > LDC builds in under a half hour, even on my underpowered ARM SoC, > > so I don't see how you could be having trouble there. > > Building dmd from the zip took 37 *seconds* for me just now, after > running a make clean (this is on Linux). > >

Re: pi benchmark on ldc and dmd

2011-08-02 Thread Adam D. Ruppe
I think I have it: 64 bit registers. I got ldc to work in 32 bit (didn't have that yesterday, so I was doing 64 bit only) and compiled. No difference in timing between ldc 32 bit and dmd 32 bit. The disassembly isn't identical but the time is. (The disassembly seems to mainly order things differen

Re: pi benchmark on ldc and dmd

2011-08-02 Thread Walter Bright
On 8/2/2011 5:00 AM, Jason House wrote: The post says they did "dmd -O". They did not mention "-inline -noboundscheck -release". There may be extra flags that are required. Often when I see benchmark results like this, I wait to see what the actual problem is before jumping to conclusions. I h

Re: pi benchmark on ldc and dmd

2011-08-02 Thread David Nadlinger
On 8/2/11 7:34 PM, Robert Clipsham wrote: On 02/08/2011 00:40, Walter Bright wrote: Anyone care to examine the assembler output and figure out why? I was talking to David Nadlinger the other day, and there was some sort of codegen bug causing things to massively outperform dmd and clang with e

Re: pi benchmark on ldc and dmd

2011-08-02 Thread Robert Clipsham
On 02/08/2011 00:40, Walter Bright wrote: http://www.reddit.com/r/programming/comments/j48tf/how_is_c_better_than_d/c29do98 Anyone care to examine the assembler output and figure out why? I was talking to David Nadlinger the other day, and there was some sort of codegen bug causing things to

Re: pi benchmark on ldc and dmd

2011-08-02 Thread Adam D. Ruppe
> LDC builds in under a half hour, even on my underpowered ARM SoC, > so I don't see how you could be having trouble there. Building dmd from the zip took 37 *seconds* for me just now, after running a make clean (this is on Linux). gdc and ldc have their advantages, but they have disadvantages to

Re: pi benchmark on ldc and dmd

2011-08-02 Thread Trass3r
Am 02.08.2011, 05:38 Uhr, schrieb Adam D. Ruppe : I was waiting over an hour just for gcc+gdc to compile! In the time it takes for gcc's configure script to run, you can make clean, build dmd, druntime and phobos. Make sure you disable bootstrapping. Compiling gdc works pleasantly fast for m

Re: pi benchmark on ldc and dmd

2011-08-02 Thread Jason House
The post says they did "dmd -O". They did not mention "-inline -noboundscheck -release". There may be extra flags that are required. Walter Bright Wrote: > http://www.reddit.com/r/programming/comments/j48tf/how_is_c_better_than_d/c29do98 > > Anyone care to examine the assembler output and figur

Re: pi benchmark on ldc and dmd

2011-08-01 Thread Andrew Wiley
On Mon, Aug 1, 2011 at 8:38 PM, Adam D. Ruppe wrote: > bearophile wrote: > > In such situations it's never enough to compare the D code compiled > > with DMD to the D code compiled with LDC. You also need a reference > > point, like a C version compiled with GCC (here using GMP bignums). > > Such

Re: pi benchmark on ldc and dmd

2011-08-01 Thread Adam D. Ruppe
bearophile wrote: > In such situations it's never enough to compare the D code compiled > with DMD to the D code compiled with LDC. You also need a reference > point, like a C version compiled with GCC (here using GMP bignums). > Such reference points are necessary to anchor performance > discussio

Re: pi benchmark on ldc and dmd

2011-08-01 Thread bearophile
Adam D. Ruppe: > It was something that used bigint. I whipped it up myself earlier > this morning, but left the code on my laptop. I'll post it when > I have a chance. OK. In such situations it's never enough to compare the D code compiled with DMD to the D code compiled with LDC. You also need

Re: pi benchmark on ldc and dmd

2011-08-01 Thread Adam D. Ruppe
bearophile wrote: > Do you mean code similar to this one, or code that uses std.bigint? It was something that used bigint. I whipped it up myself earlier this morning, but left the code on my laptop. I'll post it when I have a chance. I ran obj2asm on it myself, but was a little short on time, so

Re: pi benchmark on ldc and dmd

2011-08-01 Thread bearophile
Walter: > http://www.reddit.com/r/programming/comments/j48tf/how_is_c_better_than_d/c29do98 > > Anyone care to examine the assembler output and figure out why? Do you mean code similar to this one, or code that uses std.bigint? http://shootout.alioth.debian.org/debian/program.php?test=pidigits&l

pi benchmark on ldc and dmd

2011-08-01 Thread Walter Bright
http://www.reddit.com/r/programming/comments/j48tf/how_is_c_better_than_d/c29do98 Anyone care to examine the assembler output and figure out why?