140 9. CODE OPTIMIZATION
L9 LAB 9:
CODE OPTIMIZATION
e purpose of this lab is to experiment with the optimization steps discussed above. ese steps
include changing compiler settings, writing efficient code constructs, and using architecture-
specific instructions for the ARM processor. e FIR filtering (linear convolution) example is
considered as a model case to show the effects of these steps on the real-time throughput.
Consider a lowpass filter whose passband covers the human vocal frequency range. e
specification used to generate the filter in MATLAB is as follows.
rpass = 0.1; %passband ripple
rstop = 20; %stopbad ripple
fs = 48000; %sampling frequency
f = [3000 3570]; %frequency bands
a = [1 0]; %desired amplitudes
dev = [(10^(rpass/20)-1)/(10^(rpass/20)+1) 10^(-rstop/20)]; %deviations
[n,fo,ao,w] = firpmord(f,a,dev,fs); %estimate
B = firpm(n,fo,ao,w); %compute coefficients
e above MATLAB code produces the coefficient array B containing 128 coefficients. e
shell for this lab provides the timing and linear convolution functions.
L9.1 COMPILER OPTIONS
Using the filter specified above and a sampling rate of 48 kHz, run the filter by enabling different
optimization levels and report the processing times achieved. Use the recording function and
wait until the reported frame time stabilizes, or use a sufficiently long test signal ( 20 s) and
record the processing time for the signal.
L9.2 TARGET ARCHITECTURE (ANDROID ONLY)
Using a target smartphone which supports armeabi-v7a, enable the abiFilter for armeabi-v7a
in the ndk section of the build.gradle file and enable the hardware floating-point by setting the
cflags to -mfloat-abi=softfp -mfpu=neon-vfpv4 -O3 and re-run the experiment. Com-
pare the processing time obtained with armeabi vs. armeabi-v7a.
L9.3 CODE MODIFICATION
Implement the linear convolution algorithm using the discussed pointer manipulation technique
and report the processing time. Compare the processing time when using floating-point values
for the filter coefficients with the processing time when using double precision format for the
filter coefficients. is can be done by changing the data type of the coefficient storage array.
For these experiments, use the O3 compiler optimization setting.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.218.215