SIMD benchmark

Walter Bright newshound2 at digitalmars.com
Tue Jan 17 17:04:13 PST 2012


On 1/17/2012 4:19 PM, Peter Alexander wrote:
> So, my original point still stands, you can't vectorise this function:
>
> void foo(int[] a, int[] b, int[] c)
> {
> foreach (i; 0..256)
> a[i] = b[i] + c[i];
> }
>
> Those slices are allowed to overlap, so this cannot be automatically vectorised
> (without inlining to get better context about those arrays).
>
> Without inlining, you need something along the lines of __restrict or uniqueness
> typing.

No, you can rewrite it as:

    a[] = b[] + c[];

and you don't need __restrict or uniqueness. That's what the vector operations 
are for.


More information about the Digitalmars-d mailing list