Intel® Integrated Performance Primitives (Intel® IPP) for Linux* - Optimizing JPEG coding in the Ksquirrel application with Intel® IPP

Please notes,  more update regarding JPEG Codec are intergated UIC.  For performance data, please refer to JPEG sample and performance FAQs and  the Forum U81115


Overview

This Application Note illustrates steps to optimize the performance of JPEG coding in Linux* KDE image viewer application Ksquirrel using Intel® Integrated Performance Primitives (Intel® IPP) sample code.

"KSquirrel is an image viewer for KDE with disk navigator, file tree, thumbnails, extended thumbnails, dynamic format support, DCOP interface and tools to resize, rotate, convert, colorize and print images." Information about Ksquirrel can be found at Ksquirrel† website

This guide was created for the following product releases:

  • Intel Integrated Performance primitive (Intel IPP) 5.2 for Linux
  • Intel IPP sample code for JPEG coding: l_ipp-samples_p_5.2.036
  • Linux Ksquirrel application: ksquirrel-libs-0.6.3 and ksquirrel-0.6.3

This Application Note covers both IA-32 and Intel64 applications. The configuration steps below provide separate instructions for each application.


Downloading Ksquirrel source code

Ksquirrel source code is available at Ksquirrel download page† . Please note both Ksquirrel library and Ksquirrel application need to be downloaded from website.

Please note that OpenGL libraries and headers, GLU headers, KDE 3.3x† , QT 3.3x† are required to build the Ksquirrel application, please refer to the Ksquirrel† website for Ksquirrel building requirement.

Hardware: This Application Note has been tested on Intel® Core®2 Duo processors.

Software: This Application Note applies to use of the Intel® C/C++ Compiler 10.0 for Linux* and GCC 3.4.6 Compiler, RedHat* Linux AS EL 4.


Configuration

Step 1: Building Intel® IPP optimized IJG sample.

  1. Set up your build environment for Intel IPP and Intel C/C++ Compiler. Please Note: If you are using GCC Compiler, you can skip the step to set environment for Intel C/C++ Compiler.
    32 bit Application:
    # source /opt/intel/ipp/5.2 /ia32/tools/env/ippvars32.sh
    # source /opt/intel/cc/10.0/bin/iccvars.sh
    Intel 64 bit application:
    # source /opt/intel/ipp/5.2 /em64t/tools/env/ippvarsem64t.sh
    # source /opt/intel/cce/10.0/bin/iccvars.sh

  2. Run the build script.
    # cd ipp-samples/image-codecs/ijg
    #./build32.bat ( or buildem64t.bat for 64 bit application)
  3. Run JPEG benchmark application and verify that the Intel IPP sample code has been successfully built.
    # cd bin/linux32 (or bin/linuxem64t for 64 bit application)
    #./ijg_timing –all
  4. Copy the Intel IPP IJG library to system library path:
    #cp libjpeg.ipp.so /usr/lib (or /usr/lib64 for 64 bit applications)

Step 2: Modifying Configuration files

  1. Configuration ksquirrel-libs-0.6.3 sources
    32 bit Application:
    # tar jxfv ksquirrel-libs-0.6.3.tar.bz2
    # cd ksquirrel-libs-0.6.3/
    # ./configure.gnu
    Intel 64 bit application:
    # tar jxfv ksquirrel-libs-0.6.3.tar.bz2
    # cd ksquirrel-libs-0.6.3/
    # ./configure.gnu --libdir=/usr/lib64
  2. Configuration ksquirrel-0.6.3 sources
    32 bit Application:
    # tar jxfv ksquirrel-libs-0.6.3.tar.bz2
    # cd ksquirrel- 0.6.3/
    # ./configure.gnu
    Intel 64 bit application:
    # tar jxfv ksquirrel-0.6.3.tar.bz2 # cd ksquirrel- 0.6.3/ # ./configure.gnu --libdir=/usr/lib64
  3. Edit ksquirrel Makefile. Go to ksquirrel-0.6.3/ksquirrel. Add “ –ljpeg.ipp ” linking flag into “LDFLAGS” in the Makefile. This linking flag will replace Linux JPEG library with IPP Library.
    # cd ksquirrel-libs-0.6.3/ksquirrel
    # Edit Makefile for LDFLAGS: LDFLAGS = -lGL -lSM –lICE … –ljpeg.ipp

Step 3: Changing Source Code

In order to record JPEG performance, you can modify some parts of the Ksquirrel source code. This is an optional step. The Ksquirrel application records all the image load time (including image decoding time, resizing time and display time). The following modification can help record JPEG decode performance.

