Re: A little Py Vs C++

2012-11-03 Thread Jens Mueller
Simen Kjaeraas wrote:
> On 2012-39-03 12:11, Jens Mueller  wrote:
> 
> 
> >>
> >>I have a fork; some people are using it already. It still needs a lot of
> >>work though; some compilers missing parts, platforms not supported.
> >>That said, it's not an effort to address D's natural vector
> >>syntax, the key
> >>goal is to provide a hardware SIMD API that is as orthogonal as possible
> >>and portable (with confidence it will run reasonably well).
> >>I wonder if druntime could be enhanced to use the SIMD stuff
> >>though in the
> >>functions that perform the natural vector operations, might
> >>offer some nice
> >>little boosts.
> >
> >Cool.
> >It'll be nice though if D's vector operations could be expressed on top
> >of it. I mean a[] + b[] is so much easier to read.
> 
> Perhaps I'm the confused one here, but as I understand it, that's the
> whole point of the latter part of the paragraph - array operations are
> implemented in druntime, and that implementation might benefit from using
> SIMD instructions.

Sorry. I'm the one being confused. You're right Simen.

Jens


Re: A little Py Vs C++

2012-11-03 Thread Simen Kjaeraas

On 2012-39-03 12:11, Jens Mueller  wrote:




I have a fork; some people are using it already. It still needs a lot of
work though; some compilers missing parts, platforms not supported.
That said, it's not an effort to address D's natural vector syntax, the  
key

goal is to provide a hardware SIMD API that is as orthogonal as possible
and portable (with confidence it will run reasonably well).
I wonder if druntime could be enhanced to use the SIMD stuff though in  
the
functions that perform the natural vector operations, might offer some  
nice

little boosts.


Cool.
It'll be nice though if D's vector operations could be expressed on top
of it. I mean a[] + b[] is so much easier to read.


Perhaps I'm the confused one here, but as I understand it, that's the
whole point of the latter part of the paragraph - array operations are
implemented in druntime, and that implementation might benefit from using
SIMD instructions.


--
Simen


Re: A little Py Vs C++

2012-11-03 Thread Jens Mueller
Manu wrote:
> On 3 November 2012 01:41, Walter Bright  wrote:
> 
> > On 11/2/2012 3:10 PM, Jens Mueller wrote:
> >
> >> I see. Thanks for clarifying.
> >> If I want fast vector operations I have to use core.simd. The built-in
> >> vector operations won't fit the bill.
> >>
> >
> I think a better quote would be "If i want *HARDWARE* vector
> operations..."; this is not automatically faster by nature, it requires
> strict self-control in terms of application, and very careful attention if
> you want your code to be portable.
> 
> At the moment, yes.
> >
> > However, Manu is working on developing a higher order layer.
> >
> 
> I have a fork; some people are using it already. It still needs a lot of
> work though; some compilers missing parts, platforms not supported.
> That said, it's not an effort to address D's natural vector syntax, the key
> goal is to provide a hardware SIMD API that is as orthogonal as possible
> and portable (with confidence it will run reasonably well).
> I wonder if druntime could be enhanced to use the SIMD stuff though in the
> functions that perform the natural vector operations, might offer some nice
> little boosts.

Cool.
It'll be nice though if D's vector operations could be expressed on top
of it. I mean a[] + b[] is so much easier to read.

Jens


Re: A little Py Vs C++

2012-11-03 Thread Manu
On 3 November 2012 01:41, Walter Bright  wrote:

> On 11/2/2012 3:10 PM, Jens Mueller wrote:
>
>> I see. Thanks for clarifying.
>> If I want fast vector operations I have to use core.simd. The built-in
>> vector operations won't fit the bill.
>>
>
I think a better quote would be "If i want *HARDWARE* vector
operations..."; this is not automatically faster by nature, it requires
strict self-control in terms of application, and very careful attention if
you want your code to be portable.

At the moment, yes.
>
> However, Manu is working on developing a higher order layer.
>

I have a fork; some people are using it already. It still needs a lot of
work though; some compilers missing parts, platforms not supported.
That said, it's not an effort to address D's natural vector syntax, the key
goal is to provide a hardware SIMD API that is as orthogonal as possible
and portable (with confidence it will run reasonably well).
I wonder if druntime could be enhanced to use the SIMD stuff though in the
functions that perform the natural vector operations, might offer some nice
little boosts.


Re: A little Py Vs C++

2012-11-02 Thread Walter Bright

On 11/2/2012 3:10 PM, Jens Mueller wrote:

I see. Thanks for clarifying.
If I want fast vector operations I have to use core.simd. The built-in
vector operations won't fit the bill.


At the moment, yes.

However, Manu is working on developing a higher order layer.




Re: A little Py Vs C++

2012-11-02 Thread Jens Mueller
Walter Bright wrote:
> On 11/2/2012 11:19 AM, Jacob Carlborg wrote:
> >I can absolutely understand why he did it but it would be really nice if you
> >(Walter, Andrei and probably others as well) could be more transparent about
> >things like these. I think this would really help the community.
> 
> I apologize for being circumspect about this, but I have to respect
> peoples' privacy and I cleared what I posted about Remedy with them
> before posting it.

There is no need to reveal anything private just because you have a road
map.

Jens


Re: A little Py Vs C++

2012-11-02 Thread Jens Mueller
Andrei Alexandrescu wrote:
> On 11/2/12 1:22 PM, Walter Bright wrote:
> >On 11/2/2012 2:01 AM, Jens Mueller wrote:
> > > I had the same thought when reading this. Very disappointing. An issue
> > > with zero votes is fixed instead of more important ones.
> >
> >It's a very fair question.
> >
> >Manu works for Remedy Games, a developer of hit PC games, such as Max
> >Payne and Alan Wake. He champions a team that is investigating
> >committing to D for a major new game. This would be a huge design win
> >for D, and an enormous boost for D. I view the most effective use of my
> >time at the moment is to ensure that they can bet on D and win. Remedy's
> >use of D for a high profile product will prove that D is ready and able
> >for the big time, and that others can develop using D with confidence.
> >
> >Nearly all of what he needs the D community needs anyway, such as the
> >big push for Win64 support and the SIMD support (more on that in another
> >post).
> 
> I should add that I'm also totally behind this. When Walter jumped
> into implementing SIMD support on a hunch, I completely disagreed,
> but that was a great decision.

>From the inside you can tell it is a great decision. From the outside it
looks different.

Jens


Re: A little Py Vs C++

2012-11-02 Thread Jens Mueller
Walter Bright wrote:
> On 11/2/2012 2:01 AM, Jens Mueller wrote:
> > I had the same thought when reading this. Very disappointing. An issue
> > with zero votes is fixed instead of more important ones.
> 
> It's a very fair question.
> 
> Manu works for Remedy Games, a developer of hit PC games, such as
> Max Payne and Alan Wake. He champions a team that is investigating
> committing to D for a major new game. This would be a huge design
> win for D, and an enormous boost for D. I view the most effective
> use of my time at the moment is to ensure that they can bet on D and
> win. Remedy's use of D for a high profile product will prove that D
> is ready and able for the big time, and that others can develop
> using D with confidence.
> 
> Nearly all of what he needs the D community needs anyway, such as
> the big push for Win64 support and the SIMD support (more on that in
> another post).

Now I can understand why you made these decisions. It makes sense to me.
But I'd like to know which direction the ship is sailing.
The current rationale is to proof that D is ready for prime time. Though
I fear that some issues in the bug tracker may give a bad impression.
But in general the decision process should be as open and transparent as
possible. In Jacob's words: We need a road map.

Jens


Re: A little Py Vs C++

