Getting Started with the
Intel® C++ Compiler 9.0 for Windows*

Document number: 307057-001

Contents

Overview
Configuring the C++ Compiler
Before You Start
    The Verification Source File
    Confirming Proper Installation
Invoking the Compiler (Command Line)
    Compiling with No Optimization Options
    Running/Verifying the Compiled Program
    Compiling with Optimization
    Running/Comparing Performance
Invoking the Compiler (Visual Studio .NET)
    Compiling with No Optimization Options
    Running/Verifying the Compiled Program
    Compiling with Optimization
    Running/Comparing Performance
Using the Compiler on Your Own
Where from Here?
Disclaimer and Legal Information

Overview

The Intel® C++ Compiler 9.0 for Windows* systems uses either the command line or a Microsoft* Visual Studio .NET integrated development environment (IDE) on a Windows* host system to compile C/C++ source files.  Refer to the Intel(R) Software Development Products web site for more information about this product and other Intel software development products.

    Note:  The default installation path for the C++ compiler is
C:\Program Files\Intel\Compiler\C++\9.0
.  For the remainder of this guide,
the path C:\Program Files\Intel will be indicated as <install-dir>, so the default IA-32 installation path would be indicated as <install-dir>\Compiler\C++\9.0\IA32.

Configuring the C++ Compiler

A successful installation and configuration of the Intel C++ Compiler 9.0 for Windows product requires that you also set up the environment variables.    Refer to the Installation Guide to confirm that the Intel C++ Compiler 9.0 for Windows has been properly configured. 

    Note:  Configuration of the Intel C++ Compiler 9.0 for Windows to work within the Microsoft* Visual Studio IDE environment happens without additional setup steps if you the Microsoft Visual Studio environment is installed first.  Refer to the Installation Guide for the steps to follow if the Intel C++ Compiler 9.0 for Windows is installed first.

You can open a command window from the Intel® C++ Compiler's menu from Start > Programs > Intel(R) Software Development Tools >  Intel(R) C++ Compiler 9.0 > Build Environment for IA-32 applications . It sets up the environment automatically.  Alternatively, you can run the batch file (at <install-dir>\Compiler\C++\9.0\IA32\bin\iclvars.bat for the IA-32 architecture) to start the compiler with the correct environment (command line operation). 

If using the Microsoft* Visual Studio IDE, be sure to select Project > Convert to use Intel(R) C++ Project System on your project prior to working on your project.  Refer to the "Building Applications" sections of the Intel® C++ Compiler documentation for more complete instructions on configuring your project for use with the IDE.

Before You Start

Once you complete installation of the Intel C++ Compiler, it is useful to perform a basic verification task that confirms proper installation, configuration, and operation of the compiler.  A verification source file is provided at <install-dir>\Compiler\C++\9.0\Docs\samples\int_sin.c as part of the compiler installation. 

The Verification Source File

The verification source file is a math program that integrates the absolute value of a sine curve for one cycle of 2 pi radians.  The following figure shows the method used for calculation.  This method successively adds the areas of rectangles with a height centered on the curve.  As the number of rectangles increases (and the slice width decreases), the calculated area approaches four (4.0).  The figure below shows what is being calculated for 24 interior points and the first eight slices of a 25 interior point calculation.

The program checks that Intel libraries have been installed because it includes the Intel math library in addition to stdio, stdlib, and time libraries.  The timing function in the program returns the number of measured application clocks from the beginning to the end of program execution.  This time measure is inexact and will vary somewhat depending on the processor and its workload. 

Confirming Proper Installation

