Very simple SIMD programming

Manu turkeyman at gmail.com
Wed Oct 24 14:13:14 PDT 2012


On 24 October 2012 16:00, bearophile <bearophileHUGS at lycos.com> wrote:

> Manu:
>
>
>  D already has what's required to do some fairly nice (by comparison) simd
>> stuff with good supporting libraries.
>>
>
> After reading that paper I am not sure you are right. See how their
> language manages masks by itself. This is from page 3:
>
>
> // vector length of context = 1; current_mask = T
> int block[4] v = <0,3,4,1>;
> int block[4] w = 3; // <3,3,3,3> via broadcast
> bool block[4] m = v < w; // <T,F,F,T>
> ++v; // <1,4,5,2>
> if (m) {
>     // vector length of context = 4; current_mask = m
>     v += 2; // <3,4,5,4>
> } else {
>     // vector length of context = 4; current_mask = ~m
>     v += 3; // <3,7,8,4>
> }
> // vector length of context = 1; current_mask = T
>

I agree that if is kinda neat, but it's probably not out of the question
for future extension. All the other stuff here is possible.
That said, it's not necessarily optimal either, just conveniently written.
The compiler would have to do some serious magic to optimise that;
flattening both sides of the if into parallel expressions, and then
applying the mask to combine...
I'm personally not in favour of SIMD constructs that are anything less than
optimal (but I appreciate I'm probably in the minority here).


(The simple benchmarks of the paper show a 5-15% performance loss compared
> to handwritten SIMD code.)
>

Right, as I suspected.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20121025/20da405b/attachment.html>


More information about the Digitalmars-d mailing list