Code Monkey home page Code Monkey logo

Comments (6)

dlesnoff avatar dlesnoff commented on May 23, 2024 1

A quick google search gives:
https://gist.github.com/Yaffle/fb47de4c18b63147699e0b621f1031f7
and
https://gist.github.com/munrocket/adfbca362bf710f53621e483cb208f0e
They are more accurate albeit probably much slower than a pure axpy (a*b+c) computation.
One test that illustrates the difference:

assert( 0.1 * 10 - 1 == 0)
assert( fma(0.1, 10, 1) == 5.55112e-17) # Example from en.cppreference.com

I would expect a different rounding behaviour from a fma function than from an axpy computation.

P.S: The axpy term comes from the BLAS (basic linear algebra subprogram) specification.

from nim.

awr1 avatar awr1 commented on May 23, 2024 1

most recent high-perf x86 CPUs should do a uop-fuse on axpy, the FMA3 instructions really exist for increased accuracy. not really certain about ARM-land.

from nim.

juancarlospaco avatar juancarlospaco commented on May 23, 2024

For JS, would something like this be enough?

function fma(a, b, c) {
  return (a * b) + c
}

And an explanation on the documentation for JS targets.

from nim.

juancarlospaco avatar juancarlospaco commented on May 23, 2024

Then make it inside a when not defined(js): block and mention in docs is not available in JS.

from nim.

ringabout avatar ringabout commented on May 23, 2024

Feel free to open a pull request; see also nim-lang/RFCs#92

from nim.

dlesnoff avatar dlesnoff commented on May 23, 2024

@ringabout Sorry, I do not have time to implement this.

from nim.

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.