Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 7/13/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Use Function Order Lists, Function Grouping, Function Ordering, and Data Ordering Optimizations

Instead of doing a full multi-file interprocedural build of your application by using the compiler option [Q]ipo, you can obtain some of the benefits by having the compiler and linker work together to make global decisions about where to place the procedures and data in your application. These optimizations are not supported on macOS systems.

The following table lists each optimization, the type of procedures or global data it applies to, and the operating systems and architectures that it is supported on.

Optimization

Type of Procedure or Data

Supported OS and Architectures

Function Order Lists: Specifies the order in which the linker should link the non-static routines (procedures) of your program. This optimization can improve application performance by improving code locality and reduce paging. Also see Comparison of Function Order Lists and IPO Code Layout.

EXTERNAL procedures and library procedures only (not other types of static procedures).

Windows: all Intel architectures

Linux: not supported

Function Grouping: Specifies that the linker should place the extern and static routines (procedures) of your program into hot or cold program sections. This optimization can improve application performance by improving code locality and reduce paging.

NOTE:
This option will cause functions to be placed into the linker sections named .text.hot and .text.unlikely. If you are using a custom linker script, you will need to specify memory placement for these sections.

EXTERNAL procedures and static procedures only (not library procedures).

Linux: IA-32 and Intel 64 architectures

Windows: not supported

Function Ordering: Enables ordering of static and extern routines using profile information. Specifies the order in which the linker should link the routines (procedures) of your program. This optimization can improve application performance by improving code locality and reduce paging.

EXTERNAL procedures and static procedures only (not library procedures)

Linux and Windows: all Intel architectures

Data Ordering: Enables ordering of static global data items (data in common blocks, module variables, and variables for which the compiler applied the SAVE attribute or statement) based on profiling information. Specifies the order in which the linker should link global data of your program. This optimization can improve application performance by improving the locality of static global data, reduce paging of large data sets, and improve data cache use.

Static global data (data in common blocks, module variables, and variables for which the compiler applied the SAVE attribute or statement) only

Linux and Windows: all Intel architectures

You can only use one of the function-related ordering optimizations listed on each application. However, you can use the Data Ordering optimization with any one of the function-related ordering optimizations listed previously, such as Data Ordering with Function Ordering, or Data Ordering with Function Grouping. In this case, specify the prof-gen option keyword globdata (needed for Data Ordering) instead of srcpos (needed for function-related ordering).

The following sections show the commands needed to implement each of these optimizations: function order list, function grouping, function ordering, and data ordering. For all of these optimizations, omit the [Q]ipo or equivalent compiler option.

Generate a Function Order List on Windows

This section provides an example of the process for generating a function order list. Assume you have a Fortran program that consists of the following files: file1.f90 and file2.f90. Additionally, assume you have created a directory for the profile data files called c:\profdata. You would enter commands similar to the following to generate and use a function order list for your Windows application.

  1. Compile your program using the /Qprof-gen:srcpos option. Use the /Qprof-dir option to specify the directory location of the profile files. This step creates an instrumented executable:

    ifort /exe:myprog /Qprof-gen:srcpos /Qprof-dir c:\profdata file1.f90 file2.f90
  2. Run the instrumented program with one or more sets of input data. Change your directory to the directory where the executables are located. The program produces a .dyn file each time it is executed:

    myprog.exe
  3. Before this step, copy all .dyn and .dpi files into the same directory. Merge the data from one or more runs of the instrumented program by using the profmerge tool to produce the pgopti.dpi file. Use the /prof_dir option to specify the directory location of the .dyn files:

    profmerge /prof_dir c:\profdata
  4. Generate the function order list using the proforder tool. By default, the function order list is produced in the file proford.txt:

    proforder /prof_dir c:\profdata /o myprog.txt
  5. Compile the application with the generated profile feedback by specifying the ORDER option to the linker. Use the /Qprof-dir option to specify the directory location of the profile files:

    ifort /exe:myprog Qprof-dir c:\profdata file1.f90 file2.f90 /link /ORDER:@MYPROG.txt

Use Function Grouping on Linux

