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.

I can't optimize my software. What is my error?

Other Parts Discussed in Thread: TMS320DM643

Hello to all.

I'm a begginer programer of DSP. It is my first program and I can't do that it run more fast.

My program is a OCR. It run in a PC in 300 milisecond. I have re-write the code for TMS320DM643 micro.  in the TMS320DM643 my OCR run in 9 seconds.

I have been reading in the foro an manuals and I understand that I should be optimizing the code.

I'm using the "TMS320C6000 Programmer's Guide" for optimizing it but I haven't improve.

Can you help me? What can I try for optimize it?

Thank you.

PD.Sorry for my bad inglish

  • If you have a lot of code/data in external memory then you cache settings will actually have much more of an impact than the optimization.  The following article describes how to properly enable cache on a 64x+ DSP.  The DM643 is actually a 64x DSP not a 64x+ DSP, but the procedure is nearly identical.

    http://wiki.davincidsp.com/index.php?title=Enabling_64x%2B_Cache

    For optimizing the code just go to your project settings and set the optimization level to -o3.  You need to turn off debug (-g) in order to get the full beneft, but don't do that until everything is working as you expect from a functional perspective.

    Brad

  • Thank you Brad.

    I enable cahe on and programs is mos fast but it isn't sufficient.

    I'm trying to set the optimization level to -o3.

    I have many warnings when I build the program whit -o3 options. The warnings message is "Warning - INLINE recursion limit exceeded."

    Do you know this message? What is the cause for this message?

    Thank you.

  • Emilio Rodriguez said:
    I have many warnings when I build the program whit -o3 options. The warnings message is "Warning - INLINE recursion limit exceeded."

    Do you know this message? What is the cause for this message?

    This warning just means that the compiler was trying to inline functions that get called too deeply, not necessarily just recursive calls, I believe the limit is a depth of 10 though this may vary on different compiler and target versions. For example if you had a function that the optimizer was attempting to inline that contains a call that is inlined, and that call contained a call that is inlined, and so on to a depth greater than the tools can handle. When the limit is reached, inlining will be disabled for further calls to the function called at the point of the warning, but compilation will otherwise continue unaffected. Essentially this just means the compiler gave up inlining something that did not reach a finite inline length soon enough, so nothing is wrong with the code, though potentially some performance could have been lost due to the lack of inlining in these extreme cases. You could avoid these by constructing the code to not have as many calls within calls or to avoid recursion, though if you just want to get rid of the warning (ignore it) you can use the -pdr option in your build to supress warnings.

  • Please post your complete compiler options as seen in the top of the box when you go to Project -> Build Options.

  •  

    Hi to all.

    Brad Griffis said:

    Please post your complete compiler options as seen in the top of the box when you go to Project -> Build Options.

    My compiler options are: -k -o3 -fr"$(Proj_dir)\Debug" -d"_DEBUG" -d"CHIP_DM642" -mt -mv6400

    I ignored the inline warning how posted Bernie.

    I have get to build my program with -o3 optimization level but it is still slow.

    I read  in the forum about -k option and the information in the .asm files.

    In my .asm file I have noticed that the pipeline don't work in many functions.

    To do it more easy, I have decided build function to function, and the first function with problems is a loop with a fread. This function is very simply. I paste here this code:

    bool CObjeto::Lee(CFoto &I)
    {
        std::FILE *punteroAFichero;
        bool resultado = false;
        uint8 *iter;

        if( (punteroAFichero = fopen("foto.raw","rb"))!= NULL)
        {
            fread(&X,sizeof(uint16),1,punteroAFichero);  // X is a uint16 atribute of the class CObjeto
            fread(&Y,sizeof(uint16),1,punteroAFichero); // Y is a uint16 atribute of the class CObjeto
            I.resize(X,Y,1,1);
            iter = I.begin(); 
            for (uint32 i = 0; i < X * Y; i++,iter++) 
                fread(iter,sizeof(uint8),1,punteroAFichero);

            resultado = true;
            fclose(punteroAFichero);
        }
        else
        {
            resultado = false;

        }

        return resultado;
    }

     

    I have been used fread for the moment. In the future when the progrmas is finished I will read this values of another way.

    I think that this function don't work with pipeline because fread have to read of my hard disk by usb-emulator.It is the true? or is possible optimized this function?

     

    Very thanks.

     

  • In general C i/o functions like printf or fread will be very slow on an embedded system like this, they have a lot of overhead, and if you are transferring large files you are also being limited on your emulator's bandwidth. If you have algorithmic functions that you want to find the performance of outside of the development environment you would need to read in (fread) the data from the host's file seperately which could take an arbitrarily large amount of time, and than once it is all on the target run your algorithms through it to measure their performance. If you can seperate the loading from the execution like this than you can get a better idea of what a real world execution time would be like, but if you are always calling fread your application will appear to be slower than if the data were otherwise available, such as if the data was being fed in by a driver.