Even in the era of gigahertz processors, it is hard to meet demanding performance and cost targets without tightly optimized code. For engineering managers with tight budgets, it is tempting to buy into the idea that creating efficient code requires nothing more than setting the appropriate compiler options. Unfortunately, this is rarely the case. Although the quality of compiler-generated code has improved in recent years, compilers address only part of the software optimization problem.
To obtain efficient code, signal-processing software must be optimized at four distinct levels. First, the overall software architecture must be designed to make efficient use of processor resources. This involves considerations such as how data flows among software modules.
Second, appropriate data types must be selected. If you use a data type that's larger than you really need (for example, 32 bits when 16 will do), you're wasting resources. On the other hand, if you use a data type that's smaller than you really need, your system is likely to malfunction.
Third, the software must be optimized at the algorithm level. For example, it is often possible to improve performance by combining multiple algorithms into a single processing step, or by substituting one algorithm for another. Such optimizations sometimes yield huge performance gains.
Ultimately, the software must be carefully mapped to the processor's instruction set and pipeline. This is where compilers can do great work, but still, the code is likely to be far from optimal unless a savvy human has first optimized the software at the three other levels.
And compilers can't meet the challenge of higher-level optimizations, which are becoming increasingly important as applications and processors become more complex.
Now, don't get me wrong. Good compilers are very important. It's vital to understand, however, that you still need a skillful programmer to get the job done right.
Jeff Bier, president of Berkeley Design Technology Inc. (www.BDTI.com), a consulting firm providing analysis and advice on DSP technology. Kenton Williston of BDTI contributed to this column