SPRACV1B February 2022 – January 2024 AM2434 , AM6411 , AM6412 , AM6421 , AM6441 , AM6442
Trigonometric functions are compute functions leveraged in for example motor control. The most commonly used ones are sine, cosine, arctan and arctan2. The standard C library math.h has highly accurate implementations of these functions, but the worst case execution time might not be acceptable. For Arm Cortex-R5F, the Arm CMSIS DSP library also has optimized implementations for some trigonometric functions. Sitara™ software development kit MCU-PLUS-SDK_AM243X and PROCESSOR-SDK-AM64X contains the CMSIS libary (in folder <mcu-plus-install-directoty>/source/cmsis) and further optimized functions for some of the functions in a library called ti_r5fmath_trig (in folder <mcu-plus-install-directoty>/examples/motor_control/benchmark_demo/common). Table 2-1 and Table 2-2 show the performance of the most commonly used trigonometric functions using the implementations found in C runtime library (math.h), CMSIS, and ti_r5fmath_trig library. The implementations trade off accuracy, shown in column max error, and compute time and sometimes additional memory consumption (a lookup table with constants in memory) as shown in column labeled Table size. This table needs to be in TCM or warm L1D cache for the documented performance.
Function | Max Cycles | Avg Cycles | Max Error (abs rad) | Table Size | Library |
---|---|---|---|---|---|
ti_r5fmath_sin() | 34 | 34 | 7.20E-07 | polynomial | TI_R5FMATHLIB |
ti_r5fmath_cos() | 38 | 38 | 2.90E-07 | polynomial | TI_R5FMATHLIB |
ti_r5fmath _sincos() |
51 | 51 | 7.20E-07 | polynomial | TI_R5FMATHLIB |
ti_r5fmath_fast_sincosB() | 57 | 57 | 1.90E-07 | polynomial | TI_R5FMATHLIB |
arm_cos_f32() | 66 | 66 | 1.80E-05 | Table 2kbytes | CMSIS |
sinf() | 71 | 71 | 8.40E-08 | polynomial | math.h |
cosf() | 81 | 81 | 9.70E-08 | polynomial | math.h |
arm_sin_cos_f32() | 114 | 114 | 6.10E-07 | Table 2kbytes | CMSIS |
sin() (double) | 340 | 296 | 3.00E-08 | polynomial | math.h |
Function | Max Cycles | Avg Cycles | Max Error (abs rad) | Table Size | Library |
---|---|---|---|---|---|
ti_r5fmath_atanFast() | 45 | 39 | 3.76E-03 | function | TI_R5FMATHLIB |
ti_r5fmath_atan2Fast() | 54 | 54 | 3.76E-03 | function | TI_R5FMATHLIB |
ti_r5fmath_atan() | 80 | 68 | 6.00E-07 | poly | TI_R5FMATHLIB |
atanf() | 111 | 90 | 6.80E-08 | poly | math.h |
ti_r5fmath_atan2() | 97 | 90 | 6.00E-07 | poly | TI_R5FMATHLIB |
atan2f() | 204 | 171 | 2.00E-07 | poly | math.h |