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.

CCS/TMS320F28335: fastRTS example from Controlsuite not working

Part Number: TMS320F28335
Other Parts Discussed in Thread: CONTROLSUITE, C2000WARE

Tool/software: Code Composer Studio

Hi,

I am looking into using fastRTS to speed up some floating point calculation in my project. First of all, I try to learn how to use it by playing with the example provided by Controlsuite.

The example name is "28335_fastRTS", located at "C:\ti\controlSUITE\libs\math\FPUfastRTS\V100\examples_ccsv4\2833x_fastRTS".

I followed the document "C28x Floating Point Unit fastRTS Library" (SPRCA75):

(1) in build---c2000 link---file search path ---- both rts2800_fpu32.lib and rts2800_fpu32_fast_implement.lib are already there.

(2) search libraries in priority order and reread libraries are ticked. The other one leaves unticked.

(3) In link order, it is 28235_IQmath_Ink.cmd (do not know why is 28235?), rts2800_fpu_fast_implement, and rts2800_fpu32.lib.

The I build the project, the build log is as follows.

**** Build of configuration Debug for project 28335_fastRTS ****

"C:\\ti\\ccsv8\\utils\\bin\\gmake" -k all

Building file: "C:/ti/controlSUITE/libs/math/FPUfastRTS/V100/examples_ccsv4/source/CodeStartBranch.asm"
Invoking: C2000 Compiler
"C:/ti/ccsv8/tools/compiler/ti-cgt-c2000_18.1.3.LTS/bin/cl2000" --silicon_version=28 -g --define=_DEBUG --define=LARGE_MODEL --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-c2000_18.1.3.LTS/include" --include_path="/packages/ti/xdais" --include_path="C:/ti/controlSUITE/libs/math/FPUfastRTS/V100/include" --quiet --diag_warning=225 --optimize_with_debug --large_memory_model --unified_memory --float_support=fpu32 -k --asm_listing --output_all_syms --preproc_with_compile --preproc_dependency="CodeStartBranch.d_raw" "C:/ti/controlSUITE/libs/math/FPUfastRTS/V100/examples_ccsv4/source/CodeStartBranch.asm"
Finished building: "C:/ti/controlSUITE/libs/math/FPUfastRTS/V100/examples_ccsv4/source/CodeStartBranch.asm"

Building file: "C:/ti/controlSUITE/libs/math/FPUfastRTS/V100/examples_ccsv4/source/fastRTS_sample.c"
Invoking: C2000 Compiler
"C:/ti/ccsv8/tools/compiler/ti-cgt-c2000_18.1.3.LTS/bin/cl2000" --silicon_version=28 -g --define=_DEBUG --define=LARGE_MODEL --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-c2000_18.1.3.LTS/include" --include_path="/packages/ti/xdais" --include_path="C:/ti/controlSUITE/libs/math/FPUfastRTS/V100/include" --quiet --diag_warning=225 --optimize_with_debug --large_memory_model --unified_memory --float_support=fpu32 -k --asm_listing --output_all_syms --preproc_with_compile --preproc_dependency="fastRTS_sample.d_raw" "C:/ti/controlSUITE/libs/math/FPUfastRTS/V100/examples_ccsv4/source/fastRTS_sample.c"
Finished building: "C:/ti/controlSUITE/libs/math/FPUfastRTS/V100/examples_ccsv4/source/fastRTS_sample.c"

Building target: "28335_fastRTS.out"
Invoking: C2000 Linker
"C:/ti/ccsv8/tools/compiler/ti-cgt-c2000_18.1.3.LTS/bin/cl2000" --silicon_version=28 -g --define=_DEBUG --define=LARGE_MODEL --quiet --diag_warning=225 --optimize_with_debug --large_memory_model --unified_memory --float_support=fpu32 -k --asm_listing --output_all_syms -z -m"28335_fastRTS.map" --stack_size=400 --heap_size=2000 --warn_sections -i"C:/ti/ccsv8/tools/compiler/ti-cgt-c2000_18.1.3.LTS/lib" -i"C:/ti/ccsv8/tools/compiler/ti-cgt-c2000_18.1.3.LTS/include" -i"C:/ti/controlSUITE/libs/math/FPUfastRTS/V100/examples_ccsv4/2833x_fastRTS" -i"C:/ti/controlSUITE/libs/math/FPUfastRTS/V100/lib" --priority --reread_libs --xml_link_info="28335_fastRTS_linkInfo.xml" --entry_point=code_start --rom_model -o "28335_fastRTS.out" -lrts2800_fpu32_fast_supplement.lib -lrts2800_fpu32.lib "./CodeStartBranch.obj" "./fastRTS_sample.obj" "C:/ti/controlSUITE/libs/math/FPUfastRTS/V100/examples_ccsv4/cmd/28335_fastRTS_lnk.cmd"
warning: entry-point symbol other than "_c_int00" specified: "code_start"
Finished building target: "28335_fastRTS.out"

