Is some SSE header missing ?

270 views
Skip to first unread message

Flix

unread,
Jun 19, 2017, 8:22:43 AM6/19/17
to emscripten-discuss
Hello.

I'm tried to port to emscripten (a very simple) project that must be compiled with -msse2.

I'm completely new to SSE and similar stuff, so I'm not sure if what I'm seeing is correct... :(

I'm using 1.37.13 (it was "latest" in emsdk).

I'm seeing that in ./emsdk/emscripten/1.37.13/system/include/SSE some headers are missing.

Specifically mm_malloc.h is not present (currently I'm using a workaround using posix_memalign).

Moreover, I need these:

_MM_SET_FLUSH_ZERO_MODE
_MM_SET_DENORMALS_ZERO_MODE

that (tested with grep) are not part of ./emsdk/emscripten/1.37.13/system/include/SSE.

[Compiling for Linux using g++ works]

Flix

unread,
Jun 19, 2017, 8:40:08 AM6/19/17
to emscripten-discuss

Actually maybe it does not work because it uses sse > sse2. I can't tell, but I've discovered that _MM_SET_DENORMALS_ZERO_MODE is actually present in ./emsdk/emscripten/1.37.13/system/include/SSE/pmmintrin.h, but at its top there's:

| #ifndef __SSE3__
| #error "SSE3 instruction set not enabled"
| #endif

so I guess it's part of SSE3, and using -msse3 in the command line still seems to trigger "SSE3 instruction set not enabled".

_MM_SET_FLUSH_ZERO_MODE instead is not present in any header.

So, th conclusion seems to be:
-> the program used more than SSE2
-> and SS3 or bigger is not supported in emscripten

Is this correct ?

Flix

unread,
Jun 19, 2017, 9:12:51 AM6/19/17
to emscripten-discuss

Accroding to https://kripken.github.io/emscripten-site/docs/porting/simd.html:
"Emscripten has full support for compiling code that utilizes the SSE1, SSE2, SSE3 and SSSE3 intrinsic function calls"

For people interested, I'm trying to port the example from this repo (just 2 cpp files): https://github.com/rasmusbarr/nudge/issues/1

Flix

unread,
Jun 19, 2017, 3:55:57 PM6/19/17
to emscripten-discuss

Made some progress. I had to manually define -D"__SSSE3__" (together with -msse3).

Managed to compile it, but performance is very poor.

However, if I try web assembly (-s WASM=1), I get:

Traceback (most recent call last):
File "/.../emsdk/emscripten/1.37.13/em++", line 16, in <module>
emcc.run()
File "/.../emsdk/emscripten/1.37.13/emcc.py", line 1795, in run
 wasm_text_target, misc_temp_files, optimizer)
File "/.../emsdk/emscripten/1.37.13/emcc.py", line 2260, in do_binaryen
 subprocess.check_call(cmd)
File "/usr/lib/python2.7/subprocess.py", line 541, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '[u'/.../emsdk/clang/e1.37.13_64bit/binaryen/bin/asm2wasm', 'html/nudge.temp.asm.js', '--total-memory=16777216', '--emit-potential-traps', '-O2', '--mem-init=html/nudge.html.mem', '--mem-base=1024', '--wasm-only', '-o', 'html/nudge.wasm']' returned non-zero exit status -6

Can I do something about it ?


Jukka Jylänki

unread,
Jun 21, 2017, 8:43:31 AM6/21/17
to emscripte...@googlegroups.com
It looks like _MM_SET_FLUSH_ZERO_MODE is missing in our xmmintrin.h. I
can't find any other documentation of that except for MSDN pages, I
wonder if that is Microsoft specific?

_MM_SET_DENORMALS_ZERO_MODE seems to be SSE3 and that is present.

When benchmarking performance, check the web page console first to
verify whether it successfully compiles as asm.js in Firefox. If it
does not, then performance will be very poor. Second, take a look at
the Firefox perf.html add-on at https://perf-html.io, that is a good
tool to use to benchmark.

SIMD support is not available when building with WebAssembly. That is
a feature that is due to be added in a later release of WebAssembly
specification itself.
> --
> 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 emscripten-disc...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Flix

unread,
Jun 22, 2017, 9:02:27 AM6/22/17
to emscripten-discuss

Thanks for your help!

Indeed, I got some compile warnings in the browser console:

TypeError: asm.js link error: bad SIMD type  nudge.js:129:8
TypeError: asm.js type error: Disabled by 'asmjs' runtime option 1 nudge.js

So I got bad SIMD type. nudge.js:129:8: this line:
var Z=(function(global,env,buffer) {

Not sure how to fix it. But at least I know SIMD is not working.


SIMD support is not available when building with WebAssembly.
 
Good to know.

P.S. _MM_SET_FLUSH_ZERO_MODE and _MM_SET_DENORMALS_ZERO_MODE are not Microsoft specific (because I could use them in Linux builds). However they were used just as an optimization I could easily bypass in emscripten builds.

And it seems to me that even if the _MM_SET_DENORMALS_ZERO_MODE macro is present:

pmmintrin.h:#define _MM_SET_DENORMALS_ZERO_MODE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_DENORMALS_ZERO_MASK) | (x)))

the required _mm_setcsr and _mm_getcsr are missing (well, I could not find them).

However your answer has been very useful to me. Thanks again.


Reply all
Reply to author
Forward
0 new messages