In most cases, IPO generates a single object file for the link-time compilation. This behavior is not optimal for very large programs, perhaps even making it impossible to use -ipo (Linux* and Mac OS* X) or /Qipo (Windows*) on the application.
The compiler provides two methods to avoid this problem. The first method is an automatic size-based heuristic, which causes the compiler to generate multiple object files for large link-time compilations. The second method is to manually instruct the compiler to perform multi-object IPO.
Use the -ipoN (Linux and Mac OS X) or /QipoN (Windows) option and pass an integer value in the place of N.
Use the -ipo-separate (Linux and Mac OS X) or /Qipo-separate (Windows) option.
The number of true object files generated by the link-time compilation is invisible to the user unless either the -ipo-c or -ipo-S (Linux and Mac OS X) or /Qipo-c or /Qipo-S (Windows) option is used.
Regardless of the method used, it is best to use the compiler defaults first and examine the results. If the defaults do not provide the expected results then experiment with generating more object files.
You can use the -ipo-jobs (Linux and Mac OS X) or /Qipo-jobs (Windows) option to control the number of commands, or jobs, executed during parallel builds.
If you specify -ipo0 (Linux and Mac OS X) or /Qipo0 (Windows), which is the same as not specifying a value, the compiler uses heuristics to determine whether to create one or more object files based on the expected size of the application. The compiler generates one object file for small applications, and two or more object files for large applications. If you specify any value greater than 0, the compiler generates that number of object files, unless the value you pass a value that exceeds the number of source files. In that case, the compiler creates one object file for each source file then stops generating object files.
The following example commands demonstrate how to use -ipo2 (Linux and Mac OS X) or /Qipo2 (Windows) to compile large programs.
Operating System |
Example Command |
---|---|
Linux and Mac OS X |
icpc -ipo2 -c a.cpp b.cpp |
Windows |
icl /Qipo2 /c a.cpp b.cpp |
Because the example command shown above, the compiler generates object files using an OS-dependent naming convention. On Linux and Mac OS X, the example command results in object files named ipo_out.o, ipo_out1.o, ipo_out2.o, and ipo_out3.o. On Windows, the file names follow the same convention; however, the file extensions will be .obj.
Link the resulting object files as shown in Using IPO or Linking Tools and Options.Linking Tools and Options.
Using -ipo-separate (Linux and Mac OS X) or /Qipo-separate (Windows) allows you to force the compiler to generate the maximum number of true object files that the compiler will support during multiple object compilation.
For example, if you passed example commands similar to the following:
Operating System |
Example Command |
---|---|
Linux and Mac OS X |
icpc -ipo-separate -ipo-c a.o b.o c.o |
Windows |
icl a.obj b.obj c.obj /Qipo-separate /Qipo-c |
The compiler will generate multiple object file, which use the same naming convention discussed above. The first object file contains global variables. The other object files contain code for the functions or routines used the source files.
Link the resulting object files as shown in Using IPO or Linking Tools and Options.Linking Tools and Options.
For many large programs, compiling with IPO can result in a single, large object file. Compiling to produce large objects can create problems for efficient compilation. During compilation, the compiler attempts to swap the memory usage during compiles; a large object file might result in poor swap usage, which could result in out-of-memory message or long compilation times. Using multiple, relatively small object files during compilation causes the system to use resources more efficiently.