**** Build Finished ****

The .map file shows as follows.

.text 0 00009000 0000030d
00009000 00000134 fastRTS_sample.obj (.text)
00009134 00000056 rts2800_fpu32.lib : boot28.asm.obj (.text)
0000918a 0000004a rts2800_fpu32_fast_supplement.lib : atan_f32.obj (.text)
000091d4 00000034 : cos_f32.obj (.text)
00009208 00000034 : sin_f32.obj (.text)
0000923c 00000029 rts2800_fpu32.lib : exit.c.obj (.text)
00009265 00000024 : cpy_tbl.c.obj (.text)
00009289 00000021 rts2800_fpu32_fast_supplement.lib : sqrt_f32.obj (.text)
000092aa 0000001d rts2800_fpu32.lib : memcpy.c.obj (.text)
000092c7 00000019 : args_main.c.obj (.text)
000092e0 00000019 rts2800_fpu32_fast_supplement.lib : div_f32.obj (.text)
000092f9 00000009 rts2800_fpu32.lib : _lock.c.obj (.text)
00009302 00000008 CodeStartBranch.obj (.text)
0000930a 00000002 rts2800_fpu32.lib : pre_init.c.obj (.text)
0000930c 00000001 : startup.c.obj (.text)

According to the document mentioned above, this .map means it is still using normal RTS, not fastRTS, as the rts2800_fpu32.lib appears fist. Why it is happening, as I did not changed anything in the code, and followed the instructions in the document to change the settings. Actually, I do not have to change the settings, as they are already the same as stated in the document.

Why it is still using the normal RTS?

I am using CCS8.2 with TI F28335 experimental kit. 

