I am troubled by the optimization of the Ti 6000 series DSP. I would like to sum up my optimization experience and hope to help you.
I. First, we should consider optimizing the system structure. For example, we should try to reduce unnecessary migration of data to be processed, and consider optimizing the system structure of your DSP disk memory and the amount of data processed each time, this part of optimization should be implemented as early as possible;
2. Starting from the algorithm layer, check whether the algorithm is better and simpler, whether the algorithm has some symmetry, and whether a more suitable data structure can be used, this optimization is more obvious than program optimization;
3. If there is no better optimization method at the algorithm level, check whether the software structure can be optimized.
For example:
1) whether the multi-layer cyclic structure can be reduced. I often see such a program:
For (I = 0; I ++; I <)
For (j = 0; j ++ j <B)
{
E [I] [J] = C [I] [J]-d [I] [J];
}
This can be optimized:
For (I = 0; I ++; I <a * B)
{
E [I] = C [I]-d [I];
}
2) The conditions and jump commands in the key loop structure should be avoided as much as possible. Even if the number of loops increases, the conditional command optimizer in the loop is easier to optimize;
3) do not call subfunctions in key Loops
For more information, see the manual.
4. hardware structure optimization based on DSP System
1) check whether the data you are processing is stored on or off the chip. If the data is stored off the chip, we recommend that you batch import the data into the slice for processing, similar to the flow structure;
2) L2 cache can be optimized for external data
5. Optimizing with DSP optimizer and Command System
This part can be detailed in TI's manual. There are several methods:
1) Optimization Options,-O3-PM cancel-G and so on. If your software structure is good, their optimization effect is obvious;
2) add some optimization indicators to guide optimization. Read this manual, including storage address independence and SIMD (single-instruction multi-data processing;
3) some special commands, such as the saturation addition and overflow reduction commands provided by 6000, do not need to be judged by conditions;
4) if the effect is still not good, use linear assembly to rewrite your program and express your optimization ideas in linear assembly. Generally, it is enough;
5) If linear assembly optimization does not show your optimization ideas, compile it. The optimizer will no longer help you to optimize it. It is entirely your own control program;
This part requires a wealth of optimization experience and solid optimization skills, a lot of accumulation, read more information.
PS:
The Optimization of the system structure needs to be considered in the solution phase, mainly in hardware and data flow!
Algorithms are very important. It is best to have a general understanding of algorithms for optimization. Sometimes a change in implementation will help you optimize a lot.
Even if you do not optimize the algorithm itself, it is helpful to understand the algorithm and optimize the program.
I switched from assembly to C. When I optimized C, I found that the understanding of Assembly commands is very helpful for optimization,
If you have time, you can look at assembly commands, especially 64-core DSPs. Many Packaging Commands and SIMD commands are very helpful for Program-level optimization.
You don't need to write assembly, just write linear assembly, and you don't need to arrange parallelism, which saves a lot of effort than assembly.
I try to use C for optimization now, and then look at the disassembly instruction. If I am not satisfied, write a linear assembly. Generally, this step is almost the same.
You can also take a look at the optimization code of Ti imglib. Ti provides more, and you will get more!
Finally, we should focus on the following:
There is no end to optimization. Before careful optimization of the program, we need to test the time of each part of the program and optimize the very time-consuming part. Once it meets your requirements, we can, don't optimize for optimization. We should have more important things to learn. Don't get stuck in optimization and cannot extricate yourself !!