You can confirm proper installation of the compiler by compiling the verification source, running the verification output file, and observing that the program output converges to the known correct value of 4.  Perform the following steps to verify your installation:

  1. The verification source file is in the <install-dir>\Compiler\C++\9.0\Docs\samples directory.  Change to the directory and run the compiler on the verification source file, as follows:

                prompt> icl int_sin.c
  1. The compiled program should be in the <install-dir>\Compiler\C++\9.0\Docs\samples directory with a file name of int_sin.exe.  Execute the program as follows:

                prompt> int_sin

     
  2. The program output should display in the same command prompt window from which it was invoked, as follows:

     
        Number of     | Computed Integral |
     Interior Points  |                   |
    -------------------------------------
              4       |   3.141593e+000   |
    -------------------------------------
              8       |   3.792238e+000   |
    -------------------------------------
             16       |   3.948463e+000   |
    -------------------------------------
             32       |   3.987141e+000   |
    -------------------------------------
             64       |   3.996787e+000   |
    -------------------------------------
            128       |   3.999197e+000   |
    -------------------------------------
            256       |   3.999799e+000   |
    -------------------------------------
            512       |   3.999950e+000   |
    -------------------------------------
           1024       |   3.999987e+000   |
    -------------------------------------
           2048       |   3.999997e+000   |
    -------------------------------------
           4096       |   3.999999e+000   |
    -------------------------------------
           8192       |   4.000000e+000   |
    -------------------------------------
          16384       |   4.000000e+000   |
    -------------------------------------
          32768       |   4.000000e+000   |
    -------------------------------------
          65536       |   4.000000e+000   |
    -------------------------------------
         131072       |   4.000000e+000   |
    -------------------------------------
         262144       |   4.000000e+000   |
    -------------------------------------
         524288       |   4.000000e+000   |
    -------------------------------------
        1048576       |   4.000000e+000   |
    -------------------------------------
        2097152       |   4.000000e+000   |
    -------------------------------------
        4194304       |   4.000000e+000   |
    -------------------------------------
        8388608       |   4.000000e+000   |
    -------------------------------------
       16777216       |   4.000000e+000   |
    -------------------------------------
       33554432       |   4.000000e+000   |
    -------------------------------------
       67108864       |   4.000000e+000   |

    Application Clocks = 5.500000e+003
     

    1. If the compiler or the output of the compiled program do not appear to be functioning correctly, check the installation and configuration, and reinstall if necessary.  Otherwise the Intel C++ compiler has been properly installed and is functioning correctly.
       

Invoking the Compiler (Command Line)

The Intel® C++ Compiler 9.0 for Windows* can be invoked from the command line using icl (for C or C++ source files).   We will use the int_sin.c verification source file in order to get started using the compiler and become familiar with some of its features and options.  If you will be using the IDE interface instead of the command line for most of your work, you can skip this section and go to the Invoking the Compiler (Visual Studio or Visual Studio .NET) section.

The int_sin.c verification source file is located in the <install-dir>\Compiler\C++\9.0\Docs\samples directory.  Before starting this section, open a Command Prompt (from the Windows Start menu) window and change directory as follows:

            prompt> cd <install-dir>\Compiler\C++\9.0\Docs\samples    

Compiling with No Optimization Options

We can establish a performance baseline by invoking the Intel C++ compiler without any optimization options.  Invoke the Intel C++ compiler on the source as follows:

            prompt> icl int_sin.c /Od

Alternatively, you could use the /g debug option, because that changes the default optimization from /O2 to /O0.

Running/Verifying the Compiled Program

The compiled program is in the same directory as the source, with a default file name of int_sin.exe.  Execute the program as follows:

            prompt> int_sin

The computed integral value nears or equals 4.0 for each calculation as the execution time (number of processor clock cycles) consumed during each of the calculations generally increases with the number of interior points.  The following example output is similar to the output you should see:

 
    Number of     | Computed Integral |
 Interior Points  |                   |
-------------------------------------
          4       |   3.141593e+000   |
-------------------------------------
          8       |   3.792238e+000   |
-------------------------------------
         16       |   3.948463e+000   |
-------------------------------------
         32       |   3.987141e+000   |
-------------------------------------
         64       |   3.996787e+000   |
-------------------------------------
        128       |   3.999197e+000   |
-------------------------------------
        256       |   3.999799e+000   |
-------------------------------------
        512       |   3.999950e+000   |
-------------------------------------
       1024       |   3.999987e+000   |
-------------------------------------
       2048       |   3.999997e+000   |
-------------------------------------
       4096       |   3.999999e+000   |
-------------------------------------
       8192       |   4.000000e+000   |
-------------------------------------
      16384       |   4.000000e+000   |
-------------------------------------
      32768       |   4.000000e+000   |
-------------------------------------
      65536       |   4.000000e+000   |
-------------------------------------
     131072       |   4.000000e+000   |
-------------------------------------
     262144       |   4.000000e+000   |
-------------------------------------
     524288       |   4.000000e+000   |
-------------------------------------
    1048576       |   4.000000e+000   |
-------------------------------------
    2097152       |   4.000000e+000   |
-------------------------------------
    4194304       |   4.000000e+000   |