Thanks,

  • Hi,

    With CCS 8.2 try with C2000ware example :

    C:\ti\c2000\C2000Ware_1_00_05_00\libraries\math\FPUfastRTS\c28\examples

    Regards,

    Gautam

  • Hi Gautam,

    Thank you for your comment. I have changed to C2000ware. However, it does not make difference to me. And I believe the documents and soucre files are the same as those in controlsuite.

    The .map file still comes with rst2800_fpu32.lib first.

    .text 0 00009000 0000030d
    00009000 00000134 fastRTS_sample.obj (.text)
    00009134 00000056 rts2800_fpu32.lib : boot28.asm.obj (.text)
    0000918a 0000004a rts2800_fpu32_fast_supplement.lib : atan_f32.obj (.text)
    000091d4 00000034 : cos_f32.obj (.text)
    00009208 00000034 : sin_f32.obj (.text)
    0000923c 00000029 rts2800_fpu32.lib : exit.c.obj (.text)
    00009265 00000024 : cpy_tbl.c.obj (.text)
    00009289 00000021 rts2800_fpu32_fast_supplement.lib : sqrt_f32.obj (.text)
    000092aa 0000001d rts2800_fpu32.lib : memcpy.c.obj (.text)
    000092c7 00000019 : args_main.c.obj (.text)
    000092e0 00000019 rts2800_fpu32_fast_supplement.lib : div_f32.obj (.text)
    000092f9 00000009 rts2800_fpu32.lib : _lock.c.obj (.text)
    00009302 00000008 CodeStartBranch.obj (.text)
    0000930a 00000002 rts2800_fpu32.lib : pre_init.c.obj (.text)
    0000930c 00000001 : startup.c.obj (.text)
  • Hi Ivan,

    Can you help me to understand what's wrong with the .map file please? The fastRTS library only replaces a sub-set of those functions in the rts2800_fpu32.lib. Those functions are listed in chapter 6 of the user's guide.

    All the functions I would expect to have been linked from the fast RTS library are there:
    atan_f32
    cos_f32
    sin_f32
    sqrt_f32
    div_f32

    The other functions come from the standard FPU RTS as expected. I don't see anything in the .map list which should have been replaced by a fast RTS function, and hasn't been. What am I missing?

    Regards,

    Richard
  • Hi Richard,

    Thanks for your time. I can also see that some of the functions use fastRTS, like atan, cos, sin... And I know that not all floating point calculations are covered by fastRTS.

    My confusion is according to SPRCA75, section 3.4, p10. "If the fastRTS library is linked in first, you will see something like the listing below. Notice the atan, cos, sin, sqrt and division functions are all coming from the fastRTS library."

    So my understanding is rts2800_fpu32_fast_implemtation.lib should come first in map file, as in the below picture.

    However, in the .map generated by me in the above post, the rts2800_fpu32.lib comes first, as you can see from the second line. Please note in the following picture, the rts2800_fpu32.lib is in the third line.

    So my questions are:

    (1) With the .map file in my project, is it using fastRTS or normal RTS? 

    (2) what is "rts2800_fpu32.lib:boot.obj" doing? Does it mean that I am linking normal RTS first?

    (3) Is there any other way to check whether I am using fastRTS or normal RTS?

    Thank you so much.

  • Hi Ivan,

    (1) With the .map file in my project, is it using fastRTS or normal RTS?
    - It is using both. Those functions supported by fastRTS are linked from the fastRTS library, all other functions are linked from the standard RTS library. The order of the sections is immaterial. They are sorted by linked address, not by which file is processed first by the linker.


    (2a) what is "rts2800_fpu32.lib:boot.obj" doing?
    - This module contains code to set up the C environment when floating point is enabled. This is from the assembly language tools user's guide:

    8.11.1 Run-Time Initialization
    All C/C++ programs must be linked with code to initialize and execute the program, called a bootstrap
    routine, also known as the boot.obj object module. The symbol _c_int00 is defined as the program entry
    point and is the start of the C boot routine in boot.obj; referencing _c_int00 ensures that boot.obj is
    automatically linked in from the run-time-support library. When a program begins running, it executes
    boot.obj first. The boot.obj symbol contains code and data for initializing the run-time environment and
    performs the following tasks:
    • Sets up the system stack and configuration registers
    • Processes the run-time .cinit initialization table and autoinitializes global variables (when the linker is
    invoked with the --rom_model option)
    • Disables interrupts and calls _main
    The run-time-support object libraries contain boot.obj. You can:
    • Use the archiver to extract boot.obj from the library and then link the module in directly.
    • Include the appropriate run-time-support library as an input file (the linker automatically extracts
    boot.obj when you use the --ram_model or --rom_model option).


    (2b) Does it mean that I am linking normal RTS first?
    - No.


    (3) Is there any other way to check whether I am using fastRTS or normal RTS?
    I don't think so. If you see sections linked from "rts2800_fpu32_fast_supplement.lib" in your .map file you know that fastRTS is in use.  If there is no reference to "rts2800_fpu32_fast_supplement.lib" , it is not in use.  This is the significance of the two screen captures in your last post.


    What you are doing is correct. Your code is being built with fastRTS functions.  I hope this helps.  Feel free to post back if anything is still unclear.  

    Regards,

    Richard

  • Thank you for your kind explanation. It is quite clear now. One further point on how to check whether the fastRTS or normal RTS is in use.

    I also find that with the above mentioned TI example of fastRTS. If I put the linker order in the correct way, it will step to the second line if I press F5. However, if I deliberately put the linker order by putting normal RTS first, and press F5, it will step to the following sub-function in s_atanf.c. After it finishes the sub-function, it then goes back to the next line in my code.

    Can this act as the difference of using normal RTS or fasterRTS? Is calling s_atanf.c the way it should be for normal RTS?

    float
    atanf(float x)
    {
     float w,s1,s2,z;
     int32_t ix,hx,id;
     GET_FLOAT_WORD(hx,x);
     ix = hx&0x7fffffff;
     if(ix>=0x4c800000) { /* if |x| >= 2**26 */
         if(ix>0x7f800000)
      return x+x;  /* NaN */
         if(hx>0) return  atanhi[3]+atanlo[3];
         else     return -atanhi[3]-atanlo[3];
     } if (ix < 0x3ee00000) { /* |x| < 0.4375 */
         if (ix < 0x39800000) { /* |x| < 2**-12 */
      if(huge+x>one) return x; /* raise inexact */
         }
         id = -1;
     } else {
     x = fabsf(x);
     if (ix < 0x3f980000) {  /* |x| < 1.1875 */
         if (ix < 0x3f300000) { /* 7/16 <=|x|<11/16 */
      id = 0; x = ((float)2.0*x-one)/((float)2.0+x);
         } else {   /* 11/16<=|x|< 19/16 */
      id = 1; x  = (x-one)/(x+one);
         }
     } else {
         if (ix < 0x401c0000) { /* |x| < 2.4375 */
      id = 2; x  = (x-(float)1.5)/(one+(float)1.5*x);
         } else {   /* 2.4375 <= |x| < 2**26 */
      id = 3; x  = -(float)1.0/x;
         }
     }}
        /* end of argument reduction */
     z = x*x;
     w = z*z;
        /* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */
     s1 = z*(aT[0]+w*(aT[2]+w*aT[4]));
     s2 = w*(aT[1]+w*aT[3]);
     if (id<0) return x - x*(s1+s2);
     else {
         z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x);
         return (hx<0)? -z:z;
     }
    }
  • Hi Ivan,

    Sorry - I just noticed you asked a follow-up question.

    The sub-function in your last post is in the standard RTS source so if it's being executed when you call atan(), the linker is not pulling in fastRTS.
    To determine which library is actually in use it's always best to look for signs of "fpu32_fast_supplement" in the SECTION ALLOCATION MAP in your .map file. You should see an entry like this:
    0000aab1 0000004a rts2800_fpu32_fast_supplement.lib : atan_f32.obj (.text)

    Regards,

    Richard