2012-11-02 Thread Jens Mueller
Walter Bright wrote:
> On 11/2/2012 3:50 AM, Jens Mueller wrote:
> > Okay. For me they look the same. Can you elaborate, please? Assume I
> > want to add two float vectors which is common in both games and
> > scientific computing. The only difference is in games their length is
> > usually 3 or 4 whereas in scientific computing they are of arbitrary
> > length. Why do I need instrinsics to support the game setting?
> 
> Another excellent question.
> 
> Most languages have taken the "auto-vectorization" approach of
> reverse engineering loops to turn them into high level constructs,
> and then compiling the code into special SIMD instructions.
> 
> How to do this is explained in detail in the (rare) book "The
> Software Vectorization Handbook" by Bik, which I fortunately was
> able to obtain a copy of.
> 
> This struck me as a terrible approach, however. It just seemed
> stupid to try to teach the compiler to reverse engineer low level
> code into high level code. A better design would be to start with
> high level code. Hence, the appearance of D vector operations.
> 
> The trouble with D vector operations, however, is that they are too
> general purpose. The SIMD instructions are very quirky, and it's
> easy to unwittingly and silently cause the compiler to generate
> absolutely terribly slow code. The reasons for that are the
> alignment requirements, coupled with the SIMD instructions not being
> orthogonal - some operations work for some types and not for others,
> in a way that is unintuitive unless you're carefully reading the
> SIMD specs.
> 
> Just saying align(16) isn't good enough, as the vector ops work on
> slices and those slices aren't always aligned. So each one has to
> check alignment at runtime, which is murder on performance.
> 
> If a particular vector op for a particular type has no SIMD support,
> then the compiler has to generate workaround code. This can also
> have terrible performance consequences.
> 
> So the user writes vector code, benchmarks it, finds zero
> improvement, and the reasons why will be elusive to anyone but an
> expert SIMD programmer.
> 
> (Auto-vectorizing technology has similar issues, pretty much meaning
> you won't get fast code out of it unless you've got a habit of
> examining the assembler output and tweaking as necessary.)
> 
> Enter Manu, who has a lot of experience making SIMD work for games.
> His proposal was:
> 
> 1. Have native SIMD types. This will guarantee alignment, and will
> guarantee a compile time error for SIMD types that are not supported
> by the CPU.
> 
> 2. Have the compiler issue an error for SIMD operations that are not
> supported by the CPU, rather than silently generating inefficient
> workaround code.
> 
> 3. There are all kinds of weird but highly useful SIMD instructions
> that don't have a straightforward representation in high level code,
> such as saturated arithmetic. Manu's answer was to expose these
> instructions via intrinsics, so the user can string them together,
> be sure that they will generate real SIMD instructions, while the
> compiler can deal with register allocation.
> 
> This approach works, is inlineable, generates code as good as
> hand-built assembler, and is useable by regular programmers.
> 
> I won't say there aren't better approaches, but this one we know works.

I see. Thanks for clarifying.
If I want fast vector operations I have to use core.simd. The built-in
vector operations won't fit the bill. I was of the opinion that a vector
operation in D should (at some point) generate vectorized code.

Jens


Re: A little Py Vs C++

2012-11-02 Thread Kapps

On Friday, 2 November 2012 at 14:22:34 UTC, Jens Mueller wrote:

But the compiler knows about the alignment, doesn't it?

align(16) float[4] a;
vs
float[4] a;

In the former case the compiler can generate better code and it 
should.
The above syntax is not supported. But my point is all the 
compiler
cares about is the alignment which can be specified in the code 
somehow.

Sorry for being stubborn.

Jens


Note: My knowledge of SIMD/SSE is fairly limited, and may be 
somewhat out of date. In other words, some of this may be flat 
out wrong.


First, just because you have something that can have SIMD 
operations performed on it, doesn't mean you necessarily want to. 
SSE instructions for example have to store things in the XMM 
registers, and accessing the actual values of individual elements 
in the vector is expensive. When using SSE, you want to avoid 
accessing individual elements as much as possible. Not following 
this tends to hurt performance quite badly. Yet when you just 
have a float[4], you may or may not be frequently or infrequently 
accessing individual elements. The compiler can't know whether 
you use it as a single SIMD vector more often, or use it to 
simply store 4 elements more often. You could be aligning it for 
any reason, so it's not too fair a way of determining it.


Secondly, you can't really know which SIMD instructions are 
supported by your target CPU. It's safe to say SSE2 is supported 
for pretty much all x86 CPUs at this point, but something like 
SSE4.2 instructions may not be. Just because the compiler knows 
that the CPU compiling it supports it doesn't mean that the CPU 
running the program will have those instructions.


Lastly, we'd still need SIMD intrinsics. It may be simple to tell 
that a float[4] + float[4] operation could use addps, but it 
would be more difficult to determine when to use something like 
dotps (dot product across two SIMD vectors), and various other 
instructions. Not to mention, non-x86 architectures.


Re: A little Py Vs C++

2012-11-02 Thread Jacob Carlborg

On 2012-11-02 21:22, jerro wrote:


SIMD support was discussed here at length in the days before it was
implemented. See this thread:


Yeah, I know it's been talked about and discussed, but it's the final 
decision that's missing.


--
/Jacob Carlborg


Re: A little Py Vs C++

2012-11-02 Thread jerro
"After a throughout discussion with Manu (or 'a fellow D 
programmer' if he/she prefers to be anonymous) we have decided 
it would be in best interest of D if we implement this 
particular feature. From now on this is where I will focus most 
most of my time".


Something like this would be far better then suddenly seeing 
commits regarding SIMD (or whatever feature it might be) for 
out of the blue.


SIMD support was discussed here at length in the days before it 
was implemented. See this thread:


http://forum.dlang.org/thread/jdhb57$10vf$1...@digitalmars.com#post-wdjdcrkiaakmkzqtdhxu:40dfeed.kimsufi.thecybershadow.net

and this thread:

http://forum.dlang.org/post/mailman.76.1325814175.16222.digitalmar...@puremagic.com


Re: A little Py Vs C++

2012-11-02 Thread Jacob Carlborg

On 2012-11-02 20:22, Manu wrote:


This is probably my fault, and a matter of corporate transparency. We
didn't want to make a noise about it until we reached a particular level
of confidence.
We're fairly invested now, and quietly hopeful it will go ahead from here.


This has nothing to do with corporate transparency. It has to do with 
transparency to the community, see my reply to Walter:


http://forum.dlang.org/thread/jauixhakwvpgsghap...@forum.dlang.org?page=6#post-k718iu:242iu6:241:40digitalmars.com

--
/Jacob Carlborg


Re: A little Py Vs C++

2012-11-02 Thread Jacob Carlborg

On 2012-11-02 19:36, Walter Bright wrote:


I apologize for being circumspect about this, but I have to respect
peoples' privacy and I cleared what I posted about Remedy with them
before posting it.


This has nothing to do with what Manu does for a living (sure, 
mentioning Remedy gives it more weight, at least for me). It's more in 
the line of creating a post/starting a new thread saying something like:


"After a throughout discussion with Manu (or 'a fellow D programmer' if 
he/she prefers to be anonymous) we have decided it would be in best 
interest of D if we implement this particular feature. From now on this 
is where I will focus most most of my time".


Something like this would be far better then suddenly seeing commits 
regarding SIMD (or whatever feature it might be) for out of the blue.


--
/Jacob Carlborg


Re: A little Py Vs C++

2012-11-02 Thread Manu
On 2 November 2012 20:36, Walter Bright  wrote:

> On 11/2/2012 11:19 AM, Jacob Carlborg wrote:
>
>> I can absolutely understand why he did it but it would be really nice if
>> you
>> (Walter, Andrei and probably others as well) could be more transparent
>> about
>> things like these. I think this would really help the community.
>>
>
> I apologize for being circumspect about this, but I have to respect
> peoples' privacy and I cleared what I posted about Remedy with them before
> posting it.
>

That said, I think we'd perhaps appreciate that it doesn't appear all over
the internets just yet. It would be much more interesting, and probably
have a lot more impact if we made such an announcement alongside something
to show.


Re: A little Py Vs C++

2012-11-02 Thread Manu
On 2 November 2012 20:19, Jacob Carlborg  wrote:

> On 2012-11-02 18:46, Andrei Alexandrescu wrote:
>
>  I should add that I'm also totally behind this. When Walter jumped into
>> implementing SIMD support on a hunch, I completely disagreed, but that
>> was a great decision.
>>
>
> I can absolutely understand why he did it but it would be really nice if
> you (Walter, Andrei and probably others as well) could be more transparent
> about things like these. I think this would really help the community.


This is probably my fault, and a matter of corporate transparency. We
didn't want to make a noise about it until we reached a particular level of
confidence.
We're fairly invested now, and quietly hopeful it will go ahead from here.


Re: A little Py Vs C++

2012-11-02 Thread Manu
On 2 November 2012 20:10, deadalnix  wrote:

> Le 02/11/2012 18:46, Andrei Alexandrescu a écrit :
>
>  On 11/2/12 1:22 PM, Walter Bright wrote:
>>
>>> On 11/2/2012 2:01 AM, Jens Mueller wrote:
>>> > I had the same thought when reading this. Very disappointing. An issue
>>> > with zero votes is fixed instead of more important ones.
>>>
>>> It's a very fair question.
>>>
>>> Manu works for Remedy Games, a developer of hit PC games, such as Max
>>> Payne and Alan Wake. He champions a team that is investigating
>>> committing to D for a major new game. This would be a huge design win
>>> for D, and an enormous boost for D. I view the most effective use of my
>>> time at the moment is to ensure that they can bet on D and win. Remedy's
>>> use of D for a high profile product will prove that D is ready and able
>>> for the big time, and that others can develop using D with confidence.
>>>
>>> Nearly all of what he needs the D community needs anyway, such as the
>>> big push for Win64 support and the SIMD support (more on that in another
>>> post).
>>>
>>
>> I should add that I'm also totally behind this. When Walter jumped into
>> implementing SIMD support on a hunch, I completely disagreed, but that
>> was a great decision.
>>
>> Andrei
>>
>
> I still don't understand the benefice over align(16) float[4] .
>

