SIMD benchmark

Manu turkeyman at gmail.com
Tue Jan 17 02:43:43 PST 2012


On 17 January 2012 11:48, Martin Nowak <dawg at dawgfoto.de> wrote:

> On Tue, 17 Jan 2012 09:20:43 +0100, Manu <turkeyman at gmail.com> wrote:
>
>  On 17 January 2012 05:55, bearophile <bearophileHUGS at lycos.com> wrote:
>>
>>  Walter:
>>>
>>> > But don't worry, I'm not planning on working on that at the moment :-)
>>>
>>> Until better optimizations are implemented, I see a "simple" optimization
>>> for vector ops. When the compiler knows an arrays are very small it
>>> unrolls
>>> the operation in-place:
>>>
>>> int n = 5;
>>> auto a = new int[n];
>>> auto b = new int[n];
>>> a[] += b[];
>>>
>>> ==>
>>>
>>> int n = 5;
>>> auto a = new int[n]; // a and b are dynamic arrays,
>>> auto b = new int[n]; // but their length is easy to find at compile-time
>>> a[0] += b[0];
>>> a[1] += b[1];
>>> a[2] += b[2];
>>> a[3] += b[4];
>>> a[5] += b[5];
>>>
>>>
>> If this doesn't already exist, I think it's quite important. I was
>> thinking
>> about needing to repeatedly specialise a template last night for a bunch
>> of
>> short lengths of arrays, for this exact reason.
>> Unrolling short loops must be one of the most trivial and worthwhile
>> optimisations...
>>
>
> If the compiler knows it's a compile time constant
> thus you could use a static foreach.
>

Great idea! :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120117/3363a677/attachment-0001.html>


More information about the Digitalmars-d mailing list