Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I try out SIMD instructions in Chrome?

I would like to experiment with SIMD (single instruction multiple data). From what I can glean from Google Group postings, people have been working to add this to Google Chrome, but when I try to call SIMD.Float32x4 in Chrome 46, I get that SIMD is undefined.

My googling suggests there might be some experimental versions of Chrome that have SIMD support. What is the newest version that includes it and what command line flags need to be set in order to use it? Do I need to use strict mode?

When will SIMD be rolled into the stable Chrome build?

Also does it make a difference running SIMD instructions if I run a 32 bit version of Chrome or a 64 bit version?

like image 277
bruceceng Avatar asked Oct 28 '15 21:10

bruceceng


2 Answers

Update (24/6/17): Chrome is dropping SIMD support in JS and only allowing it in WebAssembly.


Update: Now it's possible in the latest version of Chrome with a flag:

--js-flags="--harmony-simd"

In Chrome shortcut properties(i.e. on your desktop) "Target" field will look something like this

"C:\Users\Pav\AppData\Local\Google\Chrome SxS\Application\chrome.exe" --js-flags="--harmony-simd"

Old answer:

You can try them out in Node before they will be added to Chrome (same JavaScript engine)

  1. Install latest Node from https://nodejs.org/en/

  2. Run your JavaScript as "node --harmony-simd index.js" (your code in index.js)

  3. Print output from your script just like in Chrome console using console.log('BANG') or just log('TEST 2')

Option 2

Not Chrome solution but you can use SIMD in Firefox. Download Firefox Nightly which has SIMD already integrated. SIMD is almost identical between browsers.

https://nightly.mozilla.org/

If someone could explain how to build the latest Chromium with native SIMD(not polyfill as it's now) support that would be great.

like image 153
Pawel Avatar answered Oct 03 '22 17:10

Pawel


It seems that the extent of SIMD in Chromium is an experimental contribution by Intel from 2013.

You can try it out in a special build of Chromium 37 (ia32). Source: IDF14 demo links.

To try it out download the build for your platform and start with the command-line flag --js-flags=--simd-object.

For example, on OSX:

./Chromium.app/Contents/MacOS/Chromium --js-flags=--simd-object

The SIMD object is available in the JavaScript console:

var a = SIMD.float32x4(1, 2, 3, 4);
var b = SIMD.float32x4(5, 6, 7, 8);
var c = SIMD.float32x4.add(a,b);
console.log(c.toString())
// > float32x4(6,8,10,12) 

I could find no information about intent to merge (but would love to hear something authoritative).

like image 24
joews Avatar answered Oct 03 '22 17:10

joews