Information Technology Reference
In-Depth Information
root of every sample. The use of a look-up table to compute the square root would
look as follows:
double LUT sqrt [256]; /* presumably declared globally */
/* Somewhere in the Initialization code */
for (i = 0; i < 256; i++)
{
LUT sqrt[i] = sqrt(i);/* provided that < math.h/ >
was #included */
}
/* During the normal execution of the application */
result = LUT sqrt[sample]; /* instead of
result = sqrt(sample); */
During the initialization phase, the application sacrifices a certain amount of time
to compute all 256 possible results, but after that, when the system starts to read data
in real time, the system can complete the processing required in the time available.
17.6.2
Scaled Numbers
In almost all types of computing systems, integer operations are faster than floating
point operations. Because of this, floating point algorithms often are converted into
scaled integer algorithms. In this example, the least significant bit of an integer
variable is assigned a real-number scale factor. These scaled numbers then can be
added, subtracted, multiplied, or divided, and then converted back to floating point
numbers. However, it should be noted that accuracy may be sacrificed by excessive
use of scaled numbers.
17.7
COMPILER OPTIMIZATION TOOLS
Most types of code optimization techniques can be used in an effort to improve
the real-time performance of an embedded system. In this section, several optimiza-
tion techniques and their impact on real-time performance will be discussed. These
techniques are:
1. Reduction in strength
2. Common subexpression elimination
3. Constant folding
4. Loop invariant removal
5. Loop induction elimination
6. Dead code removal
7. Flow of control
 
Search WWH ::




Custom Search