It's a mechanism to insist on register placement and usage semantics. On
the vast majority of architectures, floats and simd are absolutely
incompatible. It's awfully dangerous to describe them both with a single
type when they are mutually exclusive...


Re: A little Py Vs C++

2012-11-02 Thread Manu
On 2 November 2012 20:02, Walter Bright  wrote:

> On 11/2/2012 3:50 AM, Jens Mueller wrote:
> > Okay. For me they look the same. Can you elaborate, please? Assume I
> > want to add two float vectors which is common in both games and
> > scientific computing. The only difference is in games their length is
> > usually 3 or 4 whereas in scientific computing they are of arbitrary
> > length. Why do I need instrinsics to support the game setting?
>
> Another excellent question.
>
> Most languages have taken the "auto-vectorization" approach of reverse
> engineering loops to turn them into high level constructs, and then
> compiling the code into special SIMD instructions.
>
> How to do this is explained in detail in the (rare) book "The Software
> Vectorization Handbook" by Bik, which I fortunately was able to obtain a
> copy of.
>
> This struck me as a terrible approach, however. It just seemed stupid to
> try to teach the compiler to reverse engineer low level code into high
> level code. A better design would be to start with high level code. Hence,
> the appearance of D vector operations.
>
> The trouble with D vector operations, however, is that they are too
> general purpose. The SIMD instructions are very quirky, and it's easy to
> unwittingly and silently cause the compiler to generate absolutely terribly
> slow code. The reasons for that are the alignment requirements, coupled
> with the SIMD instructions not being orthogonal - some operations work for
> some types and not for others, in a way that is unintuitive unless you're
> carefully reading the SIMD specs.
>
> Just saying align(16) isn't good enough, as the vector ops work on slices
> and those slices aren't always aligned. So each one has to check alignment
> at runtime, which is murder on performance.
>
> If a particular vector op for a particular type has no SIMD support, then
> the compiler has to generate workaround code. This can also have terrible
> performance consequences.
>
> So the user writes vector code, benchmarks it, finds zero improvement, and
> the reasons why will be elusive to anyone but an expert SIMD programmer.
>
> (Auto-vectorizing technology has similar issues, pretty much meaning you
> won't get fast code out of it unless you've got a habit of examining the
> assembler output and tweaking as necessary.)
>
> Enter Manu, who has a lot of experience making SIMD work for games. His
> proposal was:
>
> 1. Have native SIMD types. This will guarantee alignment, and will
> guarantee a compile time error for SIMD types that are not supported by the
> CPU.
>
> 2. Have the compiler issue an error for SIMD operations that are not
> supported by the CPU, rather than silently generating inefficient
> workaround code.
>
> 3. There are all kinds of weird but highly useful SIMD instructions that
> don't have a straightforward representation in high level code, such as
> saturated arithmetic. Manu's answer was to expose these instructions via
> intrinsics, so the user can string them together, be sure that they will
> generate real SIMD instructions, while the compiler can deal with register
> allocation.
>

Well, I wouldn't claim any credit for the approach ;) .. I think this is
the standard for maximum performance, and also very well understood.
But the thing that excites me most is the potential quality of libraries
that can be built on top. D has so much potential to extend on this SIMD
foundation with it's templates being able to intelligently handle far more
context specific situations.
What we do already in other languages will be far more convenient, more
portable, and possibly even produce better code in D. And the biggest
bonus, it will be readable! :)

I think it's a low risk investment, and it doesn't prohibit higher level
support in the future.


This approach works, is inlineable, generates code as good as hand-built
> assembler, and is useable by regular programmers.
>
> I won't say there aren't better approaches, but this one we know works.
>

Aye, and it's relatively un-intrusive too. Some new types and a few
intrinsics, build useful libraries on top. It shouldn't have complex side
effects, and if offers something that was sorely missing from the language
today.


Re: A little Py Vs C++

2012-11-02 Thread Manu
On 2 November 2012 19:32, Andrej Mitrovic wrote:

> On 11/2/12, Walter Bright  wrote:
> > Manu works for Remedy Games, a developer of hit PC games, such as Max
> Payne
> > and
> > Alan Wake. He champions a team that is investigating committing to D for
> a
> > major
> > new game.
>
> Wow that's really cool!
>
> Manu if you know of any trivial-type bugs you'd like to get fixed (for
> example error messages) let me know so I can prioritize them. There's
> a ton of open issues and I usually select the ones for fixing by
> random. I've managed to fix a few so far. :)
>

Hey cheers man! :)
Actually, one thing that does consistently bite me are nonsensical error
messages. I'll start keeping tabs on them.


Re: A little Py Vs C++

2012-11-02 Thread Manu
Uh oh, I just caught wind of this thread! ;)

If there's a single argument I'd like to make in defense of the changes
that have gone through as a result of my motivating, it's that they're
either big tickets and mutually beneficial for the whole community anyway
(DMD-win64), or relatively trivial (function prototypes + definitions)
details that enable us to realistically consider proceeding with D
commercially.

The SIMD types support may be considered a little grey, but I've
encountered loads of general D users who appreciate the SIMD work already,
and while it's certainly not trivial, it's nowhere the mammoth scale of
task auto-vectorisation would be. I can't see it as a loss for the language
or the community, and again, it has further enabled our consideration of D
commercially; which I'd like to think is a general goal for the language.

I know plenty of you don't care about me or my industry, but I maintain
that it's an entire industry in desperate need of salvation from C++,
there's a lot of potential in the games industry to get fantastic value
from using D, and I'm interested in proving that it's a realistic
consideration.

I'd also like to note that we are also very conscious of the time Walter
and other contributors have kindly offered to our support, and we are
hopeful to be able to give reasonable value back to the community should it
all go well for us, in whatever way that manifests...

On 2 November 2012 11:01, Jens Mueller  wrote:

> Jacob Carlborg wrote:
> > On 2012-11-01 23:51, Walter Bright wrote:
> >
> > >What about all your feature requests? I think you've made more than
> > >anyone, by a factor of 10 at least!
> > >
> > >:-)
> > >
> > >As for Manu's request
> > >
> > >http://d.puremagic.com/issues/show_bug.cgi?id=8108
> > >
> > >I've gone over with him why he needs it, and there's no other reasonable
> > >way. He needs it for real code in a real application.
> >
> > This is quite interesting. Manu comes in from basically nowhere and
> > fairly quickly manage to convince Walter to implement at least two
> > feature requests, this one and the SIMD support. I'm not saying that
> > they shouldn't have been implemented. Although I think something
> > like AST macros could possible solve issue 8108 and a whole bunch of
> > other features, a few already present in the language.
>
> I had the same thought when reading this. Very disappointing. An issue
> with zero votes is fixed instead of more important ones. Why do I vote
> anyway?
> Regarding SIMD I have the feeling that because it is built into the
> compiler static vectors have actually failed what they promised. I
> thought D proposed a portable way of vector operations such that you
> write
> float[4] = a[] + b[]
> and the compiler generates SIMD code for you.
>

As I mentioned above, I think that is a MUCH larger task, and probably
fairly unrealistic in the near-term regardless.
But secondly, it's just not that simple. (I can see Walter has already
addressed it in a previous post)

It's worth considering that a very significant portion of the silicon on
modern processors (well in excess of 50% on some chips) is dedicated to
hardware acceleration of SIMD/media functions. Until recently, D simply
offered no mechanism at all to interact with half of the silicone in your
box. That's a massive language hole.
At least as a starting point, low level access to this hardware is vital.
Portable libraries can be built using this technology, which are
immediately useful.

The definition of hardware SIMD types doesn't rule out possible future
auto-vectorisation either. And you can probably access auto-vectorising
backends right now if you use GDC or LDC.


Re: A little Py Vs C++

2012-11-02 Thread deadalnix

Le 02/11/2012 19:25, mist a écrit :

On Friday, 2 November 2012 at 18:19:54 UTC, Jacob Carlborg wrote:

On 2012-11-02 18:46, Andrei Alexandrescu wrote:


I should add that I'm also totally behind this. When Walter jumped into
implementing SIMD support on a hunch, I completely disagreed, but that
was a great decision.


I can absolutely understand why he did it but it would be really nice
if you (Walter, Andrei and probably others as well) could be more
transparent about things like these. I think this would really help
the community.


So true. Strong mid-term vision of rationales of main language
developers really helps to reason about it.


Yeah, and avoid noise and help people concentrate on main points.


Re: A little Py Vs C++

2012-11-02 Thread Walter Bright

On 11/2/2012 11:19 AM, Jacob Carlborg wrote:

I can absolutely understand why he did it but it would be really nice if you
(Walter, Andrei and probably others as well) could be more transparent about
things like these. I think this would really help the community.


I apologize for being circumspect about this, but I have to respect peoples' 
privacy and I cleared what I posted about Remedy with them before posting it.




