Also, using SIMD is way easier than using shaders. You just write something like this:
double average (Float32x4List list) {
var n = list.length;
var sum = new Float32x4.zero();
for (int i = 0; i < n; i++) {
sum += list[i];
}
var total = sum.x + sum.y + sum.z + sum.w;
return total / (n * 4);
}
Instead of:
double average (Float32List list) {
var n = list.length;
var sum = 0.0;
for (int i = 0; i < n; i++) {
sum += list[i];
}
return sum / n;
}
I am still looking for practical examples. Unless there is a usecase for averaging gazillion numbers on the client (I would like to know what the use case for that is)
OK- Look at people trying to make 3D games for the web. GPU performance is a concern, but if you can't even run the physics simulation or cull your object database fast enough to push triangles to the GPU, your performance will be hurt and the GPU will be idle. People want games based on WebGL to have comparable performance to native apps -- well, you're going to need to take all of the libraries that games use and convert them too. This is a good solution to allow such SIMD optimization that have been present in native libs for years to have a chance to surface in JS libraries.
There's a skeletal animation demo that was made to show off Dart SIMD support. The bottleneck was the animation, not the 3D rendering, and using SIMD allowed almost 4x the number of characters to be drawn.
https://www.youtube.com/watch?v=CKh7UOELpPo
He's also the guy wrote the proposal for ECMAScript:
https://github.com/johnmccutchan/ecmascript_simd
Also, using SIMD is way easier than using shaders. You just write something like this:
Instead of: