AN2094 Freescale Semiconductor / Motorola, AN2094 Datasheet - Page 9

no-image

AN2094

Manufacturer Part Number
AN2094
Description
ITU-T G.729 Implementation on StarCore SC140
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Manual inlining is recommended when several identical calls are made in sequence, and enables the programmer to
fully exploit potential parallelism. By replacing a function call with the C statements of the function, the
programmer places in parallel, by hand, the actions in the function by allocating different variables and performing
several consecutive identical calls on phases. This technique requires a working knowledge of the code to identify
where a small function is repeatedly called and which actions are executed in parallel. Manual inlining is also used
in assembly code.
Based on these rules, five functions in the vocoder project were inlined: Mpy32_16(), Mpy_32(), Div_32(),
L_Extract(), and L_Comp(). In most places the functions were inlined explicitly using the
#pragma inline
linkage generated no conflicts. In some places the functions were manually inlined.
In most cases, function inlining improves execution speed, and was the major source of speed optimization in this
phase of the project, yielding a reduction in required processing power of 4.6 million cycles per second (MCPS).
Typically, function inlining increases the code size. However, inlining actually decreased the code size in this
project, primarily because in many cases the code that placed the parameter on the stack could be removed.
2.3.2 Data Alignment
Data flow analysis and previous experience indicated that aligning frequently-accessed data structures would
improve performance. Data was aligned on all arrays to facilitate parallel data moves. Most StarCore-specific
optimization techniques require the use of multiple move operations.
For function parameters the alignment is declared using the
assert statement is used to prevent various problems caused by misaligned data. The use of these statements is
illustrated in Code Example 4.
void fct(Word16 *x)
{
#pragma align *x 8
}
The assert statement acts like a fuse by forcing the application to stop when parameters do not conform to special
alignment needs. It also generates the code line number where the assertion violation occurred, which streamlines
the debugging process.
In G.729, most vectors are composed of two parts—the historical part, which contains values computed in previous
steps, and the current part, which contains current values. The two parts are allocated as a single vector that is
accessed with two pointers—old_ptr points to the first value in the historical part, which is also the start address
of the vector, and new_ptr (or simply ptr) points to the first new value in the array. The second pointer is often
referred to as an internal pointer. Functions that operate on new values require that the data they use is aligned on
the internal pointer. The channel data structures were aligned so that each data structure and each vector in the data
structures were aligned on an 8-byte boundary. To align internal pointers, one of the following two techniques was
used:
Freescale Semiconductor
assert(((int) x & 7) == 0);
The relative start address of the vector in the data structure was displaced by padding or rearranging the
data.
Larger vectors were defined containing extra values that shift the data so that the internal pointer is
aligned.
C statements. As a result, every call of these functions was replaced by inline code, and the
ITU-T G.729 Implementation on the StarCore™ SC140/SC1400 Cores, Rev. 1
Example 4. Parameter Alignment With Assert
#pragma align *ptr
statement. In addition, the
Optimization Process
static
and
9

Related parts for AN2094