SIMD benchmark

Peter Alexander peter.alexander.au at gmail.com
Tue Jan 17 13:47:33 PST 2012


On 17/01/12 9:24 PM, Walter Bright wrote:
> On 1/17/2012 1:20 PM, Peter Alexander wrote:
>> As Manu said, you need something like __restrict (or a linear type
>> system) to
>> solve this problem.
>
> No, you don't. It can be done with a runtime check, like array bounds
> checking is done.

So you'd change it to this, even in release builds?

void foo(int[] a, int[] b, int[] c)
{
   if ( /* arrays overlap */ )
   {
     foreach(i; 0..256)
       a[i] = b[i] + c[i];
   }
   else
   {
     /* vectorized code */
   }
}


i.e. duplicate all loops that can be potentially vectorized depending on 
aliasing? Please bear in mind that this is a simple example.

Seems a bit inefficient (code size).


More information about the Digitalmars-d mailing list