Re: A little Py Vs C++

2012-11-02 Thread mist

On Friday, 2 November 2012 at 18:19:54 UTC, Jacob Carlborg wrote:

On 2012-11-02 18:46, Andrei Alexandrescu wrote:

I should add that I'm also totally behind this. When Walter 
jumped into
implementing SIMD support on a hunch, I completely disagreed, 
but that

was a great decision.


I can absolutely understand why he did it but it would be 
really nice if you (Walter, Andrei and probably others as well) 
could be more transparent about things like these. I think this 
would really help the community.


So true. Strong mid-term vision of rationales of main language 
developers really helps to reason about it.


Re: A little Py Vs C++

2012-11-02 Thread deadalnix

Le 02/11/2012 19:19, Jacob Carlborg a écrit :

On 2012-11-02 18:46, Andrei Alexandrescu wrote:


I should add that I'm also totally behind this. When Walter jumped into
implementing SIMD support on a hunch, I completely disagreed, but that
was a great decision.


I can absolutely understand why he did it but it would be really nice if
you (Walter, Andrei and probably others as well) could be more
transparent about things like these. I think this would really help the
community.



I couldn't agree more.


Re: A little Py Vs C++

2012-11-02 Thread Jacob Carlborg

On 2012-11-02 18:46, Andrei Alexandrescu wrote:


I should add that I'm also totally behind this. When Walter jumped into
implementing SIMD support on a hunch, I completely disagreed, but that
was a great decision.


I can absolutely understand why he did it but it would be really nice if 
you (Walter, Andrei and probably others as well) could be more 
transparent about things like these. I think this would really help the 
community.


--
/Jacob Carlborg


Re: A little Py Vs C++

2012-11-02 Thread Jacob Carlborg

On 2012-11-02 18:22, Walter Bright wrote:


It's a very fair question.

Manu works for Remedy Games, a developer of hit PC games, such as Max
Payne and Alan Wake. He champions a team that is investigating
committing to D for a major new game. This would be a huge design win
for D, and an enormous boost for D. I view the most effective use of my
time at the moment is to ensure that they can bet on D and win. Remedy's
use of D for a high profile product will prove that D is ready and able
for the big time, and that others can develop using D with confidence.

Nearly all of what he needs the D community needs anyway, such as the
big push for Win64 support and the SIMD support (more on that in another
post).


I can absolutely see the point in this. Thanks for taking the time and 
explaining this.


--
/Jacob Carlborg


Re: A little Py Vs C++

2012-11-02 Thread deadalnix

Le 02/11/2012 18:46, Andrei Alexandrescu a écrit :

On 11/2/12 1:22 PM, Walter Bright wrote:

On 11/2/2012 2:01 AM, Jens Mueller wrote:
> I had the same thought when reading this. Very disappointing. An issue
> with zero votes is fixed instead of more important ones.

It's a very fair question.

Manu works for Remedy Games, a developer of hit PC games, such as Max
Payne and Alan Wake. He champions a team that is investigating
committing to D for a major new game. This would be a huge design win
for D, and an enormous boost for D. I view the most effective use of my
time at the moment is to ensure that they can bet on D and win. Remedy's
use of D for a high profile product will prove that D is ready and able
for the big time, and that others can develop using D with confidence.

Nearly all of what he needs the D community needs anyway, such as the
big push for Win64 support and the SIMD support (more on that in another
post).


I should add that I'm also totally behind this. When Walter jumped into
implementing SIMD support on a hunch, I completely disagreed, but that
was a great decision.

Andrei


I still don't understand the benefice over align(16) float[4] .


Re: A little Py Vs C++

2012-11-02 Thread Regan Heath

On Fri, 02 Nov 2012 18:10:39 -, deadalnix  wrote:


Le 02/11/2012 18:46, Andrei Alexandrescu a écrit :

On 11/2/12 1:22 PM, Walter Bright wrote:

On 11/2/2012 2:01 AM, Jens Mueller wrote:
> I had the same thought when reading this. Very disappointing. An  
issue

> with zero votes is fixed instead of more important ones.

It's a very fair question.

Manu works for Remedy Games, a developer of hit PC games, such as Max
Payne and Alan Wake. He champions a team that is investigating
committing to D for a major new game. This would be a huge design win
for D, and an enormous boost for D. I view the most effective use of my
time at the moment is to ensure that they can bet on D and win.  
Remedy's

use of D for a high profile product will prove that D is ready and able
for the big time, and that others can develop using D with confidence.

Nearly all of what he needs the D community needs anyway, such as the
big push for Win64 support and the SIMD support (more on that in  
another

post).


I should add that I'm also totally behind this. When Walter jumped into
implementing SIMD support on a hunch, I completely disagreed, but that
was a great decision.

Andrei


I still don't understand the benefice over align(16) float[4] .


http://forum.dlang.org/thread/jauixhakwvpgsghap...@forum.dlang.org?page=4#post-k711rd:242786:242:40digitalmars.com

R

--
Using Opera's revolutionary email client: http://www.opera.com/mail/


Re: A little Py Vs C++

2012-11-02 Thread Jacob Carlborg

On 2012-11-02 19:03, Dejan Lekic wrote:


How do you think people came up with those bug reports? By some magic?
:) You think they did not actually *pull their hair off* trying to
figure out why their REAL LIFE program does not work, and when we could
not find the reason we naturally started thinking "oh, it might be yet
another missing thing in D" or "oh, yet another DMD/phobos/druntime
bug!"...
Or, another scenario (a very typical one) - after DMD/phobos/druntime is
updated, my production application no longer compiles...


Good point. When you do put the whole real life program in the bug 
report "it's too big, you need to create a small test case". When you do 
create a small test case for the feature/bug it's suddenly not "real 
life" code.


--
/Jacob Carlborg


Re: A little Py Vs C++

2012-11-02 Thread Jacob Carlborg

On 2012-11-02 09:38, Don Clugston wrote:


Yes, and they could cure cancer. "AST macros" can do anything, because
they are completely undefined. Without even a vague proposal, it seems
like a rather meaningless term.


I know, I know. It's be brought up before and without any more detailed 
specification/definition is hard to do anything about it. I've done some 
research in the subject in the hope I can write down something useful 
that could be a proposal for D, but I don't have anything yet.


--
/Jacob Carlborg


Re: A little Py Vs C++

2012-11-02 Thread Walter Bright

On 11/2/2012 10:32 AM, Andrej Mitrovic wrote:
> Manu if you know of any trivial-type bugs you'd like to get fixed (for
> example error messages) let me know so I can prioritize them. There's
> a ton of open issues and I usually select the ones for fixing by
> random. I've managed to fix a few so far. :)

Thanks, any help would be appreciated. I'll ask Manu for a list of his priority 
issues, and even minor ones.


What will also help is trying out the beta Win64 target. I've been posting 
nightly new betas for it.





Re: A little Py Vs C++

2012-11-02 Thread Walter Bright

On 11/2/2012 3:50 AM, Jens Mueller wrote:
> Okay. For me they look the same. Can you elaborate, please? Assume I
> want to add two float vectors which is common in both games and
> scientific computing. The only difference is in games their length is
> usually 3 or 4 whereas in scientific computing they are of arbitrary
> length. Why do I need instrinsics to support the game setting?

Another excellent question.

Most languages have taken the "auto-vectorization" approach of reverse 
engineering loops to turn them into high level constructs, and then compiling 
the code into special SIMD instructions.


How to do this is explained in detail in the (rare) book "The Software 
Vectorization Handbook" by Bik, which I fortunately was able to obtain a copy of.


This struck me as a terrible approach, however. It just seemed stupid to try to 
teach the compiler to reverse engineer low level code into high level code. A 
better design would be to start with high level code. Hence, the appearance of D 
vector operations.


The trouble with D vector operations, however, is that they are too general 
purpose. The SIMD instructions are very quirky, and it's easy to unwittingly and 
silently cause the compiler to generate absolutely terribly slow code. The 
reasons for that are the alignment requirements, coupled with the SIMD 
instructions not being orthogonal - some operations work for some types and not 
for others, in a way that is unintuitive unless you're carefully reading the 
SIMD specs.


Just saying align(16) isn't good enough, as the vector ops work on slices and 
those slices aren't always aligned. So each one has to check alignment at 
runtime, which is murder on performance.


If a particular vector op for a particular type has no SIMD support, then the 
compiler has to generate workaround code. This can also have terrible 
performance consequences.


So the user writes vector code, benchmarks it, finds zero improvement, and the 
reasons why will be elusive to anyone but an expert SIMD programmer.


(Auto-vectorizing technology has similar issues, pretty much meaning you won't 
get fast code out of it unless you've got a habit of examining the assembler 
output and tweaking as necessary.)


Enter Manu, who has a lot of experience making SIMD work for games. His proposal 
was:


