RedLib and Trigonometric

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

RedLib and Trigonometric

Jump to solution
1,225 Views
richardpayne
Contributor II

Hi

I getting a bit of confusion on RedLib, partial support on C99 where it provide Trigonometric (sin, cos, tan, tan2 and so on) for both float and double.

I'm using RedLib for LPC1549 project (Cortex M3) which has no FPU. I'm understood that float is 32 bit and double is 64 bits but limited precision of result to 8 digit for float and 14-15 digit for double.

(1) What is performance difference between float and double (compared to Cortex M4 which has FPU) doing sin, cos and tan function. Alternatively, how many clock cycle to complete this process. Is there link for this?

(2) is RedLib a version 2 (I believe it is but not clear on LPCExpresso, it just say RedLib(Auto).

(3) How to minimise common math error when using Trigonometric function. Is there link for this?

(4) How the RedLib perform process on sin, cos, tan, tan2 and sinf, cosf, tanf, do they use look up table or use maths.

(5) Are they fully IEEE754 complaint (in context of results, nothing to do with hardware FPU) or not?

Much thanks and appericate your contribution for this calification.

0 Kudos
1 Solution
745 Views
lpcxpresso_supp
NXP Employee
NXP Employee

Cortex M3 (and Cortex-M0/M0+ as well) have no floating point hardware. This means that all floating point operations are emulated using software library routines (as part of a spec produced by ARM, called the ARM Embedded Application Binary Interface (AEABI)). This means that the compiler can automatically generate the correct function calls into the library code for floating point operations

This means that floating point operations will always be relatively slow, particularly compared to integer operations which are typically done in hardware. Thus it is generally advisable to avoid floating point if possible. And you may also want to consider using fixed point operations instead too if performance is critical.

On Cortex-M4, there is typically a FPU - but which only implement single precision operations. So again all double precision operations are carried out using software library routines. For more details of floating point on CM4, see the FAQ: Cortex-M4 Floating Point Support​.

There is nothing Redlib specific about any of this. Using your favourite search engine with "cortex-m floating point" will bring up lots of other useful information on all of this.

And there should be no need to change any C library settings for floating point to "just work" with Redlib.

Aside : Your reference to Redlib V2 - this "V2" is a legacy thing that can be ignored. It refers to a change in the semihosting interface used by Redlib that happened about 5 years ago.

Regards,

LPCXpresso Support

View solution in original post

1 Reply
746 Views
lpcxpresso_supp
NXP Employee
NXP Employee

Cortex M3 (and Cortex-M0/M0+ as well) have no floating point hardware. This means that all floating point operations are emulated using software library routines (as part of a spec produced by ARM, called the ARM Embedded Application Binary Interface (AEABI)). This means that the compiler can automatically generate the correct function calls into the library code for floating point operations

This means that floating point operations will always be relatively slow, particularly compared to integer operations which are typically done in hardware. Thus it is generally advisable to avoid floating point if possible. And you may also want to consider using fixed point operations instead too if performance is critical.

On Cortex-M4, there is typically a FPU - but which only implement single precision operations. So again all double precision operations are carried out using software library routines. For more details of floating point on CM4, see the FAQ: Cortex-M4 Floating Point Support​.

There is nothing Redlib specific about any of this. Using your favourite search engine with "cortex-m floating point" will bring up lots of other useful information on all of this.

And there should be no need to change any C library settings for floating point to "just work" with Redlib.

Aside : Your reference to Redlib V2 - this "V2" is a legacy thing that can be ignored. It refers to a change in the semihosting interface used by Redlib that happened about 5 years ago.

Regards,

LPCXpresso Support