Vectorization examples

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Mon Apr 20 14:39:36 PDT 2015


On 4/20/2015 1:09 PM, bearophile wrote:
> Walter Bright:
>
>> Use arrays of double2, float4, int4, etc., declared in core.simd. Those will
>> be aligned appropriately.
>
> Is the GC able to give memory aligned to 32 bytes for new architectures with 512
> bits wide SIMD?

When the CPU requires 32 byte alignment, the compiler/GC will support it.

And even if it doesn't, it is trivial to manually align things.

>>> and a way to tell
>>> the type system that some array slices are fully distinct (the __restrict seen
>>> here, I think this information doesn't need to be part of a type).
>>
>> A runtime test is sufficient.
>
> One of the points of having a type system is to rule out certain classes of bugs
> caused by programmers. The compiler could use the type system to add those
> runtime tests where needed. And even better sometimes is to avoid the time used
> by run time tests, as shown in that video, using the static information inserted
> in the code (he shows assembly code that contains run time tests).

"this information doesn't need to be part of a type"

Besides, you can create a 'restrict' template that checks for overlap at 
runtime, checking that can be turned on and off at compile time (i.e. assert). 
The runtime check overhead should be insignificant if using large arrays.


> Another example of missing static information in D is shown near the end of the
> video, where he shows an annotation to compile functions for different CPUs,
> where the compiler updates function pointers inside the binary according to the
> CPU you are using, making the code safe and efficient.

Come on, bearophile. I've done that stuff in C based on the runtime CPU. No 
compiler support is needed.



More information about the Digitalmars-d mailing list