8 ms·
"within 2x the speed of native" Of crippled native, with things like SIMD instructions disabled.
by capisce 13y ago
"within 2x the speed of native"
Of crippled native, with things like SIMD instructions disabled.
- acdha 13y agoWith some optimizations unrealized: it's not like everything can use SIMD or that all problems which could theoretically use SIMD actually benefit. Comparing scalar code is still useful for the vast majority of programs executed.
- azakai 13y agoFurthermore, explicit SIMD code (for example, using SSE functions) is not portable. The comparison here was portable C/C++ to portable asm.js.
- capisce 13y agoFirst of all clang and LLVM support the GCC vector extensions which means you can write portable SIMD code: http://clang.llvm.org/docs/LanguageExtensions.html#vectors-and-extended-vectors http://clang.llvm.org/docs/LanguageExtensions.html#vectors-a... Second, compilers also do auto vectorization (automatically vectorizing code that is not explicitly written to use vector types / SIMD intrinsics) and in addition SSE is used even for scalar floating point operations these days. It doesn't look like asm.js even lets you operate on single precision (32 bit) floating point values which can be a performance issue in some cases. Last, web workers are less flexible than native multithreading with shared memory between threads and atomic instructions / mutexes etc. These and other issues mean it will not be possible to squeeze as much performance (and as a result power savings) out of asm.js as from native code or PNaCL.
- azakai 13y ago> First of all clang and LLVM support the GCC vector extensions which means you can write portable SIMD code It's portable in one sense, but not another - it doesn't work in other compilers like MSVC, which was used in this article. > Second, compilers also do auto vectorization (automatically vectorizing code that is not explicitly written to use vector types / SIMD intrinsics) Yes, if the native compiler did auto vectorization here, it helped it. asm.js still did very well though, so I suspect auto vectorization could not be achieved. > and in addition SSE is used even for scalar floating point operations these days. Yes, in both native compilers and JS engines. Likely SSE was used in both sides of the comparison here. > It doesn't look like asm.js even lets you operate on single precision (32 bit) floating point values which can be a performance issue in some cases. True, we are investigating that. Note that you can in some cases optimize double precision operations into single precision ones, even without explicit syntax. > These and other issues mean it will not be possible to squeeze as much performance (and as a result power savings) out of asm.js as from native code or PNaCL. If we are talking about the current state now, then PNaCl does not support SIMD either. If we are talking about eventually, then eventually JS might gain those things too.
- capisce 13y agoAh, I didn't know PNaCl didn't have explicit SIMD through vector types yet. Sounds like it should be relatively easy to add though since LLVM already provides them.