1. Have native SIMD types. This will guarantee alignment, and will guarantee a 
compile time error for SIMD types that are not supported by the CPU.


2. Have the compiler issue an error for SIMD operations that are not supported 
by the CPU, rather than silently generating inefficient workaround code.


3. There are all kinds of weird but highly useful SIMD instructions that don't 
have a straightforward representation in high level code, such as saturated 
arithmetic. Manu's answer was to expose these instructions via intrinsics, so 
the user can string them together, be sure that they will generate real SIMD 
instructions, while the compiler can deal with register allocation.


This approach works, is inlineable, generates code as good as hand-built 
assembler, and is useable by regular programmers.


I won't say there aren't better approaches, but this one we know works.



Re: A little Py Vs C++

2012-11-02 Thread Dejan Lekic

On Friday, 2 November 2012 at 08:38:21 UTC, Don Clugston wrote:

On 02/11/12 09:07, Jacob Carlborg wrote:

On 2012-11-01 23:51, Walter Bright wrote:

What about all your feature requests? I think you've made 
more than

anyone, by a factor of 10 at least!

:-)

As for Manu's request

http://d.puremagic.com/issues/show_bug.cgi?id=8108

I've gone over with him why he needs it, and there's no other 
reasonable

way. He needs it for real code in a real application.


This is quite interesting. Manu comes in from basically 
nowhere and
fairly quickly manage to convince Walter to implement at least 
two
feature requests, this one and the SIMD support. I'm not 
saying that

they shouldn't have been implemented.


He just knows how to convince Walter.
(Hint: use real-world use cases. Arguments from theoretical 
computer science carry almost no weight with Walter).


> Although I think something like
AST macros could possible solve issue 8108 and a whole bunch 
of other

features, a few already present in the language.


Yes, and they could cure cancer. "AST macros" can do anything, 
because they are completely undefined. Without even a vague 
proposal, it seems like a rather meaningless term.


How do you think people came up with those bug reports? By some 
magic? :) You think they did not actually *pull their hair off* 
trying to figure out why their REAL LIFE program does not work, 
and when we could not find the reason we naturally started 
thinking "oh, it might be yet another missing thing in D" or "oh, 
yet another DMD/phobos/druntime bug!"...
Or, another scenario (a very typical one) - after 
DMD/phobos/druntime is updated, my production application no 
longer compiles...


Re: A little Py Vs C++

2012-11-02 Thread Dejan Lekic
On Thursday, 1 November 2012 at 18:06:21 UTC, Peter Alexander 
wrote:

On Wednesday, 31 October 2012 at 23:04:15 UTC, bearophile wrote:


The thread contains some sad comments:


It's unfortunate that there's still bad press circulating about 
a situation that is long gone. I suppose you just have to try 
and ignore those people.


A more interesting comment is this one:

"But the real problem here is that in order to achieve even 
that, the complexity and amount of concepts you have to deal 
with in C++11 is mind boggling."


The same is true in D. Well-written D code often does look 
rather elegant, but the amount of understanding needed to write 
beautiful D code is staggering.


I think that is the case of any multi-paradigm language. It is 
already enough to allow both functional and OO style of 
programming to have hundreds of things to think about... That is 
exactly one of the major reasons why people prefer Java over 
other languages...


Re: A little Py Vs C++

2012-11-02 Thread Andrei Alexandrescu

On 11/2/12 1:22 PM, Walter Bright wrote:

On 11/2/2012 2:01 AM, Jens Mueller wrote:
 > I had the same thought when reading this. Very disappointing. An issue
 > with zero votes is fixed instead of more important ones.

It's a very fair question.

Manu works for Remedy Games, a developer of hit PC games, such as Max
Payne and Alan Wake. He champions a team that is investigating
committing to D for a major new game. This would be a huge design win
for D, and an enormous boost for D. I view the most effective use of my
time at the moment is to ensure that they can bet on D and win. Remedy's
use of D for a high profile product will prove that D is ready and able
for the big time, and that others can develop using D with confidence.

Nearly all of what he needs the D community needs anyway, such as the
big push for Win64 support and the SIMD support (more on that in another
post).


I should add that I'm also totally behind this. When Walter jumped into 
implementing SIMD support on a hunch, I completely disagreed, but that 
was a great decision.


Andrei


Re: A little Py Vs C++

2012-11-02 Thread Andrej Mitrovic
On 11/2/12, Walter Bright  wrote:
> Manu works for Remedy Games, a developer of hit PC games, such as Max Payne
> and
> Alan Wake. He champions a team that is investigating committing to D for a
> major
> new game.

Wow that's really cool!

Manu if you know of any trivial-type bugs you'd like to get fixed (for
example error messages) let me know so I can prioritize them. There's
a ton of open issues and I usually select the ones for fixing by
random. I've managed to fix a few so far. :)


Re: A little Py Vs C++

2012-11-02 Thread Walter Bright

On 11/2/2012 10:22 AM, Walter Bright wrote:

such as the big push for Win64 support


I want to give a shoutout here for Rainer Schuetze who has been a big help 
behind the scenes in getting the Win64 symbolic debug support working. He's 
saved me a ton of time.


Re: A little Py Vs C++

2012-11-02 Thread Walter Bright

On 11/2/2012 2:01 AM, Jens Mueller wrote:
> I had the same thought when reading this. Very disappointing. An issue
> with zero votes is fixed instead of more important ones.

It's a very fair question.

Manu works for Remedy Games, a developer of hit PC games, such as Max Payne and 
Alan Wake. He champions a team that is investigating committing to D for a major 
new game. This would be a huge design win for D, and an enormous boost for D. I 
view the most effective use of my time at the moment is to ensure that they can 
bet on D and win. Remedy's use of D for a high profile product will prove that D 
is ready and able for the big time, and that others can develop using D with 
confidence.


Nearly all of what he needs the D community needs anyway, such as the big push 
for Win64 support and the SIMD support (more on that in another post).


Re: A little Py Vs C++

2012-11-02 Thread Timon Gehr

On 11/02/2012 09:07 AM, Jacob Carlborg wrote:

On 2012-11-01 23:51, Walter Bright wrote:


What about all your feature requests? I think you've made more than
anyone, by a factor of 10 at least!

:-)

As for Manu's request

http://d.puremagic.com/issues/show_bug.cgi?id=8108

I've gone over with him why he needs it, and there's no other reasonable
way. He needs it for real code in a real application.


This is quite interesting. Manu comes in from basically nowhere and
fairly quickly manage to convince Walter to implement at least two
feature requests, this one and the SIMD support. I'm not saying that
they shouldn't have been implemented.



SIMD support is necessary and the fix for 8108 is very simple. If the 
way default arguments work shall be improved though, it would add 
additional ways that the compiler can screw up conditional compilation.



Although I think something like
AST macros could possible solve issue 8108 and a whole bunch of other
features, a few already present in the language.



A sufficiently well/badly designed macro feature can potentially replace 
most other language features.


Re: A little Py Vs C++

2012-11-02 Thread Jens Mueller
Don Clugston wrote:
> On 02/11/12 11:57, Jens Mueller wrote:
> >Peter Alexander wrote:
> >>On Friday, 2 November 2012 at 10:24:34 UTC, Jens Mueller wrote:
> >>>Then I have a serious misunderstanding.
> >>>I thought D introduced array operations to allow the compiler to
> >>>generate efficient vector operations (in the long run), i.e.
> >>>generate
> >>>SIMD code. Why is this not working out?
> >>
> >>It works fine for large vectors. For small vectors, it is
> >>horrendously slow.
> >>
> >>The syntax a[] += b[] essentially calls a function which is designed
> >>to work for large vectors. It has to determine alignment, load
> >>everything from memory, do the operations, then store it back.
> >>
> >>The SIMD extensions allow you to define variables that are
> >>guaranteed to be aligned and will probably be in the right registers
> >>to start with. Using them, the vectors ops don't need to determine
> >>alignment, and often don't need to do lots of loads/stores.
> >>
> >>Both have their purposes.
> >
> >I see. But can't the alignment problem be solved by using align. Then
> >have the compiler emits a call that checks for alignment if none was
> >specified else use a faster version.
> 
> No. For SIMD, you cannot afford to have even a single machine
> instruction inserted, or the benefit is entirely lost.

But the compiler knows about the alignment, doesn't it?

align(16) float[4] a;
vs
float[4] a;

In the former case the compiler can generate better code and it should.
The above syntax is not supported. But my point is all the compiler
cares about is the alignment which can be specified in the code somehow.
Sorry for being stubborn.

Jens


Re: A little Py Vs C++

2012-11-02 Thread Don Clugston

On 02/11/12 11:57, Jens Mueller wrote:

Peter Alexander wrote:

On Friday, 2 November 2012 at 10:24:34 UTC, Jens Mueller wrote:

Then I have a serious misunderstanding.
I thought D introduced array operations to allow the compiler to
generate efficient vector operations (in the long run), i.e.
generate
SIMD code. Why is this not working out?


