Optimizing subroutines with optional parameters in F90 via function cloning

  • Authors:
  • Dibyendu Das

  • Affiliations:
  • Hewlett Packard, Bangalore, India

  • Venue:
  • ACM SIGPLAN Notices
  • Year:
  • 2006

Quantified Score

Hi-index 0.00

Visualization

Abstract

Optional parameters are a feature of Fortran90. The objective of this feature is to allow the F90 programmer to declare a subroutine using a number of arguments and specify a subset of these parameters as optional, which in turn, allows the programmer to omit any of these optional parameters during invocation of the subroutine. The body of such a subroutine uses an F90 intrinsic function called present(), to test whether an optional parameter has meaningful values at run-time. The optional parameter can be written/read if and only if present() returns a true value. In this work, we describe a mechanism by which such subroutines which use optional parameters can be efficiently optimized using function cloning or specialization. Function Cloning is a well-known optimization technique that creates multiple copies of a function f(), in order to exploit better optimization opportunities. We will show how cloning/specialization can be utilized such that all calls to present() can be totally eliminated in the body of such subroutines. Cloning will also result in optimization opportunities not exploitable in the original source.