This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Part Number: EVMK2H
Hello!
I have an algorithm that uses functions from math.h. TI has an optimized MATHLIB library that optimizes mathematical functions.
Is it possible to attach a header file and apply functions from the MATHLIB library without changing the algorithm (replace math.h to mathlib.h)? How do I do this?
I use the mathlib_c66x_3_1_2_4 library an EVMK2H device.
The help contains the expression " By using these routines instead of the routines found in the existing run-time-support libraries, you can achieve execution speeds significantly faster without rewriting existing code."But it is not given how to do this?
I work on the C66 core.
The docs/MATHLIB_Users_Manual file is missing.chm
mathlib_c66x_3_1_2_4 does not contain the examples folder, as written in the documentation.
I thought that implementation mathlib_rts_c66x_3_1_2_1 the solution, but in this library again sqrtdp (not replace sqrt form math.h) and so on.
SYSBIOS: 6.76.04.02
CCS: 9.3
NDK: ndk_3_61_01_01
SDK: pdk_k2hk_4_0_15
Device: [EVMK2H](https://www.ti.com/tool/EVMK2H "Tool Folder")
George,
George Rodionov said:
Yes, MATHLIB can be used to override functions that are defined in math.h. In order to do this, you will need to rebuild the MATHLIB with the OVERRIDE_RTS enabled in the compiler settings as this is not provided as a default functionality for this library.
Please refer to this document that I had created some time back that provides information to rebuild MATHLIB with OVERRIDE_RTS=1 and linking to your DSP application.
Using_MATHLIB_RTS_functions_in_TI_RTOS_DSP_application.pdf
I am also providing a prebuilt version of MATHLIB and a reference project for you to check the linker settings.
C66x_Benhmark_using_MATHLIB.zip
Hope this helps.
Regards,
Rahul
Thanks for the answer, but it's not clear yet. And it doesn't work.
Q1: Do I need to exclude math.h from the project now? Or I can have him stay.
Q2: Do I need to go up all the c-files of the project in the "Link Order", according to the pdf instructions?
Q3: After completing the steps to connecting mathlib_rts.ae66, when going through the sin function and other mathematical functions, should they switch to MATHLIB files? This is not so.
The MATLIB download page has the mathlib_rts_c66x_3_1_2_1_Win32.exe library. The default option OVERRIDE_RTS = 1 is set in it. I used it and use provided file (of course separately).
After all in map-file I got:
C:/ti/mathlib_rts_c66x_3_1_2_1/packages/ti/mathlib/lib/mathlib_rts.ae66
asindp.oe66 1376 0 0
powdp.oe66 1088 0 0
atan2dp.oe66 992 0 0
powsp.oe66 704 0 0
log10dp.oe66 640 0 0
expdp.oe66 448 0 0
cosdp.oe66 416 0 0
sindp.oe66 384 0 0
divdp.oe66 160 0 0
divsp.oe66 160 0 0
sqrtdp.oe66 160 0 0
sqrtsp.oe66 160 0 0
tables.oe66 0 0 160
+--+--------------------------------+--------+---------+-----------+
Total: 6688 0 160
Q4: The map file still contains sin and other functions. I'm not confidence that it is work properly.
Q5: The provided file mathlib_rts.ae66 = 269 kB, the file with the library mathlib_rts_c66x_3_1_2_1 mathlib_rts.ae66 = 241 kB. This is suspicious.
With the provided file, the calculation in the float ceases to be performed.
Q6: How to understand that sin and other function from MATHLIB? The way with map file not convincing. My map file has both functions.
George
George Rodionov said:Q1: Do I need to exclude math.h from the project now? Or I can have him stay.
No, you don`t need to remove math.h file.
George Rodionov said:Q2: Do I need to go up all the c-files of the project in the "Link Order", according to the pdf instructions?
you are misinterpreting the build process. Link order is not done at file level, it is a project setting as linking step happens once after all files have been compiled so I don`t understand the need to set link order for all c files that you are referring to in the question.
George Rodionov said:
Did you try to build the example project that I shared. This has been used by multiple users and confirmed to be working.
George Rodionov said:The MATLIB download page has the mathlib_rts_c66x_3_1_2_1_Win32.exe library. The default option OVERRIDE_RTS = 1 is set in it. I used it and use provided file (of course separately).
I don`t agree with your observation. I did a fresh install of the version of MATHLIB that you referred and searched to confirm that the override_rts flag is set to 0 as you can see from screenshot below:
George Rodionov said:After all in map-file I got:
C:/ti/mathlib_rts_c66x_3_1_2_1/packages/ti/mathlib/lib/mathlib_rts.ae66
asindp.oe66 1376 0 0
powdp.oe66 1088 0 0
atan2dp.oe66 992 0 0
powsp.oe66 704 0 0
log10dp.oe66 640 0 0
expdp.oe66 448 0 0
cosdp.oe66 416 0 0
sindp.oe66 384 0 0
divdp.oe66 160 0 0
divsp.oe66 160 0 0
sqrtdp.oe66 160 0 0
sqrtsp.oe66 160 0 0
tables.oe66 0 0 160
+--+--------------------------------+--------+---------+-----------+
Total: 6688 0 160Q4: The map file still contains sin and other functions. I'm not confidence that it is work properly
If you are not confident that linking the library is working with your setup, then remove mathlib_rts.ae66 from the link step. You can directly add the required MATHLIB source files to your project. This approach takes advantage of the compiler link behavior where if a function is defined in the project then the API calls will not link to the RTS library. This is the easiest way to test the override functionality.
George Rodionov said:
Size of resulting binary will depend on the compiler version and the level of inlining and optimized code size it will generate.
George Rodionov said:Q6: How to understand that sin and other function from MATHLIB? The way with map file not convincing. My map file has both functions.
Map file is the only feedback the compiler provides to all of the linked symbols in your application binary. MAthlib only contains a subset of the RTS library functions so you are likely to see object files from both libraries being used but for functions that do exist in mathlib the mathlib object files will override the functions in the RTS library.
Hope the responses help.
Rahul Prabhu said:Did you try to build the example project that I shared. This has been used by multiple users and confirmed to be working.
You do not share example, only library
I will deal with the example, but it is not yet available
Q2: Do I need to add all the c-files of the project in the "Link Order", or not?
Rahul Prabhu said:I don`t agree with your observation. I did a fresh install of the version of MATHLIB that you referred and searched to confirm that the override_rts flag is set to 0 as you can see from screenshot below:
I told about library mathlib_rts_c66x_3_1_2_1_Win32.exe . I check it as you, get the next results:
Rahul Prabhu said:If you are not confident that linking the library is working with your setup, then remove mathlib_rts.ae66 from the link step. You can directly add the required MATHLIB source files to your project. This approach takes advantage of the compiler link behavior where if a function is defined in the project then the API calls will not link to the RTS library. This is the easiest way to test the override functionality.
How to do that? In your instruction has no description, and in TI instruction I can't find.
George,
Sorry, I wasn`t able to get to this last week. I have posted the example for your reference now. The example was originally created for AM572x device and if you want to use DDR and MSMC memory, just update the linker command file and update the cache setting if required (MAR bits to enable regions.)
AM57xx_C66x_Benhmark_using_MATHLIB.zip
Hope this helps.
Regards,
Rahul
How to understand wich function replace sin, cos and so on? In MATHLIB two type functions sp and dp - how to replace standart function with sp or dp - how can I switch between sp and dp?
George
Generally, the sin and cos functions in RTS library correspond to double precision function. You can confirm by going to TI C6000 compiler installation and checking for the cos and sin function definition in cos.c and sin.c located here:
ti-cgt-c6000_8.3.2\lib\src
RTS library defines single precision functions as cosf and sinf so you can switch by using appropriate function calls (matching RTS functions).
In the test report RTS refers to RTS library in the TI C6000 compiler, Inline refers to compiler inlined version of the function (inlining is used when function is called in a loop and compiler unrolls the loop to avoid branching). Code size with Inlined version is typically higher. The vector version of the function is function that works on t a array of values instead of a single value. there are _v versions of the functions defined in the library.
Regards,
Rahul
The test report is generated by running the code provided in test folder here:
mathlib_c66x_3_x_x_x\packages\ti\mathlib\src
In each folder, there is a _d file and function source provided with test input and output vectors that are used to check for correctness. Please review and let us know if you have further questions.
Regards
Rahul
I tried to execute cosdp_66_LE_ELF:
1. Add in workspace project C:\ti\mathlib_c66x_3_1_1_0\packages\ti\mathlib\src\cosdp\c66\cosdp_66_LE_ELF.
2. Select device 66AK2H14 and XDS2xx.
3. After try of compiling arise error
"C:/ti/mathlib_c66x_3_1_1_0/packages/ti/mathlib/src/cosdp/cosdp_d.c", line 149: error #20: identifier "DBL_MIN" is undefined"
Where defined DBL_MIN? It is double min value?
I set this value to 0 and get the next result:
-------------------------------------------------------------------------------- Verification Results: cosDP -------------------------------------------------------------------------------- Pre-defined Data: Passed Special Case Data: Passed Extended Range Data: Passed Random Data (seed = 7878): Passed -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- Cycle Profile: cosDP -------------------------------------------------------------------------------- RTS: 254 cycles ASM: 128 cycles C: 128 cycles Inline: 292 cycles Vector: 30 cycles -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- Memory Profile: cosDP -------------------------------------------------------------------------------- ASM: 32 bytes C: 768 bytes Vector: 448 bytes --------------------------------------------------------------------------------
Is it correct?
George