← Back to context

Comment by adgjlsfhk1

4 years ago

that's called fixed point. there isn't hardware for it because it is cheap to make in software using integer math.

But wouldn't it be sweet to have SIMD acceleration for fixed point?

Or is that something you can do with integers and SIMD today?

Say 4x4 matrix multiplication?

  • Having implemented a nested PID controller using fixed-point arithmetic in an FPGA, I can tell you that fixed-point is a pain in the ass, and you only use it when floating-point is too slow, too large (in terms of on-chip resources), or consumes too much power, or when you really need to control the precision going into and out of an arithmetic operation.

  • your add is just an integer add. your multiply is a mul_hi, 2 shifts, 1 add and 1 mul.

    • I know some of those words, but still I'm curious as to why OpenGL has not explored fixed for 3D graphics?

Some DSP chips had hardware for fixed point. I think it's a shame that C never added support for fixed point.

  • There was a draft and GCC supports it in stdfix.h. The downside is that the types have limited integer range since they're tailored for DSP applications where values are kept scaled between +/-1.0.