This section provides a general example of the process for using the function grouping optimization. Assume you have a Fortran program that consists of the following files: file1.f90 and file2.f90. Additionally, assume you have created a directory for the profile data files called profdata. You would enter commands similar to the following to use a function grouping for your Linux application.

  1. Compile your program using the -prof-gen option. Use the -prof-dir option to specify the directory location of the profile files. This step creates an instrumented executable:

    ifort -o myprog -prof-gen -prof-dir ./profdata file1.f90 file2.f90
  2. Run the instrumented program with one or more sets of input data. Change your directory to the directory where the executables are located. The program produces a .dyn file each time it is executed:

    ./myprog
  3. Copy all .dyn and .dpi files into the same directory. If needed, you can merge the data from one or more runs of the instrumented program by using the profmerge tools to produce the pgopti.dpi file.

  4. Compile the application with the generated profile feedback by specifying the -prof-func-group option to request the function grouping as well as the -prof-use option to request feedback compilation. Again, use the -prof-dir option to specify the location of the profile files:

    ifort /exe:myprog file1.f90 file2.f90 -prof-func-group -prof-use -prof-dir ./profdata
NOTE:
On Linux, the –prof-func-group option is on by default when –prof-use is selected.

Finer grain control over the number of functions placed into the hot region can be controlled with the -prof-hotness-threshold compiler option. See the command line reference for more details.

Use Function Ordering

This section provides an example of the process for using the function ordering optimization. Assume you have a Fortran program that consists of the following files: file1.f90 and file2.f90, and that you have created a directory for the profile data files called c:\profdata (on Windows) or ./profdata (on Linux). You would enter commands similar to the following to generate and use function ordering for your application.

  1. Compile your program using the -prof-gen=srcpos (Linux) or /Qprof-gen:srcpos (Windows) option. Use the [Q]prof-dir option to specify the directory location of the profile files. This step creates an instrumented executable:

    Linux

    ifort -o myprog -prof-gen=srcpos -prof-dir ./profdata file1.f90 file2.f90

    Windows

    ifort /exe:myprog /Qprof-gen:srcpos /Qprof-dir c:\profdata file1.f90 file2.f90
  2. Run the instrumented program with one or more sets of input data. Change your directory to the directory where the executables are located. The program produces a .dyn file each time it is executed:

    Linux

    ./myprog

    Windows

    myprog.exe
  3. Copy all .dyn and .dpi files into the same directory. If needed, you can merge the data from one or more runs of the instrumented program by using the profmerge tools to produce the pgopti.dpi file.

  4. Compile the application with the generated profile feedback by specifying the [Q]prof-func-order option to request the function ordering, as well as the [Q]prof-use option to request feedback compilation. Again, use the [Q]prof-dir option to specify the location of the profile files:

    Linux

    ifort -o myprog -prof-dir ./profdata file1.f90 file2.f90 -prof-func-order -prof-use

    Windows

    ifort /exe:myprog /Qprof-dir c:\profdata file1.f90 file2.f90 /Qprof-func-order /Qprof-use

Use Data Ordering

This section provides an example of the process for using the data order optimization. Assume you have a Fortran program that consists of the following files: file1.f90 and file2.f90, and that you have created a directory for the profile data files called c:\profdata (on Windows) or ./profdata (on Linux). You would enter commands similar to the following to use data ordering for your application.

  1. Compile your program using the -prof-gen=globdata (Linux) or /Qprof-gen:globdata (Windows) option. Use the -prof-dir (Linux) or /Qprof-dir (Windows) option to specify the directory location of the profile files. This step creates an instrumented executable.

    Linux

    ifort -o myprog -prof-gen=globdata -prof-dir ./profdata file1.f90 file2.f90

    Windows

    ifort /exe:myprog /Qprof-gen:globdata /Qprof-dir c:\profdata file1.f90 file2.f90
  2. Run the instrumented program with one or more sets of input data. If you specified a location other than the current directory, change your directory to the directory where the executables are located. The program produces a .dyn file each time it is executed.

    Linux

    ./myprog

    Windows

    myprog.exe
  3. Copy all .dyn and .dpi files into the same directory. If needed, you can merge the data from one or more runs of the instrumented program by using the profmerge tools to produce the pgopti.dpi file.

  4. Compile the application with the generated profile feedback by specifying the [Q]prof-data-order option to request the data ordering as well as the [Q]prof-use option to request feedback compilation. Again, use the [Q]prof-dir option to specify the location of the profile files:

    Linux

    ifort -o myprog -prof-dir ./profdata file1.f90 file2.f90 -prof-data-order -prof-use

    Windows

    ifort /exe:myprog Qprof-dir c:\profdata file1.f90 file2.f90 /Qprof-data-order /Qprof-use