Git Product home page Git Product logo

Comments (5)

jrouwe avatar jrouwe commented on September 2, 2024 1

Sorry about that. I get an error on all the other instruction set flags too, so I opted to bypass the entire code block.

from joltphysics.

jrouwe avatar jrouwe commented on September 2, 2024 1

Shouldn't Jolt be adding the -msimd128 flag itself instead, as well as any -msse* flags, based on the relevant CMake options?

Yes it should. I've just submitted a change that adds a cmake option USE_WASM_SIMD which will add the needed flags.

Was SSE 4.2 just brought up as an example, or is there some limitation with Jolt and Emscripten that prevents targeting SSE2?

Emscripten just translates the SSE/AVX instructions to WASM SIMD instructions. The reason why I didn't pick AVX is that Jolt uses 256 bit SIMD instructions when AVX is enabled, which is not supported by emscripten. I picked the next highest which is SSE 4.2. I don't think it matters which SSE version you pick as it all gets converted to WASM instructions and the browser is responsible for translating them to native (SSE / NEON) instructions based on the CPU architecture.

It may be that rewriting Jolt to use the WASM intrinsics gives better performance, but having the SSE instructions automatically convert to WASM instructions was a lot less work.

from joltphysics.

mihe avatar mihe commented on September 2, 2024 1

Yes it should. I've just submitted a change that adds a cmake option USE_WASM_SIMD which will add the needed flags.

Great, thank you! Now there's just the dilemma of whether to actually enable it or not I guess. 😅

I don't think it matters which SSE version you pick as it all gets converted to WASM instructions and the browser is responsible for translating them to native (SSE / NEON) instructions based on the CPU architecture.

I'm a bit surprised that the minimum hardware requirements for WASM SIMD isn't explicitly mentioned anywhere for any of the major browsers (that I could find at least). I had to dig through the V8 source code to find that it's SSE4.1 for Chromium-based browsers. The one SSE4.2 intrinsic that's mappable to WASM SIMD (_mm_cmpgt_epi64) seems to have an SSE3 fallback in V8, as far as I can tell, so I assume they aim for everything to run on the minimum instruction set (i.e. SSE4.1).

from joltphysics.

tetious avatar tetious commented on September 2, 2024

Awesome! Thank you!

from joltphysics.

mihe avatar mihe commented on September 2, 2024

I'm a bit confused by this.

Shouldn't Jolt be adding the -msimd128 flag itself instead, as well as any -msse* flags, based on the relevant CMake options? From what I can tell from Emscripten's documentation it still supports all these flags just fine, albeit with some gaps/emulation in the instructions themselves by the looks of it.

Clearly mfpmath=sse isn't supported though, judging by the error here, but seeing as how the user is forced to append the rest of them through something like CMAKE_CXX_FLAGS anyway I don't quite see the point in omitting them from Jolt altogether.

I'm also curious about the specific mention of -msse4.2 here:

# Emscripten uses no special flags, if you want to turn on SIMD you should use -msimd128 -msse4.2

Was SSE 4.2 just brought up as an example, or is there some limitation with Jolt and Emscripten that prevents targeting SSE2?

(I realize SSE 4.2 has pretty much 100% coverage these days, but Godot is still hanging on to SSE2 for now.)

EDIT: I see now that the browser coverage isn't great for WebAssembly SIMD in general, but that's beside the point I guess.

from joltphysics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.