SQ_GLWidget::slotDecode() function in /ksquirrel-0.6.3/ksquirrel/sq_glwidget.cpp need changed. Attached is a modified code for ksquirrel-0.6.3.

Before:
1976: QTime started;
After:

1976: QTime started, jpegtime;

1977: int timeall=0, jsecs=0;

< /table>
Before:
fmt_read_scanline(next + pp.realw*j); ……. 2125 } ">

2117 for (j = 0; j< titleSize; j++)

2118 {

……

2125 }

After:
P>2118 jpegtime.start()

2119 for (j = 0; j< titleSize; j++)

2120 {

…….

2127 }

2128 timeall=timeall+jpegtime.elapsed()

Before:

2189 QString r=(secs) ? i18n("Loaded in %1'%2 ms.").….

2190 SQ_GLView::window()->sbarWidget("SBLoaded")->setText®;

After:

2192 QString r = (secs) ? i18n("Loaded in %1'%2 ms.").arg(secs).arg(msecs) : i18n("Loaded in %1 ms.").arg(msecs);

2193 adjustTimeFromMsecs(jsecs, timeall);

2194 QString js =(jsecs) ? i18n("JPEG Decode in %1'%2ms.").arg(jsecs).arg

(totaltime) : i18n("JPEG Decode %1 ms.").arg(totaltime);

2195 SQ_GLView::window()->sbarWidget("SBLoaded")->setText(r+js);


Building the application

Build ksquirrel-libs:

# cd ksquirrel-libs-0.6.3/
# make
# su -c 'make install'

Build Ksquirrel:

# ksquirrel-0.6.3/
# make
# su -c 'make install'

Running the application

By default, the Ksquirrel application is installed at /usr/bin. Use “/usr/bin/Ksquirrel” command to run the application. By default, Intel IPP dynamical libraries are linked with the application. Intel IPP dynamic libraries must be on system's path. This can be done by invoking the appropriate batch file. For example, for IA32, you can use the following common to run the application:

#source /opt/intel/ipp/5.2/ia32/tools/env/ippvars32.sh
#/usr/bin/Ksquirrel

When displaying a JPEG image in Ksquirrel, the image windows will display the time to load the image (see attached picture). If you have modified the code by following the step 3 in Configuration the image window will also display the JPEG decoding time, which can be used to measure IPP optimized IJG performance.


Appendix A - Performance comparison

Intel IPP JPEG functions are highly optimized for the multi-core capabilities of new Intel Core 2 Duo processors. The table below shows that, for Core 2 Duo processors, Intel IPP based IJG sample performs always faster than Linux* JPEG libraries in Ksquirrel application.

Image Size Loading Time(ms) JPEG Time(ms) IJG/ IPP-IJG
IJG IPP-IJG IJG IPP-IJG
image1_4k.jpg 4096x4096 726 618 453 343 1.32x
image1_1k.jpg 1024x1024 143 140 23 17 1.35x
image1_800.jpg 800x600 156 149 15 11 1.36x
image1_640.jpg 640x480 123 116 15 7 1.36x
image1_320.jpg 320x240 58 57 2 2 1.11x

(Tests run on Intel Core 2 Duo 2.13GHZ processors, 1.0GB RAM memory , Red Hat Enterprise Linux AS Release 4 and Intel IPP 5.2. The test JPEG files are sample images with Intel® IPP JPEG samples, which can be downloaded in Intel® Premier Support website under "Intel® IPP Sample" product.


Appendix B - Verifying correctness

The following steps can be used to verify the correctness:

  1. Check if Ksquirrel application uses on Intel IPP IJG library, not the default Linux JPEG
    library:#ldd /usr/bin/ksquirrel
    libjpeg.ipp.so => /usr/lib/libjpeg.ipp.so (0x00b77000)
    libippi.so.5.2 => /opt/intel/ipp/5.2/ia32/sharedlib/libippi.so.5.2
    ……
  2. Run Ksquirrel application and view some JPEG image files. The image should be correctly displayed and performance date can be found.

Appendix C - Known issues and limitations

The performance improvement obtained by using Intel IPP reduced for very small images, e.g. images of 100 pixels x 100 pixels or less.


Appendix D - References


This link will take you off of the Intel Web site. Intel does not control the content of the destination Web Site.

Operating System:

Red Hat* Linux, SUSE* Linux

Optimization Notice in English

有关编译器优化的更完整信息,请参阅优化通知