It works fine for large vectors. For small vectors, it is
horrendously slow.

The syntax a[] += b[] essentially calls a function which is designed
to work for large vectors. It has to determine alignment, load
everything from memory, do the operations, then store it back.

The SIMD extensions allow you to define variables that are
guaranteed to be aligned and will probably be in the right registers
to start with. Using them, the vectors ops don't need to determine
alignment, and often don't need to do lots of loads/stores.

Both have their purposes.


I see. But can't the alignment problem be solved by using align. Then
have the compiler emits a call that checks for alignment if none was
specified else use a faster version.


No. For SIMD, you cannot afford to have even a single machine 
instruction inserted, or the benefit is entirely lost.





Re: A little Py Vs C++

2012-11-02 Thread Andrei Alexandrescu

On 11/1/12 6:51 PM, Walter Bright wrote:

On 11/1/2012 2:20 PM, bearophile wrote:

Some complexity comes from the
desire to do more and more. As example see this recent request from Manu,


What about all your feature requests? I think you've made more than
anyone, by a factor of 10 at least!

:-)

As for Manu's request

http://d.puremagic.com/issues/show_bug.cgi?id=8108

I've gone over with him why he needs it, and there's no other reasonable
way. He needs it for real code in a real application.


I'd argue this actually is part of a category of features that does not 
increase the complexity of the language (quite the contrary in fact). 
This is because stating that declaration+definition in the same file 
won't work takes actually more cognitive load than just allowing it.


By the consistency principle, one should infer unknown parts of a 
complex system from knowing the others. Consider then this setup:


* Declarations (without definition) of functions are allowed.

* Definitions are allowed.

* Declarations and definitions are allowed in distinct files in the same 
project as long as they match.


At this point, it is more tenuous to argue that "same file" is a special 
case that should prevent declarations and definitions to coexist, than 
to just let it happen and let the consistency principle take care of 
explaining it.



Andrei


Re: A little Py Vs C++

2012-11-02 Thread Paulo Pinto

On Friday, 2 November 2012 at 10:50:56 UTC, Jens Mueller wrote:

Don Clugston wrote:

On 02/11/12 10:01, Jens Mueller wrote:
>Jacob Carlborg wrote:
>>On 2012-11-01 23:51, Walter Bright wrote:
>>
>>>What about all your feature requests? I think you've made 
>>>more than

>>>anyone, by a factor of 10 at least!
>>>
>>>:-)
>>>
>>>As for Manu's request
>>>
>>>http://d.puremagic.com/issues/show_bug.cgi?id=8108
>>>
>>>I've gone over with him why he needs it, and there's no 
>>>other reasonable

>>>way. He needs it for real code in a real application.
>>
>>This is quite interesting. Manu comes in from basically 
>>nowhere and
>>fairly quickly manage to convince Walter to implement at 
>>least two
>>feature requests, this one and the SIMD support. I'm not 
>>saying that
>>they shouldn't have been implemented. Although I think 
>>something
>>like AST macros could possible solve issue 8108 and a whole 
>>bunch of

>>other features, a few already present in the language.
>
>I had the same thought when reading this. Very disappointing. 
>An issue
>with zero votes is fixed instead of more important ones. Why 
>do I vote

>anyway?
>Regarding SIMD I have the feeling that because it is built 
>into the
>compiler static vectors have actually failed what they 
>promised. I
>thought D proposed a portable way of vector operations such 
>that you

>write
>float[4] = a[] + b[]
>and the compiler generates SIMD code for you.

Not for short vectors. They are more like the builtin 
operations in
Fortran, ie designed for large vectors. More for scientific 
kinds of
applications than games. (The two applications look 
superficially

similar, but in practice they have little in common).


Okay. For me they look the same. Can you elaborate, please? 
Assume I

want to add two float vectors which is common in both games and
scientific computing. The only difference is in games their 
length is
usually 3 or 4 whereas in scientific computing they are of 
arbitrary

length. Why do I need instrinsics to support the game setting?

Jens


The auto vectorization code in Visual Studio 2012 seems to work 
pretty well.





Re: A little Py Vs C++

2012-11-02 Thread Jens Mueller
Peter Alexander wrote:
> On Friday, 2 November 2012 at 10:24:34 UTC, Jens Mueller wrote:
> >Then I have a serious misunderstanding.
> >I thought D introduced array operations to allow the compiler to
> >generate efficient vector operations (in the long run), i.e.
> >generate
> >SIMD code. Why is this not working out?
> 
> It works fine for large vectors. For small vectors, it is
> horrendously slow.
> 
> The syntax a[] += b[] essentially calls a function which is designed
> to work for large vectors. It has to determine alignment, load
> everything from memory, do the operations, then store it back.
> 
> The SIMD extensions allow you to define variables that are
> guaranteed to be aligned and will probably be in the right registers
> to start with. Using them, the vectors ops don't need to determine
> alignment, and often don't need to do lots of loads/stores.
> 
> Both have their purposes.

I see. But can't the alignment problem be solved by using align. Then
have the compiler emits a call that checks for alignment if none was
specified else use a faster version.

Jens


Re: A little Py Vs C++

2012-11-02 Thread Jens Mueller
Don Clugston wrote:
> On 02/11/12 10:01, Jens Mueller wrote:
> >Jacob Carlborg wrote:
> >>On 2012-11-01 23:51, Walter Bright wrote:
> >>
> >>>What about all your feature requests? I think you've made more than
> >>>anyone, by a factor of 10 at least!
> >>>
> >>>:-)
> >>>
> >>>As for Manu's request
> >>>
> >>>http://d.puremagic.com/issues/show_bug.cgi?id=8108
> >>>
> >>>I've gone over with him why he needs it, and there's no other reasonable
> >>>way. He needs it for real code in a real application.
> >>
> >>This is quite interesting. Manu comes in from basically nowhere and
> >>fairly quickly manage to convince Walter to implement at least two
> >>feature requests, this one and the SIMD support. I'm not saying that
> >>they shouldn't have been implemented. Although I think something
> >>like AST macros could possible solve issue 8108 and a whole bunch of
> >>other features, a few already present in the language.
> >
> >I had the same thought when reading this. Very disappointing. An issue
> >with zero votes is fixed instead of more important ones. Why do I vote
> >anyway?
> >Regarding SIMD I have the feeling that because it is built into the
> >compiler static vectors have actually failed what they promised. I
> >thought D proposed a portable way of vector operations such that you
> >write
> >float[4] = a[] + b[]
> >and the compiler generates SIMD code for you.
> 
> Not for short vectors. They are more like the builtin operations in
> Fortran, ie designed for large vectors. More for scientific kinds of
> applications than games. (The two applications look superficially
> similar, but in practice they have little in common).

Okay. For me they look the same. Can you elaborate, please? Assume I
want to add two float vectors which is common in both games and
scientific computing. The only difference is in games their length is
usually 3 or 4 whereas in scientific computing they are of arbitrary
length. Why do I need instrinsics to support the game setting?

Jens


Re: A little Py Vs C++

2012-11-02 Thread Peter Alexander

On Friday, 2 November 2012 at 10:24:34 UTC, Jens Mueller wrote:

Then I have a serious misunderstanding.
I thought D introduced array operations to allow the compiler to
generate efficient vector operations (in the long run), i.e. 
generate

SIMD code. Why is this not working out?


It works fine for large vectors. For small vectors, it is 
horrendously slow.


The syntax a[] += b[] essentially calls a function which is 
designed to work for large vectors. It has to determine 
alignment, load everything from memory, do the operations, then 
store it back.


The SIMD extensions allow you to define variables that are 
guaranteed to be aligned and will probably be in the right 
registers to start with. Using them, the vectors ops don't need 
to determine alignment, and often don't need to do lots of 
loads/stores.


Both have their purposes.


Re: A little Py Vs C++

2012-11-02 Thread Jens Mueller
Don Clugston wrote:
> On 02/11/12 10:12, Jens Mueller wrote:
> >Don Clugston wrote:
> >>On 02/11/12 09:07, Jacob Carlborg wrote:
> >>>On 2012-11-01 23:51, Walter Bright wrote:
> >>>
> What about all your feature requests? I think you've made more than
> anyone, by a factor of 10 at least!
> 
> :-)
> 
> As for Manu's request
> 
> http://d.puremagic.com/issues/show_bug.cgi?id=8108
> 
> I've gone over with him why he needs it, and there's no other reasonable
> way. He needs it for real code in a real application.
> >>>
> >>>This is quite interesting. Manu comes in from basically nowhere and
> >>>fairly quickly manage to convince Walter to implement at least two
> >>>feature requests, this one and the SIMD support. I'm not saying that
> >>>they shouldn't have been implemented.
> >>
> >>He just knows how to convince Walter.
> >>(Hint: use real-world use cases. Arguments from theoretical computer
> >>science carry almost no weight with Walter).
> >
> >I think there are lots of issues in the bug tracker which describe real
> >use cases. The point is that these are more like bugs whereas Manu's
> >proposals are more like feature requests.
> >
> >Jens
> 
> The SIMD stuff has no workarounds. I don't know of many other
> feature requests in that category.

