View mode: basic / threaded / horizontal-split · Log in · Help
June 23, 2008
Re: D postmortem
Walter Bright Wrote:

> Unfortunately, the article itself has gone down, but the comments are up:
> 
> http://www.reddit.com/r/programming/info/6ogl6/comments/

It was repeated in one of the comments.

I agree with everything there, except the fact taht no steps are being
taken to solve the paralellism problem. D is taking steps, although
whether those are the correct steps is a different question entirely.
June 24, 2008
Re: D postmortem
I was reading this thread:
http://www.reddit.com/r/programming/info/6ogl6/comments/

And it contains this:
WalterBright:
> I'm not sure what you're encountering with the struct return code. The D compiler does the named value return optimization, the same as C++. It will also return small structs in registers, as C++ compilers do. If you could email me (or put on bugzilla) an example of the problem, I can comment more.<

Stuct/classes usage in DMD is much slower than the same performed in C++ with MinGW.
After two days of benchmarks I have found a way that allows enough speed (and later I have written around that solution the tinyvect module you can find in my libs).

import d.func: Lets2;
struct Vec(TyDato, int n) {
 TyDato[n] data;
 void opAddAssign(Vec!(TyDato, n)* other) {
   mixin( Lets2!("this.data[%s] += other.data[%s];", n) );
 }
}

You have to allocate them like this, with a new:
auto v = new Vec!(long, 3);

The Lets2!() template generates n assignment lines at compile time, according to the fixed size of the array.
Every other way I have tried (about 30 different designs, I think) is 1.3-4 times slower, so if you need such speed you can't use classes, etc. But designing the struct this way doesn't allows to use operation overloading, I think.

Bye,
bearophile
June 24, 2008
Re: D postmortem
bearophile wrote:
> And it contains this: WalterBright:
>> I'm not sure what you're encountering with the struct return code.
>> The D compiler does the named value return optimization, the same
>> as C++. It will also return small structs in registers, as C++
>> compilers do. If you could email me (or put on bugzilla) an example
>> of the problem, I can comment more.<
> 
> Stuct/classes usage in DMD is much slower than the same performed in
> C++ with MinGW.

Can you look at the asm output and identify a case where it is less 
efficient?
June 24, 2008
Re: D postmortem
Walter Bright:
> Can you look at the asm output and identify a case where it is less efficient?

You are right, I have cleaned my code up a bit, removing too much silly experiments. This is just a first version, if you need something different I'll try to show something different:
http://rafb.net/p/TDxobC64.html
Its asm:
http://rafb.net/p/16MemX81.html
The timings at the end are done on a dual core at 2 GHz with DMD V.1.029 (I can't use the two successive versions).

I think efficiency losses come from many different sources, so it may be difficult to spot a single small thing to be fixed.
(But DMD is a young language, at the beginning Java too was really inefficient, so for now I agree that it's better to focus most work on developing the language. Efficiency issues are mostly for later).

Thank you,
bearophile
Top | Discussion index | About this forum | D home