SIMD/intrinsincs questions

Mike Farnsworth mike.farnsworth at gmail.com
Mon Nov 9 13:56:25 PST 2009


Walter Bright Wrote:

> Michael Farnsworth wrote:
> > The ldc guys tell me that they didn't 
> > include the llvm vector intrinsics already because they were going to 
> > need either a custom type in the frontend, or else the D2 
> > fixed-size-arrays-as-value-types functionality.  I might take a stab at 
> > some of that in ldc in the future to see if I can get it to work, but 
> > I'm not an expert in compilers by any stretch of the imagination.
> 
> I think there's a lot of potential in this. Most languages lack array 
> operations, forcing the compiler into the bizarre task of trying to 
> reconstruct high level operations from low level ones to then convert to 
> array ops.

Can you elaborate a bit on what you mean?  If I understand what you're getting at, it's as simple as recognizing array-wise operations (the a[] = b[] * c expressions in D), and decomposing them into SIMD underneath where possible?  It would also be cool if the compiler could catch cases where a struct was essentially a wrapper around one of those arrays, and similarly turn the ops into SIMD ops (so as to allow some operator overloads and extra method wrapping additional intrinsics, for example).

There are a lot of cases to recognize, but the compiler could start with the simple ones and then go from there with no need to change the language or declare custom types (minus some alignment to help it along, perhaps).  The nice thing about it is you automatically get a pretty big swath of auto-vectorization by the compiler in the most natural types and operations you'd expect it to show up.

Of course, SOA-style SIMD takes more intervention by the programmer, but there is probably no easy way around that, since it's based on a data-layout technique.

-Mike




More information about the Digitalmars-d mailing list