I reviewed the current SIMD implementation (as given by vector.h and in
library.js). Unfortunately, the documentation on Javascript's
implementation of SIMD is somewhat sparse, so I am using the documentation
given in the polyfill implementation (
https://github.com/johnmccutchan/ecmascript_simd/blob/master/src/ecmascript_simd.js)
as a reference.
Some of the implementations in library.js do a lot of copying/casting, e.g.
emscripten_float32x4_and__inline: function(a, b) {
return
'SIMD.int32x4.bitsToFloat32x4(SIMD.int32x4.and(SIMD.float32x4.bitsToInt32x4('
+ a + '), SIMD.float32x4.bitsToInt32x4(' + b + ')))';
},
Given the fact that float32x4 and int32x4 objects are immutable, this has
noticable performance penalties. Also, looking at the polyfill
implementation of SIMD.float32x4.and(...), I don't think I understand the
rationale behind these copies:
*/***
* * @param {float32x4} a An instance of float32x4.*
* * @param {float32x4} b An instance of float32x4.*
* * @return {float32x4} New instance of float32x4 with values of a & b.*
* */*SIMD.float32x4.and *=* *function*(a, b) {
*var* aInt *=* SIMD.float32x4.bitsToInt32x4(a);
*var* bInt *=* SIMD.float32x4.bitsToInt32x4(b);
*return* SIMD.int32x4.bitsToFloat32x4(SIMD.int32x4.and(aInt, bInt));
}
In other cases, the emscripten function signature is different from the
Javascript SIMD implementation. Like in case of
emscripten_float32x4_lessThan__inline: function(a, b) {
return 'SIMD.int32x4.bitsToFloat32x4(SIMD.float32x4.lessThan(' + a + ',
' + b + '))';
},
which returns an float32x4 object, whereas the polyfill implementation
returns an int32x4:
*/***
* * @param {float32x4} t An instance of float32x4.*
* * @param {float32x4} other An instance of float32x4.*
* * @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on*
* * the result of t < other.*
* */*SIMD.float32x4.lessThan *=* *function*(t, other) {
*var* cx *=* t.x *<* other.x;
*var* cy *=* t.y *<* other.y;
*var* cz *=* t.z *<* other.z;
*var* cw *=* t.w *<* other.w;
*return* SIMD.int32x4.bool(cx, cy, cz, cw);
}
Can someone educate me why that is, please?
Soeren
--
You received this message because you are subscribed to the Google Groups
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.