Not applicable
Jul 04, 2013
02:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jul 04, 2013
02:12 AM
I need to perform maths functions like sqrt, pow, etc as fast as possible on the xmc4500.
Do I need to use an App to enable and utilise the Floating Point Unit (FPU) ?
Do I need to include an FPU specific maths library ?
Any help and advise would be greatly appreciated.
Aaron
Do I need to use an App to enable and utilise the Floating Point Unit (FPU) ?
Do I need to include an FPU specific maths library ?
Any help and advise would be greatly appreciated.
Aaron
- Tags:
- IFX
10 Replies
Not applicable
Jul 05, 2013
12:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jul 05, 2013
12:31 AM
Hi Aaron,
The pow function is available in CMSIS. The math library is under C:\DAVE-3.1\CMSIS\Lib\GCC.
What you need to do is:
1) Go to Project -> Active Project Properties -> C/C++ Build -> Settings -> ARM-GCC C Compiler, add "__FPU_PRESENT" & "ARM_MATH_CM4" in the Preprocessor
2) Go to Project -> Active Project Properties -> C/C++ Build -> Settings -> ARM-GCC C Linker, add "arm_cortexM4_mathL_1" & "arm_cortexM4_mathL_2" in the Libraries (-l) and ""${eclipse_home}/.../CMSIS/Lib/GCC"" in the Libraries search path (-L)
3) Add "#include"
4) Use function "arm_power_f32(float32_t * pSrc, uint32_t blockSize, float32_t * pResult)"
As for the sqrt function, you can refer to previous "May 16th" post (http://www.infineonforums.com/threads/639-Does-XMC4500-support-the-sqrt-function-please?highlight=sq...)
Best regards,
Sophia
The pow function is available in CMSIS. The math library is under C:\DAVE-3.1\CMSIS\Lib\GCC.
What you need to do is:
1) Go to Project -> Active Project Properties -> C/C++ Build -> Settings -> ARM-GCC C Compiler, add "__FPU_PRESENT" & "ARM_MATH_CM4" in the Preprocessor
2) Go to Project -> Active Project Properties -> C/C++ Build -> Settings -> ARM-GCC C Linker, add "arm_cortexM4_mathL_1" & "arm_cortexM4_mathL_2" in the Libraries (-l) and ""${eclipse_home}/.../CMSIS/Lib/GCC"" in the Libraries search path (-L)
3) Add "#include
4) Use function "arm_power_f32(float32_t * pSrc, uint32_t blockSize, float32_t * pResult)"
As for the sqrt function, you can refer to previous "May 16th" post (http://www.infineonforums.com/threads/639-Does-XMC4500-support-the-sqrt-function-please?highlight=sq...)
Best regards,
Sophia
Not applicable
Jul 05, 2013
01:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jul 05, 2013
01:39 AM
Hi Sophia,
Fantastic, very very helpful. Thank you.
Best regards
Aaron
Fantastic, very very helpful. Thank you.
Best regards
Aaron
Not applicable
Jul 05, 2013
02:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jul 05, 2013
02:42 AM
Hi Sophia,
I made all the changes to my project. Unfortunately I get the following build errors...
I made all the changes to my project. Unfortunately I get the following build errors...
c:/dave-3.1/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: cannot find -larm_cortexM4_mathL_1
c:/dave-3.1/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: cannot find -larm_cortexM4_mathL_1
I found similar files on my PC...
C:\DAVE-3.1\CMSIS\Lib\GCC\libarm_cortexM4_mathL_1.a
C:\DAVE-3.1\CMSIS\Lib\GCC\libarm_cortexM4_mathL_2.a
I changed the Libraries (-l) to "libarm_cortexM4_mathL_1" & "libarm_cortexM4_mathL_2" but this did not help.
I changed the Libraries (-l) to "libarm_cortexM4_mathL_1.a" & "libarm_cortexM4_mathL_2.a" but this did not help.
Any ideas ?
Thank you very much
Aaron
c:/dave-3.1/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: cannot find -larm_cortexM4_mathL_1
I found similar files on my PC...
C:\DAVE-3.1\CMSIS\Lib\GCC\libarm_cortexM4_mathL_1.a
C:\DAVE-3.1\CMSIS\Lib\GCC\libarm_cortexM4_mathL_2.a
I changed the Libraries (-l) to "libarm_cortexM4_mathL_1" & "libarm_cortexM4_mathL_2" but this did not help.
I changed the Libraries (-l) to "libarm_cortexM4_mathL_1.a" & "libarm_cortexM4_mathL_2.a" but this did not help.
Any ideas ?
Thank you very much
Aaron
Not applicable
Jul 08, 2013
02:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jul 08, 2013
02:15 AM
Hi Aaron,
You didn't set the Libraries search path (-L).
There are two settings in step 2:
2a) Add libraries (-l) "arm_cortexM4_mathL_1" & "arm_cortexM4_mathL_2"
2b) Add Libraries search path (-L) ""${eclipse_home}/.../CMSIS/Lib/GCC""
Pls follow the exact settings shown in LinkerSetting_FPU.jpg (Jul 5th post) , thanks.
Best regards,
Sophia
You didn't set the Libraries search path (-L).
There are two settings in step 2:
2a) Add libraries (-l) "arm_cortexM4_mathL_1" & "arm_cortexM4_mathL_2"
2b) Add Libraries search path (-L) ""${eclipse_home}/.../CMSIS/Lib/GCC""
Pls follow the exact settings shown in LinkerSetting_FPU.jpg (Jul 5th post) , thanks.
Best regards,
Sophia
Not applicable
Jul 08, 2013
02:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jul 08, 2013
02:28 AM
Hi Aaron,
There is another simple way to do "pow" function which is to use newlib library. What you need to do is:
1) Go to Project -> Active Project Properties -> C/C++ Build -> Settings -> ARM-GCC C Linker, add "m" in the Libraries (-l)
2) Add "#include"
3) Use function "float powf(float x, float y)"
The steps 1 & 2 are applicable for other math functions provided by newlib library (http://sourceware.org/newlib/libm.html).
Best regards,
Sophia
There is another simple way to do "pow" function which is to use newlib library. What you need to do is:
1) Go to Project -> Active Project Properties -> C/C++ Build -> Settings -> ARM-GCC C Linker, add "m" in the Libraries (-l)
2) Add "#include
3) Use function "float powf(float x, float y)"
The steps 1 & 2 are applicable for other math functions provided by newlib library (http://sourceware.org/newlib/libm.html).
Best regards,
Sophia
Not applicable
Jul 08, 2013
03:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jul 08, 2013
03:01 AM
The libraries search path is incorrect. It should be set to : ""C:\DAVE-3.1\CMSIS\Lib\GCC"". The libraries are not located in the eclipse_home directory (C:\DAVE-3.1\eclipse\CMSIS\Lib\GCC) but in. C:\DAVE-3.1\CMSIS\Lib\GCC
Not applicable
Jul 08, 2013
03:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jul 08, 2013
03:39 AM
Thank you Sophia and Jochem.
I have implemented Sophia's suggestion (see below) and this is now working.
Best regards
Aaron
1) Go to Project -> Active Project Properties -> C/C++ Build -> Settings -> ARM-GCC C Linker, add "m" in the Libraries (-l)
2) Add "#include"
3) Use function "float powf(float x, float y)"
I have implemented Sophia's suggestion (see below) and this is now working.
Best regards
Aaron
1) Go to Project -> Active Project Properties -> C/C++ Build -> Settings -> ARM-GCC C Linker, add "m" in the Libraries (-l)
2) Add "#include
3) Use function "float powf(float x, float y)"
Jul 08, 2013
05:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jul 08, 2013
05:35 AM
I have just measured the performance of fpu calculations (uc tackt clock 120 MHz).
This is not very accurate, but close.
Approximately the number of uc tackts for functions/operations:
Operation/Function Tackts
sqrtf 21
sqrt 1000
float++ 1
float * float 1
float / float 13
sinf 1300
sin 2300
sqrt is about 50 times slower as sqrtf! I think the sqrtf uses fpu implementation but the sqrt not. Means the float is fpu optimized, but double is not optimized!
This is not very accurate, but close.
Approximately the number of uc tackts for functions/operations:
Operation/Function Tackts
sqrtf 21
sqrt 1000
float++ 1
float * float 1
float / float 13
sinf 1300
sin 2300
sqrt is about 50 times slower as sqrtf! I think the sqrtf uses fpu implementation but the sqrt not. Means the float is fpu optimized, but double is not optimized!
Not applicable
Jul 08, 2013
06:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jul 08, 2013
06:19 AM
Hi Dmitry, thankyou for the very interesting information. It will help me choose the right functions for fastest program execution.
Best regards
Aaron
Best regards
Aaron
Not applicable
Dec 01, 2015
12:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dec 01, 2015
12:41 AM
sophia wrote:
Hi Aaron,
You didn't set the Libraries search path (-L).
There are two settings in step 2:
2a) Add libraries (-l) "arm_cortexM4_mathL_1" & "arm_cortexM4_mathL_2"
2b) Add Libraries search path (-L) ""${eclipse_home}/.../CMSIS/Lib/GCC""
Pls follow the exact settings shown in LinkerSetting_FPU.jpg (Jul 5th post) , thanks.
Best regards,
Sophia
A similar question, where to find these binary libraries for DAVE4?