<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated on Fri, 25 May 2012 06:22:49 -0700 -->
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <atom:link href="http://software.intel.com/en-us/articles/open-source/type/technical-article/feed/" rel="self" type="application/rss+xml" />
    <title>Intel Software Network articles Feed</title>
    <link>http://software.intel.com/en-us/articles/open-source/type/technical-article/</link>
    <description></description>
    <language>en-us</language>
    <item>
      <title>How to build GCC* cilkplus branch in 64bit Ubuntu* 12.04</title>
      <description><![CDATA[ <div id="art_pre_template"><b>Introduction</b>:</div>
<div id="art_pre_template">Intel® Cilk™ Plus is an open source project now. It is supported in GCC* 4.7 but still not merged into the released GCC* 4.7.0 version. We can build the 'cilkplus' branch of GCC* to make it support the Intel® Cilk™ Plus extensions. The steps are exact same with building GCC* upstream code, so this article is targeted for those who are not familiar with building GCC and want to use Cilk Plus with GCC.<br /></div>
<div id="art_pre_template"><br /></div>
<div id="art_pre_template">(1) <b>Preparation</b></div>
<div id="art_pre_template">OS: Ubuntu* 12.04 LTS beta2 64bit.</div>
<div id="art_pre_template">Install following packages before building GCC Cilk Plus:</div>
<div id="art_pre_template">sudo apt-get install binutils<br />sudo apt-get install build-essential<br />sudo apt-get install m4<br />sudo apt-get install autogen<br />sudo apt-get install bison</div>
<div id="art_pre_template"><br /></div>
<div id="art_pre_template">(2) <b>Install gmp</b></div>
<div id="art_pre_template">1. download gmp (gmp-4.3.2.tar.bz2) from: <a href="ftp://gcc.gnu.org/pub/gcc/infrastructure/">ftp://gcc.gnu.org/pub/gcc/infrastructure/</a></div>
<div id="art_pre_template">2. compile and install gmp:</div>
<div id="art_pre_template">
<pre name="code" class="shell">sudo mkdir -p /opt/gmp-4.3.2
tar -jxvf gmp-4.3.2.tar.bz2
cd gmp-4.3.2
./configure --prefix=/opt/gmp-4.3.2
make &amp;&amp; make check &amp;&amp; sudo make install</pre>
Notes: It is recommended to run 'make check'.</div>
<div id="art_pre_template"><br /></div>
<div id="art_pre_template">(3) <b>Install mpfr</b></div>
<div id="art_pre_template">1. download mpfr (mpfr-2.4.2.tar.bz2) from same link as above.</div>
<div id="art_pre_template">2. compile and install mpfr:</div>
<div id="art_pre_template">
<pre name="code" class="shell">sudo mkdir -p /opt/mpfr-2.4.2
tar -jxvf mpfr-2.4.2.tar.bz2
cd mpfr-2.4.2
./configure --prefix=/opt/mpfr-2.4.2 --with-gmp=/opt/gmp-4.3.2
make &amp;&amp; make check &amp;&amp; sudo make install</pre>
Notes: You must install gmp before installing 'mpfr' as 'mpfr' depends on 'gmp'.</div>
<div id="art_pre_template"><br /></div>
<div id="art_pre_template">(4) <b>install mpc</b></div>
<div id="art_pre_template">1. download mpc (mpc-0.8.1.tar.gz) from same link as above.</div>
<div id="art_pre_template">2. compile and install mpc:</div>
<div id="art_pre_template">
<pre name="code" class="shell">sudo mkdir -p /opt/mpc-0.8.1
tar -zxvf mpc-0.8.1.tar.gz
cd mpc-0.8.1
./configure --prefix=/opt/mpc-0.8.1 --with-gmp=/opt/gmp-4.3.2 --with-mpfr=/opt/mpfr-2.4.2
make &amp;&amp; make check &amp;&amp; sudo make install</pre>
Notes: 'mpc' depends on 'gmp' and 'mpfr'.</div>
<div id="art_pre_template"><br /></div>
<div id="art_pre_template">(5) <b>build and install GCC with Cilk Plus</b></div>
<div id="art_pre_template">1. download the source code of 'cilkplus' branch. There are various ways to download it.</div>
<div id="art_pre_template">SVN:</div>
<div id="art_pre_template">The cilkplus-4_7-branch: <a href="http://gcc.gnu.org/svn/gcc/branches/cilkplus-4_7-branch/">http://gcc.gnu.org/svn/gcc/branches/cilkplus-4_7-branch/</a><br /></div>
<div id="art_pre_template">The cilkplus branch: <a href="http://gcc.gnu.org/svn/gcc/branches/cilkplus/">http://gcc.gnu.org/svn/gcc/branches/cilkplus/</a></div>
<div id="art_pre_template">GIT:</div>
<div id="art_pre_template">The GIT mirror: <a href="http://gcc.gnu.org/git/?p=gcc.git;a=shortlog;h=refs/heads/cilkplus">http://gcc.gnu.org/git/?p=gcc.git;a=shortlog;h=refs/heads/cilkplus</a></div>
<div id="art_pre_template">Here, I download the git mirror for cilkplus branch through browser directly. (The snapshot is 'gcc-0dfa790.tar.gz')</div>
<div id="art_pre_template"><br /></div>
<div id="art_pre_template">2. compile and install gcc cilkplus branch:</div>
<div id="art_pre_template">
<pre name="code" class="shell">export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/gmp-4.3.2/lib:/opt/mpfr-2.4.2/lib:/opt/mpc-0.8.1/lib
export C_INCLUDE_PATH=/usr/include/x86_64-linux-gnu &amp;&amp; export CPLUS_INCLUDE_PATH=$C_INCLUDE_PATH &amp;&amp; export OBJC_INCLUDE_PATH=$C_INCLUDE_PATH
export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu

tar -zxvf gcc-0dfa790.tar.gz
sudo mkdir -p /opt/gcc-4.7-cilkplus
mkdir gcc_cilkplu_build &amp;&amp; cd gcc_cilkplu_build
../gcc-0dfa790/configure --prefix=/opt/gcc-4.7-cilkplus --with-gmp=/opt/gmp-4.3.2 --with-mpfr=/opt/mpfr-2.4.2 --with-mpc=/opt/mpc-0.8.1 --disable-multilib --enable-languages=c,c++
make -j8
sudo make install</pre>
Notes:</div>
<div id="art_pre_template">(1) It is suggested to run 'configure' in a standalone foler instead of running it in the source tree of gcc cilkplus.</div>
<div id="art_pre_template">(2) 'make -j8', this step will build the source code, it will take quite a long time, you may change the argument of '-j' according to your system.</div>
<div id="art_pre_template"><br /></div>
<div id="art_pre_template"><br /></div>
<div id="art_pre_template">(6) <b>Create the 'gccvars.sh' script</b></div>
<div id="art_pre_template">This is optional, you may create a script to help to set the environment of the built gcc. Following is a reference for 'gccvars.sh':</div>
<div id="art_pre_template">
<pre name="code" class="shell"># filename: gccvars.sh
# 'source gccvars.sh' to set the environment of gcc
export C_INCLUDE_PATH=/usr/include/x86_64-linux-gnu:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=$C_INCLUDE_PATH
export OBJC_INCLUDE_PATH=$C_INCLUDE_PATH
export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LIBRARY_PATH

export GCCDIR=/opt/gcc-4.7-cilkplus
export PATH=$GCCDIR/bin:$PATH
export LD_LIBRARY_PATH=$GCCDIR/lib:$GCCDIR/lib64:/opt/gmp-4.3.2/lib:/opt/mpfr-2.4.2/lib:/opt/mpc-0.8.1/lib:$LD_LIBRARY_PATH
export MANPATH=$GCCDIR/share/man:$MANPATH</pre>
Notes: GCCDIR is the installed path of the built gcc.</div>
<div id="art_pre_template"><br /></div>
<div id="art_pre_template"><br /></div>
<div id="art_pre_template">(7) <b>Test Cilk Plus with GCC</b></div>
<div id="art_pre_template">To use cilk plus with gcc, you need to add '-lcilkrts' flag to the command line. See below test case for more details (it contains how to compile and the results):</div>
<div id="art_pre_template">
<pre name="code" class="cpp">// filename: test_cilkplus.cpp
// compile: g++ test_cilkplus.cpp -lcilkrts

#include &lt;stdio.h&gt;
#include &lt;unistd.h&gt;

#include &lt;cilk/cilk.h&gt;
#include &lt;cilk/cilk_api.h&gt;

void task(int i) {
    printf("task: %d, workder id: %d\n", i, __cilkrts_get_worker_number());
    sleep(1);
}

int main() {
    for(int i=0;i&lt;10;i++)
	    cilk_spawn task(i);
    cilk_spawn task(-1);
    cilk_sync;
    return 0;
}

/* compile and result:
#g++ test_cilkplus.cpp -lcilkrts
#./a.out 
task: 0, workder id: 0
task: 1, workder id: 1
task: 2, workder id: 2
task: 3, workder id: 0
task: 4, workder id: 1
task: 5, workder id: 2
task: 6, workder id: 0
task: 7, workder id: 1
task: 8, workder id: 2
task: 9, workder id: 0
task: -1, workder id: 1
#
notes: you can use 'export CILK_NWORKERS=N' to set the max workders of cilk plus runtime.
*/</pre>
</div>
<div id="art_pre_template">(8) <b>Resources for the Cilk Plus Open Source Project</b></div>
<div id="art_pre_template"><a href="http://software.intel.com/en-us/articles/intel-cilk-plus/">http://software.intel.com/en-us/articles/intel-cilk-plus/</a><br /><a href="http://software.intel.com/en-us/articles/intel-cilk-plus-open-source/">http://software.intel.com/en-us/articles/intel-cilk-plus-open-source/</a><br /></div> ]]></description>
      <link>http://software.intel.com/en-us/articles/how-to-build-gcc-cilkplus-brance-in-64bit-ubuntu-1204/</link>
      <pubDate>Sat, 14 Apr 2012 09:00:00 -0700</pubDate>
      <comments>http://software.intel.com/en-us/articles/how-to-build-gcc-cilkplus-brance-in-64bit-ubuntu-1204/#comments</comments>
      <guid isPermaLink="true">http://software.intel.com/en-us/articles/how-to-build-gcc-cilkplus-brance-in-64bit-ubuntu-1204/</guid>
      <category>Parallel Programming</category>
      <category>Open Source</category>
      <category>Intel® C++ Compiler for Linux* Knowledge Base</category>
    </item>
    <item>
      <title>Intel® AVX C/C++ Intrinsics Emulation</title>
      <description><![CDATA[ <p>Intel® AVX instruction set extension <a target="_blank" href="http://software.intel.com/en-us/avx/">[1]</a> will appear in the next generation Intel microarchitecture codename ‘Sandy Bridge'. We chose to announce AVX early to get as much support from software vendors as possible by the hardware launch time. Now, most software development platforms are supporting Intel AVX, examples are compilers and assemblers from Intel, Microsoft and GCC as well as UNIX binutils.</p>
<p>For early adopters we introduced support of AVX in Intel® Software Development Emulator <a target="_blank" href="http://software.intel.com/en-us/articles/intel-software-development-emulator/">[2]</a>, it allows you to run and check functional correctness of the code with the actual AVX instructions before hardware is available.</p>
<p>Today we are adding another useful piece to help those who may not be able to use new tools supporting AVX in their current development environment but plan to migrate in the future or are using a software platform which is not supported by Intel SDE. These software developers can still start programming with Intel AVX using intrinsics.</p>
<p>Here we are providing the C and C++ header file which emulates Intel AVX intrinsics. The AVX emulation header file uses intrinsics for the prior Intel instruction set extensions up to Intel SSE4.2. SSE4.2 support in your development environment as well as hardware is required in order to use the AVX emulation header file. <br /><br />To use simply have this file included:</p>
<p>#include "avxintrin_emu.h"</p>
<p>Instead of usual:</p>
<p>#include &lt;immintrin.h&gt;</p>
<p><br />One can also create alternative immintrin.h file (which in turn includes avxintrin_emu.h) to avoid an intrusive change to the source base and then simply switch between real AVX code generation and emulation via alternating the path to include directories.</p>
<p>Emulation header is primarily targeting UNIX type of environments, and was tested on such with GCC and Intel C/C++ compilers. We have a strong support with other tools (compilers, assemblers and SDE) on Microsoft Windows platform, but this header file can still be used on Windows, if desired, with Intel Compiler.</p>
<p>Note that the AVX emulation header file is designed to allow functional correctness of an AVX implementation and not recommended for long-term usage or release in a final product. Once your development environment and hardware supports AVX, we recommend that you switch to the real AVX intrinsic header file.<br /><br />Although we did our best to debug it, this file must <em>not</em> be considered a reference functional implementation of AVX instructions or even bug-free. Please see the current version's limitations and caveats in the beginning of the file. Please let us know about the issues you faced using it.</p>
<p><b><br />Example</b></p>
<pre name="code" class="cpp:nogutter:nocontrols">#include "avxintrin_emu.h"  // #include &lt;immintrin.h&gt;

void saxpy( float a, const float* x, const float* y, float* __restrict z, size_t len )
{
    size_t i = 0;
    __m256 a_ = _mm256_set1_ps( a );

    for ( size_t len16_ = len &amp; -16; i + 16 &lt;= len16_; i += 16 )
    {
        __m256 x1_ = _mm256_loadu_ps( x + i );
        __m256 x2_ = _mm256_loadu_ps( x + i + 8 );

        __m256 y1_ = _mm256_loadu_ps( y + i );
        __m256 y2_ = _mm256_loadu_ps( y + i + 8 );

        x1_ = _mm256_mul_ps( x1_, a_ );
        x2_ = _mm256_mul_ps( x2_, a_ );

        x1_ = _mm256_add_ps( x1_, y1_ );
        x2_ = _mm256_add_ps( x2_, y2_ );

        _mm256_storeu_ps( z + i     , x1_ );
        _mm256_storeu_ps( z + i + 8 , x2_ );
    }

    for ( ; i &lt; len; ++i )
        z[i] = x[i] * a + y[i];
}</pre>
<p><br /><strong><br />References </strong></p>
<p>[1] Intel AVX - <a target="_blank" href="http://software.intel.com/en-us/avx/">http://software.intel.com/en-us/avx/</a></p>
<p>[2] Intel Software Development Emulator - <a target="_blank" href="http://software.intel.com/en-us/articles/intel-software-development-emulator/">http://software.intel.com/en-us/articles/intel-software-development-emulator/</a></p> ]]></description>
      <link>http://software.intel.com/en-us/articles/avx-emulation-header-file/</link>
      <pubDate>Wed, 23 Jun 2010 00:00:00 -0700</pubDate>
      <comments>http://software.intel.com/en-us/articles/avx-emulation-header-file/#comments</comments>
      <guid isPermaLink="true">http://software.intel.com/en-us/articles/avx-emulation-header-file/</guid>
      <category>Parallel Programming</category>
      <category>Open Source</category>
      <category>What If Experimental Software</category>
      <category>Tools</category>
      <category>Intel® AVX</category>
      <category>Software News</category>
      <category>Code &amp; Downloads</category>
    </item>
    <item>
      <title>64-bit Loki</title>
      <description><![CDATA[ <b>
<p><a href="http://sourceforge.net/projects/loki-lib/">Loki Team</a> and <a href="http://www.viva64.com">OOO "Program Verification Systems"</a>.<br /> Andrei Alexandrescu, Andrey Karpov, Evgeniy Ryzhkov, Peter Kümmel, Rich Sposato.</p>
</b>
<h6>September  2009</h6>
<p> </p>
<div ><a href="http://software.intel.com#IDAIJMEE"><b></b></a><br />
<div ></div>
<a href="http://software.intel.com#IDAMJMEE"><b>Abstract</b></a><br />
<div ></div>
<a href="http://software.intel.com#IDAUJMEE"><b>Introduction</b></a><br />
<div ></div>
<a href="http://software.intel.com#IDAHKMEE"><b>Building of the 64-bit version of Loki in Microsoft Visual Studio 2005</b></a><br />
<div ></div>
<a href="http://software.intel.com#IDAVNMEE"><b>Testing of the 64-bit Loki version with the help of Viva64</b></a><br />
<div ><a href="http://software.intel.com#IDAAOMEE">1 Incorrectly used constant LONG_MIN</a><br /><a href="http://software.intel.com#IDAFYMEE">2 Some types of magic numbers - errors or not?</a><br /><a href="http://software.intel.com#IDADZMEE">3 Addition of int to a pointer as a potential error</a><br /><a href="http://software.intel.com#IDAL0MEE">4 Using int for indexing arrays is incorrect</a><br /><a href="http://software.intel.com#IDAT0MEE">5 Right arguments of functions</a><br /></div>
<a href="http://software.intel.com#IDAK1MEE"><b>Loki library is compatible with 64-bit systems - does it mean that we can say the same about a program using it?</b></a><br />
<div ></div>
<a href="http://software.intel.com#IDAU3MEE"><b>Conclusion</b></a><br />
<div ></div>
<a href="http://software.intel.com#IDAC4MEE"><b>Acknowledgements</b></a><br />
<div ></div>
<a href="http://software.intel.com#IDAS4MEE"><b>References</b></a><br />
<div ></div>
</div>
<h2><a name="IDAIJMEE"></a></h2>
<p> </p>
<h2>Abstract<a name="IDAMJMEE"></a></h2>
<p>The article is a report about testing of portability of Loki library with 64-bit systems with the help of Viva64 code analyzer performed by OOO "Program Verification Systems" Company. It contains recommendations for users of the library. The article will be also useful for the users of other libraries built on templates for it describes the peculiarities of analysis of such libraries.</p>
<p> </p>
<h2>Introduction<a name="IDAUJMEE"></a></h2>
<p>Loki library has been developed by Andrei Alexandrescu as part of the highly acclaimed book "Modern C++ Design: Generic Programming and Design Patterns Applied". An abstract of the book declares: "<i>This book introduces the concept of generic components-reusable design templates that produce boilerplate code for compiler consumption-all within C++. Generic components enable an easier and more seamless transition from design to application code, generate code that better expresses the original design intention, and support the reuse of design structures with minimal recoding."</i></p>
<p>OOO "Program Verification Systems" Company creating <a href="http://www.viva64.com/viva64-tool/">Viva64</a> code analyzer for developing 64-bit applications participates actively in communication with the authors of various software projects. Once one of Loki project administrators, Rich Sposato, asked us to check the code of the library for portability to 64-bit systems with the help of our code analyzer Viva64. The Loki library is known for using the most powerful and up-to-date abilities of C++ language; so if Viva64 managed Loki then it can easily manage simpler projects.</p>
<p>We should notice that this article is based on the Loki version of May 2009 (it is more modern than the official version of that time Loki 0.1.7), so the stated problems will be removed in further Loki versions.</p>
<p>So, we downloaded the latest version of Loki from the SVN repository on SourceForge and set to work.</p>
<p> </p>
<h2>Building of the 64-bit version of Loki in Microsoft Visual Studio 2005<a name="IDAHKMEE"></a></h2>
<p>Viva64 code analyzer integrates into Microsoft Visual Studio development environment, that's why it would be sensible to build a version of Loki for this particular environment. Loki package contains ready files of solutions for Visual Studio 2005 and Visual Studio 2008. But now, in May 2009, these solutions contain only 32-bit configurations. That's why we needed to create configurations for x64 platform in Visual Studio. After adding the necessary configurations we could launch compilation of the 64-bit version.</p>
<p>Loki library is intended for operating on many various platforms and is built with the help of many most popular compilers. It explains why the 64-bit Loki version has been compiled nearly at once.  The Loki library is actually only one of 20 projects in the most recent version of Loki.  The other 19 projects are test programs which exercise various parts of Loki to demonstrate the code compiles and runs correctly.  By including so many test programs with Loki, the programmers can provide guarantees for much of Loki's functionality despite the complexity of the Loki source code.  Out of 20 projects in the solution only SafeFormat failed to build:</p>
<div id="IDAOKMEE">
<table>
<tbody>
<tr>
<td>
<pre>========== Build: 19 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p> </p>
<div id="IDASKMEE">
<table>
<tbody>
<tr>
<td>
<pre>------ Build started: Project: SafeFormat, Configuration: Debug x64 ------
Compiling...
main.cpp
.\main.cpp(255) : error C3066: there are multiple ways 
that an object of this type can be called with these arguments
        ..\..\include\loki/SafeFormat.h(109): could be 'Loki::PrintfState&lt;Device,Char&gt; 
&amp;Loki::PrintfState&lt;Device,Char&gt;::operator ()(bool)'
...
        while trying to match the argument list '(UInt)'
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>The text of the error is abridged a bit for it would take the whole page in a full form. Let's consider the code causing the error:</p>
<div id="IDA0KMEE">
<table>
<tbody>
<tr>
<td>
<pre>void test_dword()
{
    typedef signed int Int;
    typedef unsigned int UInt;
    typedef signed long Long;
    typedef unsigned long ULong;
    Int i(0);
    UInt ui(0);
    Long l(0);
    ULong ul(0);
    Printf("%d")(i);
    Printf("%d")(ui); // the problem is in this line
    Printf("%d")(l);
    Printf("%d")(ul);
}
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>The PrintfState  struct uses the LOKI_PRINTF_STATE_FORWARD macro to cast various parameter types to unsigned long. We found one problem here where a 64 bit parameter may get sliced down to 32 bits by this code snippet inside the file SafeFormat.h:</p>
<div id="IDAAMMEE">
<table>
<tbody>
<tr>
<td>
<pre>#if (defined(_WIN32) || defined(_WIN64))
        LOKI_PRINTF_STATE_FORWARD(unsigned long)
#else
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>We recommend using this snippet to avoid slicing 64 bit types:</p>
<div id="IDAMMMEE">
<table>
<tbody>
<tr>
<td>
<pre>#if (defined(_WIN32) || defined(_WIN64))
#if (defined(_WIN64))
        LOKI_PRINTF_STATE_FORWARD(unsigned int)
#endif
        LOKI_PRINTF_STATE_FORWARD(unsigned long)
#else
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>After this single correction the compilation error disappears and all the 20 projects of the library compiled with only some diagnostic warnings. One such warning tells us about a potentially unsafe conversion of <a href="http://www.viva64.com/terminology/size_t.html">size_t</a> type inside typicalUse() function in the file CachedFactoryTest.cpp:</p>
<div id="IDAENMEE">
<table>
<tbody>
<tr>
<td>
<pre>// Registering objects
for(size_t i=0;i&lt;objectKind;i++)
  CC.Register(i, createProductNull);
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>The control variable (objectKind) of the loop is an unsigned type.  After changing the type of the loop counter to unsigned so it matches the type of the control variable, the warning disappears:</p>
<div id="IDAMNMEE">
<table>
<tbody>
<tr>
<td>
<pre> // Registering objects
for(unsigned i=0;i&lt;objectKind;i++)
  CC.Register(i, createProductNull);
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>After these small corrections the 64-bit library compiles successfully and does not show any diagnostic warnings on 64-bit mode. But is the library's code actually correct? By running the many test projects and seeing no incorrect results or assertion failures, we can confidently say the Loki library is correct.  We also used our code analyzer, Viva64, to perform static analysis of Loki.</p>
<h2>Testing of the 64-bit Loki version with the help of Viva64<a name="IDAVNMEE"></a></h2>
<p>To make sure that Loki is compatible with 64-bit systems, let's perform analysis of the code using Viva64. <a href="http://www.viva64.com/viva64-tool/">Viva64</a> code analyzer is intended for developing new 64-bit applications and porting of existing 32-bit ones on a 64-bit platform.</p>
<p>During the analysis of Loki, Viva64 detected 89 potentially unsafe syntactic constructions. It does not mean Loki projects contain 89 errors related to 64-bit code, but that the developers should review these 89 places should be  to understand if these are errors. Of course, we have studied these locations in the code to ascertain if there are actual errors.  Many of the 89 locations are inside test projects rather than inside Loki itself.</p>
<h3>1 Incorrectly used constant LONG_MIN<a name="IDAAOMEE"></a></h3>
<p>Let's begin with an error relating to the incorrectly used constant LONG_MIN in the following function:</p>
<div id="IDAFOMEE">
<table>
<tbody>
<tr>
<td>
<pre>char* RenderWithoutSign(LOKI_SAFEFORMAT_SIGNED_LONG n, 
    char* bufLast, unsigned int base, bool uppercase)
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>It is located in the file SafeFormat.h. The problem is in this line:</p>
<div id="IDAJOMEE">
<table>
<tbody>
<tr>
<td>
<pre>if (n != LONG_MIN) {
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>LOKI_SAFEFORMAT_SIGNED_LONG type is defined as a type capable of storing 64-bit values in a 64-bit system. In Unix-systems (with <a href="http://www.viva64.com/terminology/LP64.html">LP64 data model</a>) long type is used for this purpose. But in 64-bit Windows-systems (<a href="http://www.viva64.com/terminology/LLP64.html">LLP64</a> data model) long type remained 32-bit. That's why LOKI_SAFEFORMAT_SIGNED_LONG type is defined in Loki in this way:</p>
<div id="IDAVOMEE">
<table>
<tbody>
<tr>
<td>
<pre>#if defined(_WIN32) || defined(_WIN64)
  #define LOKI_SAFEFORMAT_SIGNED_LONG intptr_t
  #define LOKI_SAFEFORMAT_UNSIGNED_LONG uintptr_t
#else
  #define LOKI_SAFEFORMAT_SIGNED_LONG signed long
  #define LOKI_SAFEFORMAT_UNSIGNED_LONG unsigned long
#endif
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>As long type remained 32-bit in 64-bit Windows-systems, LONG_MIN constant defines the minimum value of the 32-bit variable. This means that using it is incorrect when operating 64-bit types (in this case intptr_t). A strongly recommended solution is to use your own constant so you can guarantee its value remains the same for all platforms, or so you can control its value per platform rather than relying on the compiler. One possible correction is as follows:</p>
<div id="IDAHPMEE">
<table>
<tbody>
<tr>
<td>
<pre>#if defined(_WIN32) || defined(_WIN64)
#  define LOKI_SAFEFORMAT_SIGNED_LONG intptr_t
#if defined(_WIN64)
#  define LOKI_SAFEFORMAT_SIGNED_LONG_MIN_VALUE LLONG_MIN
#  define LOKI_SAFEFORMAT_SIGNED_LONG_MAX_VALUE LLONG_MAX
#else
#  define LOKI_SAFEFORMAT_SIGNED_LONG_MIN_VALUE LONG_MIN
#  define LOKI_SAFEFORMAT_SIGNED_LONG_MAX_VALUE LONG_MAX
#endif
...
#else
#  define LOKI_SAFEFORMAT_SIGNED_LONG signed long
#  define LOKI_SAFEFORMAT_SIGNED_LONG_MIN_VALUE LONG_MIN
#  define LOKI_SAFEFORMAT_SIGNED_LONG_MAX_VALUE LONG_MAX
...
#endif
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>Consequently, the line</p>
<div id="IDAXPMEE">
<table>
<tbody>
<tr>
<td>
<pre>if (n != LONG_MIN) {
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>must be replaced with</p>
<div id="IDA1PMEE">
<table>
<tbody>
<tr>
<td>
<pre>if (n != LOKI_SAFEFORMAT_SIGNED_LONG_MIN_VALUE) {
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>Fortunately, the creators of Loki library must be praised because this is the only line needing this correction. All the other comments described further may be interesting but they are not important.</p>
<p> </p>
<h3>2 Some types of magic numbers - errors or not?<a name="IDAFYMEE"></a></h3>
<p>Many of the problems detected by the Viva64 analyzer in Loki are because the lines seem to contain magic numbers. From the viewpoint of migration of code from a 32-bit platform on a 64-bit one, some numbers are the most dangerous. Perhaps, a programmer wants to have a definite size of a data type in some code section and this may cause a problem. Those who look through the warnings of the code analyzer often complain that they are irrelevant. Really, why should the code analyzer  about number 4 in lines like these?</p>
<div id="IDAKYMEE">
<table>
<tbody>
<tr>
<td>
<pre>::Loki::ScopeGuard guard4 = ::Loki::MakeGuard( &amp;HasFour, 1, 2, 3, 4 );
::Loki::ScopeGuard guard5 = ::Loki::MakeGuard( &amp;HasFive, 1, 2, 3, 4, 5 );
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>Sometimes there appear such constructions that must be studied very thoroughly. For example, in the file SafeFormat\main.cpp we see the code:</p>
<div id="IDAOYMEE">
<table>
<tbody>
<tr>
<td>
<pre>case 'X':
    // TestCase(formatSpec, RandomInt(-10000, 10000));
    // don't test negative values on 64bit systems, because 
    // snprintf does not support 64 Bit values
    TestCase(formatSpec, 
        RandomInt( -10000 * (sizeof(size_t)&gt;4 ? 0 : 1) , 10000));   
    break;
case 'e':
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>Of course, this particular use of a magic number is not an actual problem, but detecting and diagnosing magic numbers helps make the code more portable from one operating system to another and from 32 bits to 64 bits.</p>
<p> </p>
<h3>3 Addition of int to a pointer as a potential error<a name="IDADZMEE"></a></h3>
<p>The file flex\simplestringstorage.h contains the function:</p>
<div id="IDAIZMEE">
<table>
<tbody>
<tr>
<td>
<pre>void resize(size_type newSize, E fill)
{
  const int delta = int(newSize - size());
  if (delta == 0) return;
  if (delta &gt; 0)
  {
    if (newSize &gt; capacity())
    {
      reserve(newSize);
    }
    E* e = &amp;*end();
    flex_string_details::pod_fill(e, e + delta, fill);
  }
  pData_-&gt;pEnd_ = pData_-&gt;buffer_ + newSize;
}
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>Viva64 analyzer warns about a potential problem here:</p>
<div id="IDA2ZMEE">
<table>
<tbody>
<tr>
<td>
<pre>flex_string_details::pod_fill(e, e + delta, fill);
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>The defect occurs in adding, delta, a variable of int type, to e, a pointer. This is a potential problem since the pod_fill function will not be able to process a data size of more than 2 GB (INT_MAX characters). This particular instance is not a no problem for there are hardly  any lines that occupy more than 2 GB. Even so, it is better to change delta from an int type to a <a href="http://www.viva64.com/terminology/ptrdiff_t.html">ptrdiff_t</a> type:</p>
<div id="IDAE0MEE">
<table>
<tbody>
<tr>
<td>
<pre>const ptrdiff_t delta = ptrdiff_t(newSize - size());
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p> </p>
<h3>4 Using int for indexing arrays is incorrect<a name="IDAL0MEE"></a></h3>
<p>To access very large data arrays - more than INT_MAX elements - we recommend using types ptrdiff_t or size_t instead of unsigned int or unsigned long. The file SmallObj\SmallObjBench.cpp contains a large macro LOKI_SMALLOBJ_BENCH_ARRAY in which an int is used to index an array since compilers often use 32 bit variables for ints, but must use an appropriately sized data type for size_t.</p>
<p> </p>
<h3>5 Right arguments of functions<a name="IDAT0MEE"></a></h3>
<p>The file CachedFactory\CachedFactoryTest.cpp contains the following function:</p>
<div id="IDAY0MEE">
<table>
<tbody>
<tr>
<td>
<pre>template&lt; class Cache &gt;
milliSec typicalUse(Cache &amp;CC, unsigned objectKind, 
                    unsigned maxObjectCount, unsigned maxIteration)
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>We recommend using the size_t type for the objectKind parameter, but as this code exists only in a test project, the code does not affect the Loki library itself.</p>
<p> </p>
<h2>Loki library is compatible with 64-bit systems - does it mean that we can say the same about a program using it?<a name="IDAK1MEE"></a></h2>
<p>All the few problems of Loki library described above are easy to correct. Does that mean that if Loki does not contain any 64-bit problems (and this is true) than any application using this library is also safe from the viewpoint of 64-bit code? Unfortunately, it is not!</p>
<p>The point is that Loki library uses templates actively, so when the code analyzer examines a template code sometimes it cannot detect a problem. To be absolutely sure the analyzer needs to perform instancing of template classes and functions.</p>
<p>Let's give an example that does not relate to Loki library. Among other problems Viva64 analyzer can detect non-optimal data structures in code:</p>
<div id="IDAT1MEE">
<table>
<tbody>
<tr>
<td>
<pre>template &lt;class T&gt;
struct TClass
{
  int m_a;
  T m_b;
  int m_c;
};
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>If T has int type here the structure is optimal. But if T has size_t type the structure will occupy 24 bytes instead of possible 16 bytes. When there are many such objects, it is better to rewrite the code in this way:</p>
<div id="IDAB2MEE">
<table>
<tbody>
<tr>
<td>
<pre>template &lt;class T&gt;
struct TClass
{
  T m_b;
  int m_a;
  int m_c;
};
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>But the analyzer can check it only by instancing the template. That is, you cannot detect a problem when there is only definition of a class in the header.</p>
<p>Another example, again not relating to Loki, concerns type conversion:</p>
<div id="IDAR2MEE">
<table>
<tbody>
<tr>
<td>
<pre>template&lt;typename T1, typename T2&gt;
class TemplateClass
{
public:
	void test1()
	{
		m_a.m_value = m_b.m_value; // is there an error here?
	}
private:
	T1 m_a;
	T2 m_b;
};
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>In this code the error of type conversion can or cannot occur depending on the parameters with which instancing of TemplateClass template is performed. Without performing instancing, by simply analyzing the function's code, the analyzer cannot detect an error.</p>
<p>The two examples of template classes described above do not relate to Loki library but they are important for understanding the principles of code analyzers' operation. The peculiarity of template libraries like Loki is that even if a library is completely compatible with 64-bit systems it does not mean that the code using it is correct. This point changes completely the approach to verification of applications. Unlike common (non-template) libraries when complete compatibility with 64-bit systems is enough to make sure that the whole application is correct, in case of template libraries you cannot be sure about it.</p>
<p>All this means that although Loki library does not contain problems relating to 64-bit code, a user application which uses it must be tested by the code analyzer additionally to see if there are such problems, for errors depend on the parameters with which instancing of templates is performed.</p>
<p> </p>
<h2>Conclusion<a name="IDAU3MEE"></a></h2>
<p>The results of testing Loki library on compatibility with 64-bit systems performed by the workers of OOO "Program Verification Systems" Company allowed us to draw the following conclusions:</p>
<p>The library is fully compatible with 64-bit systems and does not contain potential errors. The errors stated in this article are likely to be corrected very easily.</p>
<p>Viva64 code analyzer intended for developing 64-bit applications and porting existing 32-bit ones turned out to be very efficient when testing a complicated template code of the library. It proves a very good quality of the code analyzer.</p>
<p>Although Loki library does not contain 64-bit problems they can occur in user applications using Loki. As the end code depends on the parameters with which templates have been instanced, it is necessary to test user applications with the help of the code analyzer. Only then you can be sure that the user application is compatible with 64-bit systems.</p>
<p> </p>
<h2>Acknowledgements<a name="IDAC4MEE"></a></h2>
<p>We would like to thank the following people who assisted us with our analysis of Loki library, or reviewed our work on Loki:</p>
<ul >
<li>We thank Program Verification Systems technical team who reviewed Loki library and carried out verification of its 64-bit compliance: Andrey Karpov and Evgeniy Ryzhkov. </li>
<li>We thank Loki team: Andrei Alexandrescu, Peter Kümmel, and Rich Sposato for cooperation and for checking our article, editing it and providing valuable advice.</li>
<li>We are glad that Rich Sposato expressed the will of working together in future and we would like to cooperate in future with the team of Loki developers.</li>
</ul>
<p> </p>
<h2>References<a name="IDAS4MEE"></a></h2>
<ol>
<li>Loki Library. <a href="http://sourceforge.net/projects/loki-lib/">http://sourceforge.net/projects/loki-lib/</a>.</li>
<li>Viva64 Tool. <a href="http://www.viva64.com/viva64-tool">http://www.viva64.com/viva64-tool</a>. </li>
</ol> ]]></description>
      <link>http://software.intel.com/en-us/articles/64-bit-loki/</link>
      <pubDate>Mon, 05 Oct 2009 13:00:00 -0700</pubDate>
      <comments>http://software.intel.com/en-us/articles/64-bit-loki/#comments</comments>
      <guid isPermaLink="true">http://software.intel.com/en-us/articles/64-bit-loki/</guid>
      <category>Open Source</category>
    </item>
    <item>
      <title>How to build ffmpeg to run under Moblin 2</title>
      <description><![CDATA[ <div class="Section1">
<p class="MsoNormal"><span class="sectionBodyText"><br />The application ‘ffmpeg’ consist of three executables and 5 libraries. All the sources can be downloaded using the following svn command:</span></p>
<p class="MsoNormal"><span class="sectionBodyText"></span></p>
<p class="MsoNormal"><span class="sectionBodyText"></span></p>
<p class="MsoNormal" ><span >Ø<span >      </span></span><span class="sectionBodyText">svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg </span></p>
<p class="MsoNormal"><span > </span><strong class="sectionHeading">Required patch</strong></p>
<p class="MsoNormal"><span class="sectionBodyText">One version which I tried ( download: svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg –r 17944)</span></p>
<p class="sectionBodyText">has a known problem with the sources. If you try to build the code, then you will get a compile time error:</p>
<p class="MsoNormal"><span class="sectionBodyText"> </span><span class="sectionBodyText">libswscale/swscale.c:488: error: ‘PIX_FMT_YUV420PLE’ undeclared</span></p>
<p class="MsoNormal"><span class="sectionBodyText"></span></p>
<p class="MsoNormal"><span class="sectionBodyText">The solution is solved by copying the contents of the libswscale directory from .</span><span ><span class="sectionBodyText">  </span> <a href="http://www.ffmpeg.org/releases/ffmpeg-0.5.tar.bz2" title="http://www.ffmpeg.org/releases/ffmpeg-0.5.tar.bz2" >http://www.ffmpeg.org/releases/ffmpeg-0.5.tar.bz2</a>    (see </span><span lang="EN" ><a href="http://www.ffmpeg.org/download.html" >http://www.ffmpeg.org/download.html</a>)</span></p>
<p class="MsoNormal"><span class="sectionBodyText"></span></p>
<p class="MsoNormal"><span class="sectionBodyText">Please Note, <b><i>only</i></b> the libswscale directory should be copied <b><i>over the top</i></b> of the existing files.</span></p>
<h3> </h3>
<h3><span class="sectionHeading" lang="FR">Build Instructions</span></h3>
<p class="MsoNormal"><span class="sectionBodyText"></span></p>
<p class="MsoNormal"><span class="sectionBodyText">Following instructions will help you build ffmpeg under a Linux system assuming that the tar ball from the download is copied to &lt;install_directory&gt;:<br /></span><br /> Ø      cd  &lt;install_directory&gt;<br /><br /> Ø      cd tar xvfz  ffmpeg.tar.gz   #Extract the tar ball to your local directory. You will find a directory tree under the name ffmpeg installed. All the required sources are installed within this tree provided that you are not enabling any additional third party libraries.<br /><br /> Ø      cd ffmpeg</p>
<p class="sectionBodyText"> Ø      ./configure –help &lt;cr&gt; # to show all the options available to rebuild ffmpeg. For a reference build with <b>gcc</b> there is no need to provide any parameters to configure. However if you would like to enable any third party libraries like ‘libfaad’, ‘libx264’ etc. then you need to add --enable-libfaad --enable-libx264 etc. as parameters to configure. If this is required make sure that you have these sources available on your development environment and that the third party libraries are rebuilt with the selected compiler / compiler options.</p>
<p class="sectionBodyText"> Ø      ./configure &lt;parameters as below&gt;</p>
<p class="MsoNormal"><span class="sectionBodyText"> </span>Ø      make &lt;cr&gt; #recommended sequence is ‘make clean’ followed by ‘make’. The rebuild will take several minutes (depending on your development environment). Two versions of each executable are produced: ex. ‘ffmpeg’ and ‘ffmpeg_g’. The ‘*_g’ contains the executable with debug information while the ‘*’ is the stripped version. In addition ‘ffplay, ffplay_g, ffserver and ffserver_g’ are produced as executables and libavutil, libavcodec, libavformat, libavdevice and libswscale are rebuilt.</p>
<p class="sectionHeadingText"> <b><span >Icc build</span></b>:</p>
<p class="MsoNormal"><span class="sectionBodyText">Depending on what version of icc you are using different configure parameters may be necessary.</span></p>
<p class="MsoNormal"><span class="sectionBodyText"> </span><span class="sectionBodyText">Using icc v10.1.xxx:</span></p>
<p class="MsoNormal"><span class="sectionBodyText"> </span>Ø      ./configure cc=icc --extra-cflags=”-xL –O3” --extra-libs=-lsvml &lt;cr&gt; # Without linking in the extra library (libsvml.so) you get several references unresolved.</p>
<p class="MsoNormal"><span class="sectionBodyText"> </span><span class="sectionBodyText">Using icc v11.0.xxx:</span></p>
<p class="MsoNormal"><span class="sectionBodyText"> </span>Ø      ./configure cc=icc –extra-cflags=”-xSSE3_ATOM –O3” –extra-libs=-lsvml &lt;cr&gt; #  The option –xSSE3_ATOM do require that you run the code on a processor which does support the ‘movbe’ instruction. If you would like to test the code on a processor not supporting the ‘movbe’ instruction you can add the option ‘-minstruction=nomovbe’ in the extra-cflag part of the command line above.<br />Ø      Make sure that the LD (linker) options do not contain ‘–march=generic’ in the config.mak file. This option causes an error from the compiler.<br /><span class="sectionBodyText"><br />Using icc v11.1.xxx:<br /></span><br />Ø      To avoid a run time erratum following source change is needed:   Open file ./libavcodec/x86/dsputil_mmx.c and on line #2944 insert // before || __ICC &gt; 1100. The line is highlighted below.</p>
<p class="MsoNormal" ><span ><v:shapetype coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f" id="_x0000_t75"><v:stroke join></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"></v:path><o:lock v:ext="edit" aspectratio="t"></o:lock></v:shapetype><v:shape type="#_x0000_t75" id="_x0000_s1025" ><v:imagedata src="new_page_21_files/image001.png"><img height="151" width="576" src="http://software.intel.com/file/22666" /></v:imagedata></v:shape></span><br /><br />Ø      After the change it will look like: #if ARCH_X86_64 || ! ( __ICC) // || __ICC &gt; 1100</p>
<p class="MsoNormal" ><span class="sectionBodyText"></span></p>
<p class="sectionBodyText" >Ø      ./configure cc=icc –extra-cflags=”-xSSE3_ATOM –O3” &lt;cr&gt; # This simple configure does work but you get better performance if you also add the ‘--extra-lib=-lsvml’. Additional compiler switches can be used to improve the performance – for example ‘-no-prec-div’, ‘-vec-‘. As the no-prec-div has an effect on the fp calculations please refer to the compiler documentation before it is used. In addition the ‘-xSSE3_ATOM’ switch are no longer requiring a processor with ‘movbe’ support.</p>
<p class="sectionHeadingText"> Cross compilation.</p>
<p class="MsoNormal"><span class="sectionBodyText">It is standard practice to build the library and executables on a development machine and then copy the resultant files to the MOBLIN target.  You can use the option --enable–cross-compile in this case.</span></p>
<p class="MsoNormal"><span class="sectionBodyText"></span></p>
<p class="MsoNormal" ><span class="sectionBodyText"></span></p>
<p class="MsoNormal"><span class="sectionBodyText">Once you have completed the configure stage you can just run the ‘make clean’ followed by ‘make’. You could expect additional warnings produced.</span></p>
<p class="MsoNormal"><span class="sectionHeading"></span></p>
<p class="MsoNormal"><b><span ><span class="sectionHeading">Building ffmpeg with third party libraries:</span></span></b></p>
<p class="MsoNormal"><b><span ><span class="sectionHeading"></span></span></b></p>
<p class="MsoNormal"><span class="sectionBodyText">The application can support 21 different external 3<sup>rd</sup> party libraries. Each of those are selected in the configure process by adding the option ‘--enable-&lt;library-name&gt;’. </span></p>
<p class="MsoNormal"><span class="sectionBodyText">Below is an example of using some of the different external libraries available:</span></p>
<p class="MsoNormal"><span class="sectionBodyText"> </span>Ø      ./configure &lt;other options as above&gt; --enable-libfaac --enable-libfaad --enable-libmp3lame --enable-libtheora --enable-libx264 --enable-libxvid<span class="sectionBodyText"> </span></p>
<p class="MsoNormal"><span class="sectionBodyText">The invocation above assumes that you will be using 6 external 3<sup>rd</sup> party libraries:</span></p>
<p class="MsoNormal"><span class="sectionBodyText"> </span><span class="sectionBodyText">- libfaac       # for example you can download ‘faac-1.28.tar.gz’ or later version from the web.</span></p>
<p class="MsoNormal"><span class="sectionBodyText"> </span><span class="sectionBodyText">- libfaad       # for example you can download ‘faad2-2.7.tar.gz’ or later version from the web.</span></p>
<p class="MsoNormal"><span class="sectionBodyText"> </span><span class="sectionBodyText">- libmp3lame # for example you can download ‘lame-398-2.tar.gz’ or later version from the web.</span></p>
<p class="MsoNormal"><span class="sectionBodyText"> </span><span class="sectionBodyText">- libtheora    # for example you can download ‘libtheora-1.0.tar.tar’ or later version from the web. Please note that you can not use ICC v 10.1 to rebuild this library due to a compiler issue. This has been fixed with 11.1 version of the compiler.</span></p>
<p class="MsoNormal"><span class="sectionBodyText"> </span><span class="sectionBodyText">- libx264      # for example you can download ‘x264-snapshot-20090117-2245.tar.bz2’ or later version from the web.</span></p>
<p class="MsoNormal"><span class="sectionBodyText"> </span><span class="sectionBodyText">- libxvid      # for example you can download ‘xvidcore-1.2.1.tar.gz’ or later version from the web.<br /></span><span class="sectionBodyText"><br /><strong>Performance Notes:</strong> <br /><br />Best option combination for ICC: “-xSSE3_ATOM –O3 –vec- -static –no-prec-div –ansi_alias”. Also make sure you add –extra-libs=-lsvml in your configure invocation.<br /><br />Two ways of improving the performance of ffmpeg:<br /><br />1) Use the external 3rd party libraries which are supported – 20+ are available. They are optimized for their specific field. You need to select the suitable library – download the code and build them using the ICC. <br /><br />2) Use PGO. Here it is important to produce a set of .dyn files for the most common conversion you will be using. The code size improves a bit and the performance also gets a boost provided that you use any of the conversions for which you generated a .dyn file. If you select a totally different conversion you actually could get a slower performance compared to both gcc and icc (general optimized version). For those who are not familiar with the PGO optimization this is a three step procedure:<br /><br />a. Add the option –prof-gen to the extra-cflags section for the configure generation. Build ffmpeg. <br /><br />b. Run the resulting binary on your target. Make sure you use representative input files and output formats. You may want to repeat this process several times. For each run you will have a .dyn file generated on the target. Copy these files over to your development system.<br /><br />c. Now use the options –prof-use and –prof-dir &lt;directory path where you have the .dyn files which you copied in step b&gt; [make sure to remove –prof-gen option]. Generate a new make file with configure and build your ffmpeg. You may see a number of warnings ‘missing .dpi information for &lt;file name.’ This is information only and can be ignored. The finally generated ffmpeg should be both smaller and faster. <br /><br /><br />
<table cellpadding="5" cellspacing="0" rules="none" border="1">
<tbody>
<tr>
<th align="left" valign="middle" >Optimization Notice</th>
</tr>
<tr bgcolor="#ccecff">
<td>
<p>Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.</p>
<p align="right">Notice revision #20110804</p>
</td>
</tr>
</tbody>
</table>
<br /><br /><br /><br /><br /></span></p>
</div> ]]></description>
      <link>http://software.intel.com/en-us/articles/how-to-build-ffmpeg-to-run-under-moblin-2/</link>
      <pubDate>Wed, 23 Sep 2009 00:00:00 -0700</pubDate>
      <comments>http://software.intel.com/en-us/articles/how-to-build-ffmpeg-to-run-under-moblin-2/#comments</comments>
      <guid isPermaLink="true">http://software.intel.com/en-us/articles/how-to-build-ffmpeg-to-run-under-moblin-2/</guid>
      <category>Mobility</category>
      <category>Open Source</category>
      <category>Tools</category>
      <category>Intel® AppUp(SM) Developer Community</category>
      <category>MID</category>
      <category>Intel® Software Development Tool Suites for Intel® Atom™ Processor Knowledge Base</category>
    </item>
    <item>
      <title>Building ACE/TAO with Intel(R) C++ Compiler for Windows XP 64-bit using Visual Studio</title>
      <description><![CDATA[ <br />
<div id="art_pre_template"><b>Introduction : </b><br />This document explains how to build ACE/TAO using Intel(R) C++ Compiler for Windows XP 64-bit. From the ACE/TAO web site:<br /><br /><a href="http://www.cs.wustl.edu/~schmidt/ACE.html">ACE</a>† is an open-source framework that provides many components and patterns for developing high-performance, distributed real-time and embedded systems. ACE provides powerful, yet efficient abstractions for sockets, demultiplexing loops, threads, synchronization primitives. <br /><br /><a href="http://www.cs.wustl.edu/~schmidt/TAO.html">TAO</a>† (The ACE ORB) is an open-source implementation of a CORBA Object Request Broker (ORB) built using components and patterns in the ACE framework. <br />Several companies provide commercial support for ACE/TAO, see <a href="http://www.cs.wustl.edu/~schmidt/commercial-support.html">http://www.cs.wustl.edu/~schmidt/commercial-support.html</a>† for information. <br /><br /><br /><b>Version : </b><br />The version of ACE/TAO used in this document is 5.7.2. <br />The 11.1.038 version of the Intel C++ compiler (Intel64) is used.<br /><br /><br /><b>Obtaining Source Code : </b><br />The ACE/TAO source code was downloaded from <a href="http://download.dre.vanderbilt.edu/">http://download.dre.vanderbilt.edu/</a>†.<br /><br /><br /><b>Prerequisites : </b><br />- WinZIP or similar tool for extracting software archives<br />- Microsoft Visual Studio (2003, 2005 or 2008)<br /><br /><br /><b>Configuration and Set-up information : </b><br /><br />1. Extract the archive into a path with no spaces in the path name (e.g., C:\ACE_wrappers).<br /><br />2. Set ACE_ROOT, TAO_ROOT, and PATH environment variables.<br /><br />For example, if ACE/TAO is installed in C:\ACE_wrappers, the variables should look like this:<br />ACE_ROOT=C:\ACE_wrappers<br />TAO_ROOT=%ACE_ROOT%\TAO<br />The PATH variable should contain these directories: %ACE_ROOT%\bin;%ACE_ROOT%\lib<br /><br />Please follow these steps to set the environment variables:<br /><br />- Log into an account with Administrator privilege<br />- Open the Control panel<br />- Click System<br />- Click the Advanced tab and then click the Environment Variables button<br />- Add new ACE_ROOT and TAO_ROOT variables<br />- Edit PATH variable from the System variables list<br />- Click OK<br /><br />3. Create a file named config.h in %ACE_ROOT%\ace with the following contents:<br /><br />#include "ace/config-win32.h"<br /><br />4. Open the solution file that matches your version of Visual Studio. <br />For example, you could find following solution files:<br /><br />%TAO_ROOT%\TAO_ACE.sln (Visual Studio 2003)<br />%TAO_ROOT%\TAO_ACE_vc8.sln (Visual Studio 2005)<br />%TAO_ROOT%\TAO_ACE_vc9.sln (Visual Studio 2008)<br /><br />The projects in the TAO_ACE solution build the ACE and TAO libraries, TAO IDL compiler, gperf, ORB services<br />libraries and executables, and some common utilities. They do not include any examples, tests, or performance<br />tests. (Separate directories and solutions exist for them.) Libraries will be installed in %ACE_ROOT%\lib.<br />Some executables will be installed in %ACE_ROOT%\bin, others (the ORB services executables) will be installed<br />in their source directories.<br /><br />5. It is necessary to update the solution to use the Intel(R) C++ Compiler. <br />In the Solution Explorer, select the solution and click the Use Intel C++ toolbar button. <br />Alternatively, select Intel C++ Compiler Pro &gt; Use Intel C++ from the Visual Studio Project menu.<br />Click the OK button to continue. <br />The TAO_ACE solution constains many projects and it will take some time to update them to use Intel C++.<br /><br />Finally, you should see the message in the output window with the list of the successfully updated projects.<br /><br /><br />6. Open Solution Properties and create a new platform configuration for x64 using the Configuration Manager. <br />Make sure, that current (target) configuration is Debug|x64 or Release|x64 and build solution (Build &gt; Build Solution).<br /><br /><br />During building of the solution, go to the Output window to verify that the Intel C++ Compiler is used. If Intel C++ Compiler is used, you should see a message similar to the following:<br /><br />Compiling with Intel(R) C++...[Intel(R) 64]... (Intel C++ Environment)<br /><br /><br /><strong>Verifying Correctness</strong> <br /><br />There are many examples and tests included in ACE/TAO. Additional separate directories and solutions exist for them.<br />It is possible to compile all tests using corresponding test solution files from %ACE_ROOT%\tests folder.<br />There is one solution file for all tests (each for different versions of VS) there, however, it is also possible to compile each test separately.<br /><br />For example, you could compile ACE_Test to verify the correctness of ACE compilation using following instructions:<br /><br />1. Open ACE_Test project file from %ACE_ROOT%\tests folder (e.g.,ACE_Test_vc9.vcproj for VS2008).<br /><br />2. It is necessary to update the solution to use the Intel(R) C++ Compiler. Please follow the same instructions as described previously in step 5. You will be also asked to save the solution.<br /><br />3. Make sure, that current (target) configuration is Debug|x64 or Release|x64 (it should be the same with the compiled libraries) and build solution.<br /><br />4. Run the test (F5 or Ctrl+F5).<br /><br />5. You could check the logs in %ACE_ROOT%\tests\log folder (ACE_Test.log file). In case of normal execution the output looks like this:<br /><br />Sep 08 15:52:11.103 2009@LM_DEBUG@(3820|5884) Starting ACE_Test test at Tue Sep 8 2009 15:52:11.103000<br />Sep 08 15:52:11.103 2009@LM_DEBUG@(3820|5884) Ending ACE_Test test at Tue Sep 8 2009 15:52:11.103000<br /><b><br /><br />Source Code Changes : </b><br />None required. <br /><br /><br /><b>Related topics: </b><br /><a href="http://software.intel.com/en-us/articles/building-acetao-with-intelr-c-compiler-for-linux/">http://software.intel.com/en-us/articles/building-acetao-with-intelr-c-compiler-for-linux/</a><br /><br /><br /><b>Known Issues or Limitations : </b><br />None. Please contact Intel® Premier Support website or Intel® User Forums if you encounter problems or want to provide feedback.<br /><br />† This link will take you off of the Intel Web site. Intel does not control the content of the destination Web Site.</div> ]]></description>
      <link>http://software.intel.com/en-us/articles/building-acetao-with-intelr-c-compiler-for-windows-xp-64-bit-using-visual-studio/</link>
      <pubDate>Sat, 15 Aug 2009 13:00:00 -0700</pubDate>
      <comments>http://software.intel.com/en-us/articles/building-acetao-with-intelr-c-compiler-for-windows-xp-64-bit-using-visual-studio/#comments</comments>
      <guid isPermaLink="true">http://software.intel.com/en-us/articles/building-acetao-with-intelr-c-compiler-for-windows-xp-64-bit-using-visual-studio/</guid>
      <category>Open Source</category>
      <category>Intel® Compilers</category>
      <category>Intel® C++ Compiler for Windows* Knowledge Base</category>
    </item>
  </channel></rss>
