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: Optimization problem

Tool/software: TI C/C++ Compiler

Hello,

In my project I have a C6457 DSP clock of 1200 MHz which runs code from internal memory.

I use Code Composer 3.3.82.13

Code Generation tool 6.1.20

DSP Bios 5.33.06

I have some instruction code in a C function written as follows:

       info_prf.TxLen               = QE2dRt.CurrSeq.prf_tx;
       info_prf.RxLen              = QE2dRt.CurrSeq.prf_rx;
       info_prf.RxOffset           = QE2dRt.CurrSeq.offs_rx;
       info_prf.SafeGateLen     = QE2dRt.CurrSeq.safegate_time;

where info_prf and QE2dRt are structured variables in internal memory.

Compiler optimization generates a code which results in crash during real time execution. That is a systematic error. It seems that the variable assignments are not correctly translated.

If I introuce some  asm(" NOP") operation after each assignment then no problem with the same optimization. Same result with no nop code and no optimization.

The file compiler options are -o2, Far aggregate memory model, Aliasing = default, interrupt threshold 2048, turn off software pipelininig. Other options are as default

Did I wrong in something? Same code in c6452 results in no problems. Did I miss some note on c6457 compiler optimizer?

Thank you in advance

Francesco

  • Domenico Logozzo said:
    Same code in c6452 results in no problems.

    I presume the exact same executable .out file runs correctly on a C6452 system, but fails on a C6457 system.  If that presumption is correct, then this is not a compiler problem.  The root cause of the problem must be elsewhere.  Maybe the system configuration, memory timing, or some HW specific detail like that.  If that is the case, then I recommend you take up the problem in the C6400 device forum.  Or, if you prefer, I can move this thread into that forum.

    Thanks and regards,

    -George

  • Hello George,

    Today I have compared the assembly generated from compiler for the 2 projects (C6457 and C6452).

    I have seen some differences between the 2 files so I decided to investigate about differences in compiler option for the 2 projects.

    I have discovered that in the C6457 project I had an advanced option activated:  "Turn Off Software Pipelininig (-mu)" while in the other project it was not checked.

    Unchecking that compiler option resulted in a perfect execution with no errors!

    Indeed I thought that activating that option (i.e. turning off software pipeline) should generate a more "relaxed" compilation...

    Do you have an explaination about this strange behaviour?

    Thanks!

  • A loop that is software pipelined runs around 20-30 times faster than a loop that is not software pipelined.  Using -mu made your code run much slower.  You were probably missing some deadlines.  

    The option -mu is used only to debug problems.  On rare occasions, using -mu on one file can help diagnose a larger problem.

    Thanks and regards,

    -George

  • Ok George I think I have understood the meaning of the -mu option and the effects on execution. From your explaination I think I should worry because that unintentional use of the compiler switch probably is showing a more general problem.  Isn't it? But what it is not clear is why (when option is activated) it's just enough to insert some nop operation between those code lines, to avoid the incorrect execution...

    Best regards,

    Franco

  • You are saying that these assignment statements ...

    Domenico Logozzo said:
           info_prf.TxLen               = QE2dRt.CurrSeq.prf_tx;
           info_prf.RxLen              = QE2dRt.CurrSeq.prf_rx;
           info_prf.RxOffset           = QE2dRt.CurrSeq.offs_rx;
           info_prf.SafeGateLen     = QE2dRt.CurrSeq.safegate_time;

    ... execute incorrectly when you build with -mu.  Since -mu disables software pipelining, it should have no effect on these assignments.  Adding asm(" NOP"); between each statement causes correct execution.

    Please carefully define what incorrect execution means in this case.  Do the wrong values get copied?  Or what?

    Thanks and regards,

    -George

  • When I told about incorrect execution I meant that the info_prf structured variable had bad values after those field assignements if compiled with the -mu compiler option.

    And that doesn't happen if I insert asm("nop") instructions after each assignement (maintaining the -mu compiler option). If I turn off the -mu option the execution is

    correct even without the nop instructions.

    Thanks again for your contribute and regards,

    Franco

  • That's very odd.  The problem assignment statements, are they in a loop?

    -George

  • I agree with you! No loop... simple sequential instructions.

    That's why I thought it could be a bug in compiler (code generation tool v6.1.20) originated by -o2 optimization switch (my current optimization option) and -mu advanced compiler option...

    Franco

  • Well, then, this looks like some sort of bug in the compiler.  I'd appreciate if you send us a test case which allows us to investigate.  For the source file which contains the problem assignments, please submit a test case as described in the article How to Submit a Compiler Test Case.  We'll use that test case to compile your code down to assembly.  In many cases, we can spot the problem in the assembly code.

    Thanks and regards,

    -George