c++fma

Is there a simple way to use multiply accumulate in c++?


I've gotten great performance benefit from using the mad function in the c++AMP library. I was wondering if there is a similar function for regular c++ 11? All I found googling was stuff on AVX intrinsics but I'd rather avoid them due to them not being universally supported.

Also, they seem to be all made for processing 4+ mad operations at the same time and I'm not sure that constructing an environment for that to happen while actually just using 1 of them is even efficient.


Solution

  • In C and C++ there is the fma family of math functions:

    As they are part of the standard library they should be portable enough.