I have been writing kernels for a communication dsp device, which uses cmac/cmad operation on fixed and floating point numbers. I am not very clear why both types is used in the same operation.
-
1$\begingroup$ usually because of external requirements, or because of that's the kind of data you have, or because of numerical stability or... Well, why does one use fixed or floating point? the same applies here. $\endgroup$– Marcus MüllerMay 14, 2021 at 12:59
-
$\begingroup$ i think it depends on what parts are available to you. if you're using a SHArC, you got both fixed and float. if you're using a Blackfin, you got only fixed and you'll have to adapt to it. $\endgroup$– robert bristow-johnsonMay 14, 2021 at 17:19
-
$\begingroup$ And if you're using a mix of code from various sources, you may be bound to the types because that's what was originally assumed. $\endgroup$– TimWescottMay 14, 2021 at 17:42
2 Answers
The transition from text-book math to product code can be a lot simpler with floating point than with fixed point. The latter requires some specialized knowledge that, while not rocket science, may be more common for electronic engineers or embedded engineers than computer science or math people. Simple stuff tends to be a lot simpler in floating point than in fixed point.
If you really need to know the numerical behaviour of your code (as in certain recursive algorithms), it tends to be the other way around - the «cruise control» of floating point also makes it more tedious to figure out what is actually going on, while the explicit requirements of fixed point makes the details more plain sight.
-
$\begingroup$ "The latter requires some specialized knowledge ..." and even if your entire staff has that knowledge, every stage has to be carefully sized to match the data type, which is tedious. And "tedious" translates to "engineering hours", and those aren't free. $\endgroup$ May 14, 2021 at 17:44
One reason would be for the difference in how the quantization error signals are generated: a fixed point quantization error is a fixed level for all inputs within the allowable range between underflow and overflow ($-2^{b-1}$ to +$2^{b-1}-1$ for example for a signed fixed precision number with $b$ bits given here as signed integers, the peak to peak error is bound to be $b$). Floating point numbers in contrast have a quantization error that is proportional to the exponent: very large floating point numbers will have a very large peak to peak error in comparison to very small floating point numbers. This can cause stability issues in applications of pole cancellation where the fixed point solution can provide an exact cancellation while the floating point solution could have a residual error. Another application of fixed point is in the way it allows overflow and underflow conditions to wrap rather than create an underflow/overflow error as in floating point. See this recent post discussion how a CIC filter needs to be implemented in fixed point for these reasons.