-------------------------------------
    8388608       |   4.000000e+000   |
-------------------------------------
   16777216       |   4.000000e+000   |
-------------------------------------
   33554432       |   4.000000e+000   |
-------------------------------------
   67108864       |   4.000000e+000   |

Application Clocks = 1.184300e+004
 

Compiling with Optimization

The performance enhancement realized by using some of the optimization options of the Intel C++ compiler can be quite significant.  Other options allow you to enhance operation or performance in different areas.  Invoke the compiler (with the default optimization) as follows:

            prompt> icl int_sin.c

By default the compiler performs level 2 optimizations (/O2), which is intended to improve code execution speed. 

Running/Comparing Performance

Execute this optimized version of the compiled int_sin program as follows:

            prompt> int_sin

Compare the number of "Application Clocks" with the number you noted for the unoptimized program.  Although the actual time differences you see might depend on the architecture of your target system, the following output is typical for an Intel® IA-32 system.

 
    Number of     | Computed Integral |
 Interior Points  |                   |
-------------------------------------
          4       |   3.141593e+000   |
-------------------------------------
          8       |   3.792238e+000   |
-------------------------------------
         16       |   3.948463e+000   |
-------------------------------------
         32       |   3.987141e+000   |
-------------------------------------
         64       |   3.996787e+000   |
-------------------------------------
        128       |   3.999197e+000   |
-------------------------------------
        256       |   3.999799e+000   |
-------------------------------------
        512       |   3.999950e+000   |
-------------------------------------
       1024       |   3.999987e+000   |
-------------------------------------
       2048       |   3.999997e+000   |
-------------------------------------
       4096       |   3.999999e+000   |
-------------------------------------
       8192       |   4.000000e+000   |
-------------------------------------
      16384       |   4.000000e+000   |
-------------------------------------
      32768       |   4.000000e+000   |
-------------------------------------
      65536       |   4.000000e+000   |
-------------------------------------
     131072       |   4.000000e+000   |
-------------------------------------
     262144       |   4.000000e+000   |
-------------------------------------
     524288       |   4.000000e+000   |
-------------------------------------
    1048576       |   4.000000e+000   |
-------------------------------------
    2097152       |   4.000000e+000   |
-------------------------------------
    4194304       |   4.000000e+000   |
-------------------------------------
    8388608       |   4.000000e+000   |
-------------------------------------
   16777216       |   4.000000e+000   |
-------------------------------------
   33554432       |   4.000000e+000   |
-------------------------------------
   67108864       |   4.000000e+000   |

Application Clocks = 5.500000e+003

    Note: While the large improvement in execution time (unoptimized to optimized program) in this example might not be typical for all programs, you should be able to improve the execution time for programs running on Intel processors by choosing to optimize your compiled output.  Note also that the Intel C++ compiler optimizes programs at an /O2 level by default.

Invoking the Compiler (Visual Studio .NET)

If you installed Microsoft Visual Studio .NET* 2002 or 2003 on the same system where you plan to install the Intel® C++ Compiler, you can use the Intel compiler in Microsoft Visual Studio .NET without additional setup steps. If you installed the Intel C++ Compiler while running Visual Studio .NET, you need to restart Visual Studio before you can select the Intel C++ Compiler.  Once the Intel C++ compiler has been installed, perform the following steps:

  1. Create a new project in Visual Studio .NET by selecting File - New - Project ... .  In the new Project dialog box, select Win32 Console Project, as shown below.  Use int_sin as the project name.


     
  2. The Visual Studio .NET Win32 Application Wizard displays the following window.  Just click Finish and a Win32 console project will be created.


     
  3. Next, select Convert to use Intel(R) C++ Project System from the Project drop-down menu. This action converts your Microsoft Visual C++ Project to an Intel C++ Project and creates a new Intel C++ project file (.icproj).


     
  4. Click Yes in the Confirmation dialog that follows to complete your selection.

        Note: A version of the example program named int_sin.cpp is provided in the <install-dir>\Compiler\C++\9.0\Docs\samples directory.  Use this version of the example program with the IDE.

  5. Next select all of the content of the int_sin.cpp source file in the Edit Window, as shown.


     
  6. Click Edit - Insert File As Text... and select the source file at
    <install-dir>\Compiler\C++\9.0\Docs\samples\int_sin.cpp to replace the default source file that was created for this project. 


     

