Your feedback is important to keep improving our website and offer you a more reliable experience.

Bringing SIMD to JavaScript

BY 01 Staff (not verified) ON Mar 24, 2014

By Mohammad Reza Haghighat, Intel Senior Principal Engineer

Modern microprocessors utilize parallelism to deliver high performance within a constrained power budget.  Through Single Instruction, Multiple Data (SIMD) instructions, processors exploit the fine-grained parallelism in applications by simultaneously processing the same operation on multiple data items, delivering major performance improvements at high power efficiency. SIMD is particularly applicable to common computations in image/audio/video processing including computer vision and perceptual computing. Thanks to its superior power efficiency and excellent performance boost, SIMD plays an increasing role in modern systems. However, up until now, SIMD support was missing in JavaScript*, the language of the browser and the “assembly language of the web.”  Fortunately, this gap is closing now.

In an exciting collaboration with Mozilla and Google, Intel is bringing SIMD to JavaScript. This makes it possible to develop new classes of compute-intensive applications such as games and media processing—all in JavaScript—without the need to rely on any native plugins or non-portable native code. SIMD.JS can run anywhere JavaScript runs. It will, however, run a lot faster and more power efficiently on the platforms that support SIMD. This includes both the client platforms (browsers and hybrid mobile HTML5 apps) as well as servers that run JavaScript, for example through the Node.js V8 engine.

We have introduced a set of low level APIs for programming SIMD directly in JavaScript. The API can be efficiently mapped to the processor’s SIMD instructions by a JavaScript JIT compiler when the processor has SIMD capabilities; otherwise, a default VM implementation will accomplish the task. Mozilla’s Emscripten compiler, that compiles C++ to JavaScript through LLVM, is also being modified to generate SIMD code automatically.  The SIMD.JS API is architecture-neutral and allows efficient SIMD execution on different platforms that support SIMD (e.g., Intel® Architecture and ARM).

A major part of the SIMD.JS API implementation has already landed in Firefox Nightly and our full implementation of the SIMD API for Intel Architecture has been submitted to Chromium for review. At an early stage of the initiative, we are getting excellent speedups of close to 400% using float32x4 and int32x4 SIMD operations. The following screenshots show a near 4x JavaScript performance improvement in computing the Mandelbrot set. On our other SIMD benchmarks, we get even more dramatic speedups of up to 10x. Google, Intel, and Mozilla are working on a TC39 ECMAScript proposal to include this JavaScript SIMD API in the future ES7 version of the JavaScript standard.


SIMD.JS Speedup in Firefox browser


SIMD.JS Speedup in Chromium browser


There is encouraging evidence that SIMD will enable a whole new class of application domains and high-performance libraries in JavaScript.   At Intel, we are very excited to help close one of the remaining important performance gaps in the web platform and move one step forward toward complete seamless cross-platform computing.

View the Intel presentation at the O’Reilly Fluent 2014 Conference for additional information including more exciting SIMD.JS benchmarking results. 

Read the white paper, SIMD in JavaScript.




Check out the free Intel XDK and take advantage of Crosswalk and contribute.