Inlining functions using *CONTAINS* statement
From: Arindam Chakraborty (arimail77_at_yahoo.com)
Date: 10/26/04
- Next message: Stig Kildegård Andersen: "Re: Best number crunching solution under $10,000 ?"
- Previous message: Kamaraju Kusumanchi: "Re: graphics with g77 GNU fortran compiler"
- Next in thread: Tim Prince: "Re: Inlining functions using *CONTAINS* statement"
- Reply: Tim Prince: "Re: Inlining functions using *CONTAINS* statement"
- Reply: beliavsky_at_aol.com: "Re: Inlining functions using *CONTAINS* statement"
- Reply: Paul Van Delst: "Re: Inlining functions using *CONTAINS* statement"
- Reply: Richard E Maine: "Re: Inlining functions using *CONTAINS* statement"
- Reply: James Giles: "Re: Inlining functions using *CONTAINS* statement"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 25 Oct 2004 21:40:30 -0700
Hi,
I wish to inline a function in a loop, but I can't manually replace
the function call with its source code since the function is a HIGH
maintenance function and will be updated/modified frequently. The loop
is a high traffic loop and takes up 99% of the total run time of the
code. Right now I am using compiler directives to do the inlining, but
I will like to hardcode it into the program. By the way, the code is
written in F90.
[1]. Is there any way to inline a function (maybe using CPP
directives, or include statements) without replacing the function call
with its source code.
[2]. Does it matter in optimization and inlining (by compiler) if a
function is defined using the CONTAINS statement within the calling
program?
[3]. Any tips for optimizing big loop and functions calls will be very
useful.
Here is an example (test codes are listed below):
Given a compiler (xlf90, pgf90, ifort) and a optimization level (say
O5) will program prog1 be better optimized than prog2 ?
Thanks in advance,
-Ari
PROGRAM prog1
implicit none
integer :: i,N
double precision :: x,y
! N is very large ~10**12
do i=1,N
y = bigfunc(x)
end do
CONTAINS
FUNCTION bigfunc(x)
: : :
: : :
: : :
END FUNCTION bigfunc
END PROGRAM prog1
PROGRAM prog2
implicit none
integer :: i,N
double precision :: x,y,bigfunc
! N is very large ~10**12
do i=1,N
y = bigfunc(x)
: : :
: : :
end do
END PROGRAM prog2
FUNCTION bigfunc(x)
: : :
: : :
: : :
END FUNCTION bigfunc
- Next message: Stig Kildegård Andersen: "Re: Best number crunching solution under $10,000 ?"
- Previous message: Kamaraju Kusumanchi: "Re: graphics with g77 GNU fortran compiler"
- Next in thread: Tim Prince: "Re: Inlining functions using *CONTAINS* statement"
- Reply: Tim Prince: "Re: Inlining functions using *CONTAINS* statement"
- Reply: beliavsky_at_aol.com: "Re: Inlining functions using *CONTAINS* statement"
- Reply: Paul Van Delst: "Re: Inlining functions using *CONTAINS* statement"
- Reply: Richard E Maine: "Re: Inlining functions using *CONTAINS* statement"
- Reply: James Giles: "Re: Inlining functions using *CONTAINS* statement"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|