golemfactory/sp-wasm

Float Nan's determenistic

Opened this issue · 3 comments

mnill commented

Hi there, from documentation

WebAssembly is a deterministic machine, but in some points it needs more consideration. WebAssembly is single threaded by design - synchronisation and order of execution is not the case. Floating point operations are strict and deterministic. With one exception, NaN representation differs in various environments. There is an execution parameter that enforces determinism but it decreases performance slightly.

But there is no more information about this "execution parameter", can you please explain how enforce float deterministic?

Hey, thanks for raising this issue. I guess the docs are somewhat misleading. Floats are deterministic up to NaN considerations, and we currently don't offer any way of allowing the user enable/disable it. However, we strive to enforce it at the Golem's app level meaning that gWasm will, for now, only be available on x86_64 architechtures. ASAIK there are other solutions which enforce deterministic floats and hence NaNs at the software level, however, we've decided not to go that route ATM as it really affects the performance.

Anyhow, I'll make the necessary changes in the docs so that we minimise any confusion that may arise. Thanks again for spotting it!

mnill commented

Thank you for the answer.
I interested in reproduce-able computation. Are you think float NaN's has one binary representation on any x86_64 processor? I'll test it, also I will try to write simple gWasm app in near future.
Thank you again, very interested project =-)

Yep, it's exactly as you're saying: on any x86_64 cpu, you should get the same NaN behaviour.

Awesome, please do try writing some gWasm apps, and let us know how it goes! We're looking forward to your feedback, and if you encounter any problems, issues, bugs, etc., don't hesitate to file an issue, etc. :-)