Very simple SIMD programming

Walter Bright newshound2 at digitalmars.com
Thu Oct 25 12:05:16 PDT 2012


On 10/25/2012 4:13 AM, bearophile wrote:
 > Manu:
 >
 >> I think this is far more convenient than any crazy 'if' syntax :) .. It's
 >> also perfectly optimal on all architectures I know aswell!
 >
 > You should show more respect for them and their work. Their ideas seem very far
 > from being crazy. They have also proved their type system to be sound. This kind
 > of work is lightyears ahead of the usual sloppy designs you see in D features,
 > where design holes are found only years later, when sometimes it's too much late
 > to fix them :-)
 >
 > That if syntax (that is integrated in a type system that manages the masks, plus
 > implicit polymorphism that allows the same function to be used both in a
 > vectorized or scalar context) works with larger amounts of code too, while you
 > are just doing a differential assignment.


The interesting thing about SIMD code is that if you just read the data sheets 
for SIMD instructions, and write some SIMD code based on them, you're going to 
get lousy results. I know this from experience (see the array op SIMD 
implementations in the D runtime library).

Making SIMD code that delivers performance turns out to be a highly quirky and 
subtle exercise, one that is resistant to formalization. Despite the 
availability of SIMD hardware, there is a terrible lack of quality information 
on how to do it right on the internet by people who know what they're talking about.

Manu is on the daily front lines of doing competitive, real world SIMD 
programming. He leads a team doing SIMD work. Hence, I am going to strongly 
weight his opinions on any high level SIMD design constructs.

Interestingly, both of us have rejected the "auto-vectorization" approach 
popular in C/C++ compilers, for very different reasons.



More information about the Digitalmars-d mailing list