Compiling UFRaw on Linux using profiling for better performance

From UFRaw

Jump to: navigation, search

Background

Current Gcc compilers give the possibility to include profiling instrumentation in the generated code (option -fgenerate-profile). This extra code gathers statistics about the behaviour of the program when it is run. Later the program can be compiled again, and the compiler can use the statistics to better optimise the generated code (option -fuse-profile). In some cases (tight loops etc.) this can lead to great improvements in performance.

Another way to improve the performance of UFRaw is to instruct the compiler to generate code for the specific processor architecture you are using (this of course means that the compiled binary may not work on other machines with a different processor). With the current Gcc this happens with the option -march=native.

The script

Below is a script to automate the compilation process. You may have to edit it to suit your purposes. Currently it compiles UFRaw with profile generation, runs it several times (using a raw image ../test.nef, you should of course edit the script to use an image of your choice). Then it recompiles UFRaw using the generated profiling information.

#!/bin/bash

NEF="../test.nef"
TIFF="../test.tif"

# Common options for running the profiling runs
UFRAW="./ufraw-batch --wavelet-denoising-threshold=30 --out-type=tiff8 --overwrite"

# Add/remove options to configure, if necessary
CONFIGURE="./configure --enable-extras --with-exiv2"

echo "Running autogen..."
sh autogen.sh

# I use CC and CXX for older versions of UFRaw which did not allow C(XX)FLAGS to be overridden
# Generate code for the machine's native architecture, generate profiling info
export CC="gcc -march=native -fprofile-generate"
export CXX="g++ -march=native -fprofile-generate"
echo "configuring..."
$CONFIGURE
echo "making with profile-generate..."
make

for restore in clip lch hsv
do
  echo $UFRAW --restore=$restore --exposure=-1 $NEF
  $UFRAW --restore=$restore --exposure=-1 $NEF
  rm $TIFF
done

for clip in digital film
do
  echo $UFRAW --clip=$clip --exposure=1 $NEF
  $UFRAW --clip=$clip --exposure=1 $NEF
  rm $TIFF
done


for interpolation in eahd ahd vng four-color ppg bilinear
do
  echo $UFRAW --interpolation=$interpolation $NEF
  $UFRAW --interpolation=$interpolation $NEF
  rm $TIFF
done

make clean
# Generate code for the machine's native architecture, use profiling info
export CC="gcc -march=native -fprofile-use"
export CXX="g++ -march=native -fprofile-use"
echo "configuring..."
$CONFIGURE
echo "making with profile-use..."
make
rm *.gcno *.gcda
Personal tools