Neon Reciprocal Approximation


Exophase

Nothing good will ever come of Exophase.
Joined
Sep 21, 2006
Messages
10,307
Age
41
Location
Cleveland OH
It looks like NEON has some instructions to perform reciprocal approximation or reciprocal series steps if you want to control the accuracy. This could potentially be useful for anyone attempting a perspective-correct software renderer where the SGX would or any reason be unsuitable.

Sadly, like a lot of things NEON, there isn't a lot of information out there, just the basic overview of the instruction and its operand types. So I'm wondering two things:

1. Just how accurate is the approximation? What is the error function exactly?
2. There's an approximation instruction for unsigned integer instead of floating point (same does not exist for the step function). What format is the result in? 0.0.32 fixed point? 0.1.31? Naturally if you're keeping things fixed point for whatever reason this could be more useful - for software rendering fixed point can be better since you'd be stepping a lot of low precision things like color elements.

I was hoping that perhaps someone with a Cortex-A8 who enjoys testing these things could find this one out. Adventus, maybe you would be interested? This seems like something that'd be quick and easy for you to do.
 
Slightly off-topic:

Do yourself a favour: follow the link on this page http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0406b/index.html
It's just a matter of registering and you'll get access to ARMv7-A documentation. Yes, things changed a few months ago. A very wise decision from ARM :)
 
Laurent said:
Slightly off-topic:

Do yourself a favour: follow the link on this page http://infocenter.ar...406b/index.html
It's just a matter of registering and you'll get access to ARMv7-A documentation. Yes, things changed a few months ago. A very wise decision from ARM :)

Thanks Laurent! This should be very informative.

EDIT: Okay, I have the document. It looks like for the integer version the input is fixed point 0.32, but it only works on values from 0.5 to 1 (non-inclusive), and the result is in 1.31 format from 1 to 2 (non-inclusive) with 9bits of data.
 
Last edited by a moderator:
1. Just how accurate is the approximation? What is the error function exactly?
I'm pretty sure vrecpe is just:

1 / (1+m)*(2^n) = (1 / (1+m)) * (2^-n)
1 / (1+m) ~ 1.41176471 - 0.47058824 * (1+m)

So you negate the exponent and do a linear expansion for the mantissa. The above values give a maximum error of ~0.0588 in the mantissa (and no error in the exponent). The step functions can then be used to implement newton rhapson iterations that converge quickly to 1/x. You can find approximation of the error in newtons method on the net, we're just finding the roots of f(x) = 1/x + c where c is the value we're trying to invert. Not completely sure but I think the absolute error after k iterations is given by:

E_k ~ c*(E_k-1)^2
E_k ~ c^(2^(k-1)) * E_0^(2^k)

where E_0 is the initial error (probably from the function above). I think 4 iterations is enough for a 100% accurate 32 bit inversion.
 
Laurent said:
Slightly off-topic:

Do yourself a favour: follow the link on this page http://infocenter.ar...406b/index.html
It's just a matter of registering and you'll get access to ARMv7-A documentation. Yes, things changed a few months ago. A very wise decision from ARM :)

the link ro register seems unreachable :/
 
Last edited by a moderator:
Back
Top