What is SIMD?SIMD is the ability of a CPU to apply an operand to vectors of values, instead of single values. For example, a CPU may be able to add two vectors v and w by adding their components, hence applying the single instruction addition to multiple data:
SIMD brings speed-ups to many kinds of number crunching (3D computations, image processing, singal processing, etc.).
v + w = 〈v1, …, vn〉+ 〈w1, …, wn〉 = 〈v1+w1, …, vn+wn〉
At the moment, the API provides two data types:
- float32x4 (C type: __m128): four 32 bit floating point numbers.
- uint32x4 (C type: __m128i): four 32 bit unsigned integers.
var a = SIMD.float32x4(1.0, 2.0, 3.0, 4.0); var b = SIMD.float32x4(5.0, 6.0, 7.0, 8.0); var c = SIMD.float32x4.add(a,b);A few examples of available operators:
|float32x4.abs(v)||absolute values of v|
|float32x4.neg(v)||negated values of v|
|float32x4.sqrt(v)||the square roots of the values of v|
|float32x4.add(v, w)||pairwise addition of v and w|
|float32x4.mul(v, w)||pairwise multiplication of v and w|
|float32x4.equal(v, w)||determines, per pair of values from v and w, whether they are equal and returns the resulting booleans as a uint32x4|
- Support for generic data parallelism that works across a wide variety of processor architectures.
What about the second use case? Here, ParallelJS  shines. It isn’t tied to specific vector sizes or vector element sizes. And it will probably eventually even be able to produce GPU code.
The SIMD API won’t be in ECMAScript 6, but will probably be included in either ECMAScript 7 or ECMAScript 8.