GithubHelp home page GithubHelp logo

Comments (6)

sunfishcode avatar sunfishcode commented on May 14, 2024 5

Wasm's sqrt really is deterministic; while other languages can use x87 which rounds things like sqrt differently in some cases, wasm doesn't permit this, and this is specifically tested for in the spec testsuite.

The ARM subnormal issue is only on 32-bit ARM, and only NEON, not VFP, so wasm's current scalar operations aren't affected. This is a potential concern for the SIMD proposal, however.

WebAssembly also fully specifies the behavior of conversion from floats to integers, and the behavior in all the cases where hardware is known to differ is covered in the testsuite too.

So while wasm could add rsqrt approximations or other things in the future, and SIMD will have to cope with 32-bit ARM NEON, in the current spec, NaN bit patterns really are the only floating-point nondeterminism.

from wasmi.

recmo avatar recmo commented on May 14, 2024 1

I'm assuming this issue tries to solve the non-determinism problem like so: WebAssembly/design#582 (comment)

For NaN bits, it'd be straightforward for a preprocessor to inject NaN canonicalization code after every floating-point computation, and that would suffice.

Doing this after every operation might be excessive, NaNs with different bit patterns still mostly behave the same. It should be enough to canonicalize in the few places where they don't: reinterpret, store, etc. There is a list here: https://github.com/WebAssembly/design/blob/master/Rationale.md#nan-bit-pattern-nondeterminism

Although it would be fun to write a contract that pays out when someone mines it with ARM instead of x86. Might be good for an ARM node bounty! 🤡

from wasmi.

NikVolf avatar NikVolf commented on May 14, 2024

Yep, the motivation is to prevent non-determinism still having some base2 floats.

it's not very important atm, since we can ban floats on the embedder and/or use soft floats in the user space

But still might be useful!

from wasmi.

pepyakin avatar pepyakin commented on May 14, 2024

Although it would be fun to write a contract that pays out when someone mines it with ARM instead of x86. Might be good for an ARM node bounty! 🤡

Interesting idea, but how would you actually proof that? : D

from wasmi.

MaxGraey avatar MaxGraey commented on May 14, 2024

I don't think NaN is only non-determinism part of float points in WebAssembly. Operations like sqrt and inverse sqrt (rsqrt) implement differently even on x86 by some vendors. ARM for example flush all subnormal values to zero (FTZ and DAZ modes). Conversion from floats to integers also behave differently on hardware and by compiler's mode.

from wasmi.

MaxGraey avatar MaxGraey commented on May 14, 2024

@sunfishcode Thank you for so detail clarifying! Now you had dispelled any doubts)

from wasmi.

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.