16

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?

Yves M.
  • 29,855
  • 23
  • 108
  • 144
bruceceng
  • 1,844
  • 18
  • 23
  • Maybe the Google developer forum would be a better place to ask this. – Barmar Oct 28 '15 at 22:09
  • 2
    **Note to future visitors:** Looks like [chrome is dropping SIMD support](https://bugs.chromium.org/p/v8/issues/detail?id=4124#c159) in JS and only allowing it [in WebAssembly](https://bugs.chromium.org/p/v8/issues/detail?id=6020&desc=2#maincol) :\ –  Jun 24 '17 at 04:21

2 Answers2

12

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.

Pawel
  • 16,093
  • 5
  • 70
  • 73
  • `--js-flags="--harmony-simd"` NOT worked for me, in chrome 52.0.2743.116 m NOR nw.js 0.16.1 – Ciberman Aug 26 '16 at 03:16
  • @Ciberman just checked with 52.0.2743.116 m 64bit on Windows 10 and it worked. What's your "Target" field? – Pawel Aug 26 '16 at 09:26
  • I tried again and it simply worked. I don't know why. – Ciberman Aug 27 '16 at 03:39
  • @Ciberman To get Chrome to actually run with new flags, you have to totally shutdown all existing Chrome processes. Sometimes an extension keeps running in the background. Maybe this was your issue the first time. – bruceceng Aug 29 '16 at 22:58
1

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).

joews
  • 29,767
  • 10
  • 79
  • 91
  • It is possible to build the latest version of Chromium with SIMD support. I saw a later version than Intel's somewhere. How to do it? – Pawel Nov 14 '15 at 17:59
  • 1
    I tried these but names of functions are outdated. They are different in Firefox nightly and Node i,e, float32x4 is Float32x4 – Pawel Jan 29 '16 at 01:16
  • Also works in current node version (7.4): `node --harmony-simd` – Shane Holloway Jan 24 '17 at 04:15