Compiling with No Optimization Options

Perform the following steps:

  1. Before building any solution in VS .NET, it is a good idea to clean the project.  Select Build - Clean Solution, and observe the following report:


     
  2. Next select Build - Build Solution, and observe the following report:



    Note that the default project configuration is Debug, which results in the the solution being Built (compiled) without optimizations and with symbolic debugging information.  This is equivalent to entering  icl /Od /Zi int_sin.cpp on the command line.

Running/Verifying the Compiled Program

  1. Select Debug - Start Without Debugging and observe the following command window output:


     
  2. Note the number of Application Clocks used for the application without any optimization.

Compiling with Optimization

Now we can recompile the program with optimization.  Perform the following steps:

  1. Select Project - int_sin Properties... to get the following dialog box:


     
  2. Select Configuration Manager..., then change the Active Solution Configuration and the Project Contents Configuration to Release.  Click Close.


     
  3. Back on the Property Pages dialog, go to the Configuration Properties - C/C++ - Optimization line, and make sure the Optimization is set to Maximize Speed (/O2).  Note that in this dialog you can define specific options using the Command Line selection.
  4. As before, select Build - Clean Solution, and then Build - Build Solution to compile the int_sin project with optimization on.

Running/Comparing Performance

  1. As before, select Debug - Start Without Debugging and observe the following command window output:


     
  2. Again note the number of Application Clocks used for the application with optimization, and compare it with the unoptimized number.

        Note: While the large improvement in execution time (unoptimized to optimized program) in this example might not be typical for all programs, you should be able to improve the execution time for programs running on Intel processors by choosing to optimize your compiled output.  Note also that the Intel C++ compiler optimizes programs at an /O2 level by default.

You can vary the optimization settings and other options to judge their effects on program execution speed, on compilation time, and on compiled code size.

Using the Compiler on Your Own

The procedures in this Getting Started guide show you how to compile, apply/remove optimization, and monitor the output of the example program.  If you have an existing C/C++ source program, there should be no problem in substituting your source file for the example and running it. 

Where from Here?

The examples provided in this Getting Started guide are only an introduction to the capabilities of the Intel C++ compiler.

A Documentation Index file is available that provides links to all of the documentation included with the product.  Refer to the doc_index.htm file.

Detailed information on the Intel C++ Compiler for Windows Systems is presented in the Intel® C++ Compiler documentation.

If you would like more in-depth training on Intel compilers, a Web-based training tutorial on using Intel compilers for software development is included with this product.   Refer to Enhancing Performance with Intel Compilers  located at:
  
   
<install-dir>\Compiler\Training\9.0\Optimize\index.htm

Refer to the product Release Notes document for information about Technical Support and any Limitations that apply to the product.

You can find out about other Intel software development products through the Intel web site at:
http://www.intel.com/software/products/.

Disclaimer and Legal Information

The information in this document is subject to change without notice and Intel Corporation assumes no responsibility or liability for any errors or inaccuracies that may appear in this document or any software that may be provided in association with this document. This document and the software described in it are furnished under license and may only be used or copied in accordance with the terms of the license. No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted by this document. The information in this document is provided in connection with Intel products and should not be construed as a commitment by Intel Corporation.

EXCEPT AS PROVIDED IN INTEL'S TERMS AND CONDITIONS OF SALE FOR SUCH PRODUCTS, INTEL ASSUMES NO LIABILITY WHATSOEVER, AND INTEL DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO SALE AND/OR USE OF INTEL PRODUCTS INCLUDING LIABILITY OR WARRANTIES RELATING TO FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. Intel products are not intended for use in medical, life saving, life sustaining, critical control or safety systems, or in nuclear facility applications.

Designers must not rely on the absence or characteristics of any features or instructions marked "reserved" or "undefined." Intel reserves these for future definition and shall have no responsibility whatsoever for conflicts or incompatibilities arising from future changes to them.

The software described in this document may contain software defects which may cause the product to deviate from published specifications. Current characterized software defects are available on request.

Intel, the Intel logo, Intel SpeedStep, Intel NetBurst, Intel NetStructure, MMX, Intel386, Intel486, Celeron, Intel Centrino, Intel Xeon, Intel XScale, Itanium, Pentium, Pentium II Xeon, Pentium III Xeon, Pentium M, and VTune are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.

Copyright © 2005, Intel Corporation.