SSE, AVX, and beyond

bearophile bearophileHUGS at lycos.com
Sun Aug 9 08:43:03 PDT 2009


Eljay:
>Should larger sizes have reserved keywords?  Or are those larger sizes just too ludicrously large to worry about?<

Today a CPU can perform an operation like ucent & ucent using the single SSE2 instruction PAND (_mm_and_si128 on GCC).

A 128 bit unsigned number may look of little use if you see it as an integer value, but it can be very useful if you see it like an array of bits that can be modified with operations that work in parallel on many bits. Such very wide bitwise operations are useful in many situations, for example to compute possible moves in a program that plays chess, to find approximate genomic substrings using a fast finite state machine, to quickly perform set operations on bit vectors and bloom filters, etc.

Adding other type names for values longer than cent/ucent doesn't look useful. In my opinion it's much better if the D compiler is able to translate operations like:

float[4] v1, v2, v3;
uint[4] a1, a2, a3;
v3[] = v1[] + v2[];
a3[] = a1[] & a2[];

In single inlined SSE1/2/3+ instructions, and 

float[8] v1, v2, v3;
uint[8] a1, a2, a3;
v3[] = v1[] + v2[];
a3[] = a1[] & a2[];

In inlined pairs of istructions, and so on. LDC is supposed to be able to do this, but currently it's not able to (also today those v1, v2, etc on the stack have to be aligned to 16 bytes).

Bye,
bearophile



More information about the Digitalmars-d mailing list