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.

Compiler/TMS320C6455: Optimization level and compiler concept

Part Number: TMS320C6455
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI C/C++ Compiler

Hi

CCS: 5.3

DSP: C6455

OS: win7

SYS/BIOS: 7.4.1

I have some problems when I develope my program that I don't understand why they have happened.

I could solve them by try and errors but I didn't understand why they happened and what was the root of problems.

When I have a performance problem with my code (speed up) I increase the performance optimization level to -O3. When I profile the code I can see the code performs much faster but

I have several "*.c" files that I change the optimization level of some of them so in my project I have files with different optimization levels.

Q1

How should I use optimization levels for my files?

I have some strange problems that I think they are related to compiler problems that I explained below:

In my memory map, I reserved some L2 memory for HPI communication and other extra memory space (I named IRAM) is belong to OS(OS is responsible to fit all memory segments in IRAM section).

Sometimes when I declared a global variable only(without using in the code), after compile and load the program, my program didn't work!!! and there isn't any memory error!!!

or sometimes when I comment some part of code my program didn't work! again!! (the commented part didn't have an effect on my code, for example, I commented my logger peace of code ).

I can't interpret why those problems happened, I thought the problems related to the compiler.

Q2:

please, explain why those problems happened and how I must solve them?

Best Regards

  • It is OK to use different levels of optimization on different source files in the program.

    Unfortunately, the description of your problems is too vague.  At this point, nothing can be done.

    dariush karami said:
    Sometimes when I declared a global variable only(without using in the code), after compile and load the program, my program didn't work!!!

    How do you know the program didn't work?  What do you look at?  Exactly how do you measure it?

    Please narrow down the problem.  Try to find one small function which acts differently when you add a global variable.  Then focus on explaining what happened.

    Thanks and regards,

    -George

  • Hi

    How do you know the program didn't work?  What do you look at?  Exactly how do you measure it?

    I set the breakpoint at the beginning of threads and ISR function and the program didn't receive to the breakpoint and the communication between DSP and PC disconnected.

    Sometimes when I declared global variable and I didn't use it but the program didn't work!!!!!! 

    or sometimes when I comment some part of code my program didn't work! again!! (the commented part didn't have an effect on my code, for example, I commented my logger peace of code ).

    Especially in my "PC_Interface.c" file that contained the parser functions, encode and decode data frames(I set the optimization level O2) I saaw these kinds of problems more.

    I know with accurate debugging and by narrowing down the problem we can find problems and mistake in the code but those problems that I explained above are unordinary for me!!!!

    Please guide me.

    Best Regards

  • dariush karami said:
    SYS/BIOS: 7.4.1

    Do you mean c6000 compiler version 7.4.1?  All sysbios releases are 6.x.y version numbers.  If you are in fact referring to the compiler, the first and most critical step will be to update to the latest bug-fix release within that same 7.4.x branch.  The 7.4.1 release is from Aug 2012.  The most recent release is 7.4.24 from Feb 2018.  Moving from 7.4.1 to 7.4.24 is not expected to break anything in your code as there are no new features.  It does however fix MANY issues, some of which might very well be relevant to your issues.

    dariush karami said:

    In my memory map, I reserved some L2 memory for HPI communication and other extra memory space (I named IRAM) is belong to OS(OS is responsible to fit all memory segments in IRAM section).

    Sometimes when I declared a global variable only(without using in the code), after compile and load the program, my program didn't work!!! and there isn't any memory error!!!

    If you don't use a variable, it's expected that the compiler might remove it.  Is the unused variable related to your HPI communication?  I wasn't clear if those two paragraphs were connected.  If so, you are required to declare the variable as "volatile" to let the compiler know that the variable might be accessed outside its scope.

    Cache coherence is closely related to the HPI communication.  However, if your code is in the DSP's L2 RAM then the coherence will be handled automatically in hardware.  If however you relocate that code elsewhere (e.g. DDR) then you would need to add manual cache coherence operations.

    dariush karami said:
    I have several "*.c" files that I change the optimization level of some of them so in my project I have files with different optimization levels.

    If you use the "program wide optimization" it will exclude any files that have file-specific options.  So you could potentially be hurting overall optimization this way.

  • Hi 

    Thanks for your answers. I will upgrade the CGT to 7.4.24 and test it. As I described before, sometimes, I have strange problems that I could solve them every time by changing the optimization level but 

    I didn't understand why those problems produce and why they solved by optimization level!!!!

    Best regards