Then I have a serious misunderstanding.
I thought D introduced array operations to allow the compiler to
generate efficient vector operations (in the long run), i.e. generate
SIMD code. Why is this not working out?

Jens


Re: A little Py Vs C++

2012-11-02 Thread Don Clugston

On 02/11/12 10:01, Jens Mueller wrote:

Jacob Carlborg wrote:

On 2012-11-01 23:51, Walter Bright wrote:


What about all your feature requests? I think you've made more than
anyone, by a factor of 10 at least!

:-)

As for Manu's request

http://d.puremagic.com/issues/show_bug.cgi?id=8108

I've gone over with him why he needs it, and there's no other reasonable
way. He needs it for real code in a real application.


This is quite interesting. Manu comes in from basically nowhere and
fairly quickly manage to convince Walter to implement at least two
feature requests, this one and the SIMD support. I'm not saying that
they shouldn't have been implemented. Although I think something
like AST macros could possible solve issue 8108 and a whole bunch of
other features, a few already present in the language.


I had the same thought when reading this. Very disappointing. An issue
with zero votes is fixed instead of more important ones. Why do I vote
anyway?
Regarding SIMD I have the feeling that because it is built into the
compiler static vectors have actually failed what they promised. I
thought D proposed a portable way of vector operations such that you
write
float[4] = a[] + b[]
and the compiler generates SIMD code for you.


Not for short vectors. They are more like the builtin operations in 
Fortran, ie designed for large vectors. More for scientific kinds of 
applications than games. (The two applications look superficially 
similar, but in practice they have little in common).


Re: A little Py Vs C++

2012-11-02 Thread Don Clugston

On 02/11/12 10:12, Jens Mueller wrote:

Don Clugston wrote:

On 02/11/12 09:07, Jacob Carlborg wrote:

On 2012-11-01 23:51, Walter Bright wrote:


What about all your feature requests? I think you've made more than
anyone, by a factor of 10 at least!

:-)

As for Manu's request

http://d.puremagic.com/issues/show_bug.cgi?id=8108

I've gone over with him why he needs it, and there's no other reasonable
way. He needs it for real code in a real application.


This is quite interesting. Manu comes in from basically nowhere and
fairly quickly manage to convince Walter to implement at least two
feature requests, this one and the SIMD support. I'm not saying that
they shouldn't have been implemented.


He just knows how to convince Walter.
(Hint: use real-world use cases. Arguments from theoretical computer
science carry almost no weight with Walter).


I think there are lots of issues in the bug tracker which describe real
use cases. The point is that these are more like bugs whereas Manu's
proposals are more like feature requests.

Jens


The SIMD stuff has no workarounds. I don't know of many other feature 
requests in that category.





Re: A little Py Vs C++

2012-11-02 Thread Jens Mueller
Don Clugston wrote:
> On 02/11/12 09:07, Jacob Carlborg wrote:
> >On 2012-11-01 23:51, Walter Bright wrote:
> >
> >>What about all your feature requests? I think you've made more than
> >>anyone, by a factor of 10 at least!
> >>
> >>:-)
> >>
> >>As for Manu's request
> >>
> >>http://d.puremagic.com/issues/show_bug.cgi?id=8108
> >>
> >>I've gone over with him why he needs it, and there's no other reasonable
> >>way. He needs it for real code in a real application.
> >
> >This is quite interesting. Manu comes in from basically nowhere and
> >fairly quickly manage to convince Walter to implement at least two
> >feature requests, this one and the SIMD support. I'm not saying that
> >they shouldn't have been implemented.
> 
> He just knows how to convince Walter.
> (Hint: use real-world use cases. Arguments from theoretical computer
> science carry almost no weight with Walter).

I think there are lots of issues in the bug tracker which describe real
use cases. The point is that these are more like bugs whereas Manu's
proposals are more like feature requests.

Jens


Re: A little Py Vs C++

2012-11-02 Thread Jens Mueller
Jacob Carlborg wrote:
> On 2012-11-01 23:51, Walter Bright wrote:
> 
> >What about all your feature requests? I think you've made more than
> >anyone, by a factor of 10 at least!
> >
> >:-)
> >
> >As for Manu's request
> >
> >http://d.puremagic.com/issues/show_bug.cgi?id=8108
> >
> >I've gone over with him why he needs it, and there's no other reasonable
> >way. He needs it for real code in a real application.
> 
> This is quite interesting. Manu comes in from basically nowhere and
> fairly quickly manage to convince Walter to implement at least two
> feature requests, this one and the SIMD support. I'm not saying that
> they shouldn't have been implemented. Although I think something
> like AST macros could possible solve issue 8108 and a whole bunch of
> other features, a few already present in the language.

I had the same thought when reading this. Very disappointing. An issue
with zero votes is fixed instead of more important ones. Why do I vote
anyway?
Regarding SIMD I have the feeling that because it is built into the
compiler static vectors have actually failed what they promised. I
thought D proposed a portable way of vector operations such that you
write
float[4] = a[] + b[]
and the compiler generates SIMD code for you.

Jens


Re: A little Py Vs C++

2012-11-02 Thread Don Clugston

On 02/11/12 09:07, Jacob Carlborg wrote:

On 2012-11-01 23:51, Walter Bright wrote:


What about all your feature requests? I think you've made more than
anyone, by a factor of 10 at least!

:-)

As for Manu's request

http://d.puremagic.com/issues/show_bug.cgi?id=8108

I've gone over with him why he needs it, and there's no other reasonable
way. He needs it for real code in a real application.


This is quite interesting. Manu comes in from basically nowhere and
fairly quickly manage to convince Walter to implement at least two
feature requests, this one and the SIMD support. I'm not saying that
they shouldn't have been implemented.


He just knows how to convince Walter.
(Hint: use real-world use cases. Arguments from theoretical computer 
science carry almost no weight with Walter).


> Although I think something like

AST macros could possible solve issue 8108 and a whole bunch of other
features, a few already present in the language.


Yes, and they could cure cancer. "AST macros" can do anything, because 
they are completely undefined. Without even a vague proposal, it seems 
like a rather meaningless term.




Re: A little Py Vs C++

2012-11-02 Thread Jacob Carlborg

On 2012-11-01 23:51, Walter Bright wrote:


What about all your feature requests? I think you've made more than
anyone, by a factor of 10 at least!

:-)

As for Manu's request

http://d.puremagic.com/issues/show_bug.cgi?id=8108

I've gone over with him why he needs it, and there's no other reasonable
way. He needs it for real code in a real application.


This is quite interesting. Manu comes in from basically nowhere and 
fairly quickly manage to convince Walter to implement at least two 
feature requests, this one and the SIMD support. I'm not saying that 
they shouldn't have been implemented. Although I think something like 
AST macros could possible solve issue 8108 and a whole bunch of other 
features, a few already present in the language.


--
/Jacob Carlborg


Re: A little Py Vs C++

2012-11-01 Thread Jesse Phillips

On Thursday, 1 November 2012 at 23:56:00 UTC, Rob T wrote:

On Thursday, 1 November 2012 at 20:10:47 UTC, H. S. Teoh wrote:
But yeah, the current documentation needs work. Unfortunately, 
wishing
for it to happen won't make it happen, so if you contribute 
(use the

"improve this page" link) that would be great


I never noticed that link before. When I click on it, I go to 
github showing me a webpage with "404" on it. The text over 
link says I need a github account and to submit pull requests. 
I'm not sure how I'm supposed to make changes with that.


I know about the regular Wiki and have made a contribution 
there, that's very simple to do.


--rt


All the documentation is written in DDoc. The website is hosted 
on github. Github provides an online text editor usable against 
your repository. Your repository is created as a fork of the 
original. Github uses pull requests to move changes upstream.


It isn't as simple as a wiki but it isn't too bad. Hope that is 
enough information to get started.


Re: A little Py Vs C++

2012-11-01 Thread Rob T

On Thursday, 1 November 2012 at 20:10:47 UTC, H. S. Teoh wrote:
But yeah, the current documentation needs work. Unfortunately, 
wishing
for it to happen won't make it happen, so if you contribute 
(use the

"improve this page" link) that would be great


I never noticed that link before. When I click on it, I go to 
github showing me a webpage with "404" on it. The text over link 
says I need a github account and to submit pull requests. I'm not 
sure how I'm supposed to make changes with that.


I know about the regular Wiki and have made a contribution there, 
that's very simple to do.


--rt




Re: A little Py Vs C++

2012-11-01 Thread Walter Bright

On 11/1/2012 2:20 PM, bearophile wrote:

Some complexity comes from the
desire to do more and more. As example see this recent request from Manu,


