SimCon logo

SimCon - Fortran Analysis, Engineering & Migration

  FPT Reference ManualDownloadsLicensingHome

FPT - Fortran Code Optimisation
Code Optimisation

FPT carries out in-line expansion of subroutines and functions, and unwinds DO loops, to optimise code for speed of execution. The effects of the optimisations depend on the host architecture. There are trade-offs between processor speed, memory speed and instruction cache size. Run times are typically improved by 20% to 40%, and by as much as a factor of two or more on high performance processors inhibited by memory speed.

Sub-program calls may interfere seriously with compiler optimisations. Click here for an example.

FPT comments the changes that it makes in the expanded code, so that it remains readable for debugging. The linear interpolation function, 'INTERP1' called in the example above can be seen by clicking here. FPT expands the call - as shown here.

Note that the modified code is marked by bars across the text, and the original statement, the assignment of 'FR', remains in place but is commented-out. The formal arguments in the function have been replaced by the actual arguments to the call.

In this example, there was no variable named 'I' in the scope of the expanded statement, so the name of the variable 'I' in the function was retained. Variables are renamed if name clashes occur. Declarations of variables used in the expansion are inserted in the routines which require them, and they are moved to COMMON blocks if they have a SAVE attribute or are SAVEd by default.

In-line expansion may be carried out quickly and easily, and it is recommended that users maintain code in unexpanded form. FPT may therefore be used to resolve a common conflict in the maintenance of large programs. It is good practice to encapsulate small, frequently used operations, such as accesses to data structures, in subroutines or functions. Maintenance changes are then made in only one place. However, a large number of sub-program calls slow down program execution.

By using FPT, users may choose to encapsulate primitive operations and to expand the calls in-line before the release of production code.

In-line expansion and loop unwinding are controlled by the FPT commands EXPAND INLINE and UNWIND LOOPS. The commands INLINE and UNWIND may be written in the code to mark candidate routines and loops for expansion.

Copyright ©1995 to 2014 Software Validation Ltd. All rights reserved.