• 2019 Update 7
  • 03/31/2020

Compiling an MPI Program

Intel® MPI Library Developer Guide for Linux* OS
This topic describes the basic steps required to compile and link an MPI program, using the Intel® MPI Library SDK.
To simplify linking with MPI library files, Intel MPI Library provides a set of compiler wrapper scripts with the
prefix for all supported compilers. To compile and link an MPI program, do the following:
  1. Make sure you have a compiler in your
    environment variable. For example, to check if you have the Intel® C Compiler, enter the command:
    $ which icc
    If the command is not found, add the full path to your compiler into the
    . For Intel® compilers, you can source the
    script to set the required environment variables.
  2. Source the
    script to set up the proper environment for Intel MPI Library. For example, using the Bash* shell:
    $ . <installdir>/intel64/bin/mpivars.sh
  3. Compile your MPI program using the appropriate compiler wrapper script. For example, to compile a C program with the Intel® C Compiler, use the
    script as follows:
    $ mpiicc myprog.c -o myprog
You will get an executable file
in the current directory, which you can start immediately. For instructions of how to launch MPI applications, see Running an MPI Program .
By default, the resulting executable file is linked with the multi-threaded optimized library. If you need to use another library configuration, see Selecting Library Configuration .
For details on the available compiler wrapper scripts, see the
Developer Reference

Compiling an MPI/OpenMP* Program

To compile a hybrid MPI/OpenMP* program using the Intel® compiler, use the
option. For example:
openmp test.c
-o testc
This enables the underlying compiler to generate multi-threaded code based on the OpenMP* pragmas in the source. For details on running such programs, refer to Running an MPI/OpenMP* Program .

Adding Debug Information

If you need to debug your application, add the
option to the compilation command line. For example:
$ mpiicc -g test.c -o testc
This adds debug information to the resulting binary, enabling you to debug your application. Debug information is also used by analysis tools like Intel® Trace Analyzer and Collector to map the resulting trace file to the source code.

Test MPI Programs

Intel® MPI Library comes with a set of source files for simple MPI programs that enable you to test your installation. Test program sources are available for all supported programming languages and are located at
, where
by default.

See Also

Intel® MPI Library Developer Reference, section
Command Reference > Compiler Commands

Product and Performance Information


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.

Notice revision #20110804