What about all your feature requests? I think you've made more than anyone, by a 
factor of 10 at least!


:-)

As for Manu's request

http://d.puremagic.com/issues/show_bug.cgi?id=8108

I've gone over with him why he needs it, and there's no other reasonable way. He 
needs it for real code in a real application.




Re: A little Py Vs C++

2012-11-01 Thread Tavi Cacina

On Thursday, 1 November 2012 at 19:49:42 UTC, Rob T wrote:
On Thursday, 1 November 2012 at 18:06:21 UTC, Peter Alexander 
wrote:




The number one missing item that I would love to get my hands 
on is comprehensive documentaion. What we have now leaves out 
far too much detail, and may be missing entire features, and 
what is available is scattered all over the place.




Workaround: I find it useful to check the code of a 'std' module 
that interests me. A lot of unittests and comments are quite 
usefull. For ex. about the RAII/ref-counted stuff I checked the 
stdio.d File.




Re: A little Py Vs C++

2012-11-01 Thread Paulo Pinto

On Thursday, 1 November 2012 at 19:44:04 UTC, H. S. Teoh wrote:

On Thu, Nov 01, 2012 at 08:19:56PM +0100, Paulo Pinto wrote:
On Thursday, 1 November 2012 at 18:06:21 UTC, Peter Alexander 
wrote:

[...]

>A more interesting comment is this one:
>
>"But the real problem here is that in order to achieve even 
>that,

>the complexity and amount of concepts you have to deal with in
>C++11 is mind boggling."
>
>The same is true in D. Well-written D code often does look 
>rather
>elegant, but the amount of understanding needed to write 
>beautiful

>D code is staggering.

I have to agree having to deal with lots of concepts.


I don't see it as a problem, unless one is a programmer of the 
drone
persuasion. Many of D's concepts are liberatingly powerful, and 
very

potent in combination.



On the other hand, except for the programming drones, most D
concepts are also available in most mainstream languages.

[...]

If we want to minimize the number of concepts, we should 
program using
Lambda calculus. ;-) We already have lambda-syntax for 
delegates, after
all. Now just restrict all statements to only lambda 
expressions, get
rid of difficult concepts like arithmetic operators, variables 
and

imperative programming, and we have a winner on our hands.

Seriously, though, imagining that one can program effectively 
without
learning new concepts is a preposterous proposition to me. I 
just don't

understand the unwillingness to learn.


T


It is not the unwillingness to learn, rather the standard HR way 
of getting replaceable programming drones in most enterprises.


This was already discussed a few times.

--
Paulo




Re: A little Py Vs C++

2012-11-01 Thread H. S. Teoh
On Thu, Nov 01, 2012 at 08:49:40PM +0100, Rob T wrote:
> On Thursday, 1 November 2012 at 18:06:21 UTC, Peter Alexander wrote:
> >
> >The same is true in D. Well-written D code often does look rather
> >elegant, but the amount of understanding needed to write beautiful
> >D code is staggering.
> 
> I'll second that!
> 
> I'm finally making good progress with D after a whole lot of effort,
> and there were (and still are) periods where I felt like giving up,
> although not so much anymore.
> 
> The number one missing item that I would love to get my hands on is
> comprehensive documentaion. What we have now leaves out far too much
> detail, and may be missing entire features, and what is available is
> scattered all over the place.
> 
> Reading the TDPL book is a huge help for understanding D, it's
> essential reading for sure, but it's only an overview rather than a
> full text on the subject. The TDPL lacks many of the fine details
> that one needs to know in order to write proper D code. I find
> myself experimenting a lot in order to figure out what the various
> obscure details are, but without comprehensive documentation, I
> cannot be certain if the observed behaviours are actually correct or
> fully complete under all situations.

Ali's D book might be helpful: http://ddili.org/ders/d.en/index.html

But yeah, the current documentation needs work. Unfortunately, wishing
for it to happen won't make it happen, so if you contribute (use the
"improve this page" link) that would be great, and suggestions are also
helpful. I recently revised the docs for std.range to explain briefly
what ranges are and why we even need them, but this is only one piece of
the entire standard library. Many other modules need improved docs. And
there is still the need for a general overview to put everything in
perspective.


T

-- 
It is impossible to make anything foolproof because fools are so ingenious. -- 
Sammy


Re: A little Py Vs C++

2012-11-01 Thread Rob T
On Thursday, 1 November 2012 at 18:06:21 UTC, Peter Alexander 
wrote:


The same is true in D. Well-written D code often does look 
rather elegant, but the amount of understanding needed to write 
beautiful D code is staggering.


I'll second that!

I'm finally making good progress with D after a whole lot of 
effort, and there were (and still are) periods where I felt like 
giving up, although not so much anymore.


The number one missing item that I would love to get my hands on 
is comprehensive documentaion. What we have now leaves out far 
too much detail, and may be missing entire features, and what is 
available is scattered all over the place.


Reading the TDPL book is a huge help for understanding D, it's 
essential reading for sure, but it's only an overview rather than 
a full text on the subject. The TDPL lacks many of the fine 
details that one needs to know in order to write proper D code. I 
find myself experimenting a lot in order to figure out what the 
various obscure details are, but without comprehensive 
documentation, I cannot be certain if the observed behaviours are 
actually correct or fully complete under all situations.


--rt



Re: A little Py Vs C++

2012-11-01 Thread H. S. Teoh
On Thu, Nov 01, 2012 at 08:19:56PM +0100, Paulo Pinto wrote:
> On Thursday, 1 November 2012 at 18:06:21 UTC, Peter Alexander wrote:
[...]
> >A more interesting comment is this one:
> >
> >"But the real problem here is that in order to achieve even that,
> >the complexity and amount of concepts you have to deal with in
> >C++11 is mind boggling."
> >
> >The same is true in D. Well-written D code often does look rather
> >elegant, but the amount of understanding needed to write beautiful
> >D code is staggering.
> 
> I have to agree having to deal with lots of concepts.

I don't see it as a problem, unless one is a programmer of the drone
persuasion. Many of D's concepts are liberatingly powerful, and very
potent in combination.


> On the other hand, except for the programming drones, most D
> concepts are also available in most mainstream languages.
[...]

If we want to minimize the number of concepts, we should program using
Lambda calculus. ;-) We already have lambda-syntax for delegates, after
all. Now just restrict all statements to only lambda expressions, get
rid of difficult concepts like arithmetic operators, variables and
imperative programming, and we have a winner on our hands.

Seriously, though, imagining that one can program effectively without
learning new concepts is a preposterous proposition to me. I just don't
understand the unwillingness to learn.


T

-- 
Computers shouldn't beep through the keyhole.


Re: A little Py Vs C++

2012-11-01 Thread Walter Bright
On 11/1/2012 12:19 PM, Paulo Pinto wrote:> On the other hand, except for the 
programming drones, most D concepts are also

> available in most mainstream languages.

Most of them are also well established in one form or another, with proven 
value.



Re: A little Py Vs C++

2012-11-01 Thread Paulo Pinto
On Thursday, 1 November 2012 at 18:06:21 UTC, Peter Alexander 
wrote:

On Wednesday, 31 October 2012 at 23:04:15 UTC, bearophile wrote:


The thread contains some sad comments:


It's unfortunate that there's still bad press circulating about 
a situation that is long gone. I suppose you just have to try 
and ignore those people.


A more interesting comment is this one:

"But the real problem here is that in order to achieve even 
that, the complexity and amount of concepts you have to deal 
with in C++11 is mind boggling."


The same is true in D. Well-written D code often does look 
rather elegant, but the amount of understanding needed to write 
beautiful D code is staggering.


I have to agree having to deal with lots of concepts.

On the other hand, except for the programming drones, most D 
concepts are also available in most mainstream languages.


--
Paulo


Re: A little Py Vs C++

2012-11-01 Thread Peter Alexander

On Wednesday, 31 October 2012 at 23:04:15 UTC, bearophile wrote:


The thread contains some sad comments:


It's unfortunate that there's still bad press circulating about a 
situation that is long gone. I suppose you just have to try and 
ignore those people.


A more interesting comment is this one:

"But the real problem here is that in order to achieve even that, 
the complexity and amount of concepts you have to deal with in 
C++11 is mind boggling."


The same is true in D. Well-written D code often does look rather 
elegant, but the amount of understanding needed to write 
beautiful D code is staggering.


A little Py Vs C++

2012-10-31 Thread bearophile
Maybe this Reddit thread should be completed with a nice D 
version :-)


http://www.reddit.com/r/programming/comments/12ecq5/c11_and_boost_succinct_like_python/

The thread contains some sad comments:

http://www.reddit.com/r/programming/comments/12ecq5/c11_and_boost_succinct_like_python/c6uihbi

http://www.reddit.com/r/programming/comments/12ecq5/c11_and_boost_succinct_like_python/c6ugw8h

Bye,
bearophile