Profiling an application includes the following three phases:
This topic provides detailed information on how to profile an application by providing sample commands for each of the three phases (or steps).
Instrumentation compilation and linking
Use -prof-gen (Linux* and Mac OS* X) or /Qprof-gen (Windows*) to produce an executable with instrumented information included.
Operating System |
Commands |
---|---|
Linux and Mac OS X |
icpc -prof-gen -prof-dir/usr/profiled a1.cpp a2.cpp a3.cpp icpc a1.o a2.o a3.o |
Windows |
icl /Qprof-gen /Qprof-dirc:\profiled a1.cpp a2.cpp a3.cpp icl a1.obj a2.obj a3.obj |
Use the -prof-dir (Linux and Mac OS X) or /Qprof-dir (Windows) option if the application includes the source files located in multiple directories; using the option insures the profile information is generated in one consistent place. The example commands demonstrate how to combine these options on multiple sources.
The compiler gathers extra information when you use the -prof-gen=srcpos (Linux and Mac OS X) or /Qprof-gen:srcpos (Windows) option; however, the extra information is collected to provide support only for specific Intel tools, like the code-coverage tool. If you do not expect to use such tools, do not specify -prof-gen=srcpos (Linux and Mac OS X) or /Qprof-gen:srcpos (Windows); the extended option does not provide better optimization and could slow parallel compile times.
Run your instrumented program with a representative set of data to create one or more dynamic information files.
Operating System |
Command |
---|---|
Linux and Mac OS X |
./a1.out |
Windows |
a1.exe |
Executing the instrumented applications generates dynamic information file that has a unique name and .dyn suffix. A new dynamic information file is created every time you execute the instrumented program.
You can run the program more than once with different input data.
Before this step, copy all .dyn and .dpi files into the same directory. Compile and link the source files with -prof-use (Linux and Mac OS X) or /Qprof-use (Windows); the option instructs the compiler to use the generated dynamic information to guide the optimization:
Operating System |
Examples |
---|---|
Linux and Mac OS X |
icpc -prof-use -ipo -prof-dir/usr/profiled a1.cpp a2.cpp a3.cpp |
Windows |
icl /Qprof-use /Qipo /Qprof-dirc:\profiled a1.cpp a2.cpp a3.cpp |
This final phase compiles and links the sources files using the data from the dynamic information files generated during instrumented execution (phase 2).
In addition to the optimized executable, the compiler produces a pgopti.dpi file.
Most of the time, you should specify the default optimizations,-02 (Linux and Mac OS X) or /O2 (Windows), for phase 1, and specify more advanced optimizations, -ipo (Linux) or /Qipo (Windows), during the final (phase 3) compilation. For example, the example shown above used-O2 (Linux and Mac OS X) or /O2 (Windows) in step 1 and-ipo (Linux or Mac OS X) or /Qipo (Windows) in step 3.
The compiler ignores the -ipo or -ip (Linux and Mac OS X) or /Qipo or /Qip (Windows) option during phase 1 with -prof-gen (Linux and Mac OS X) or /Qprof-gen (Windows).