Automatically transform or expand do loop in a subroutine
- From: yaqi <yaqiwang@xxxxxxxxx>
- Date: Wed, 30 Jan 2008 20:15:54 -0800 (PST)
Hi All,
I knew following piece of code will not be compiled, at least with
Compaq Visual Fortran. My intention of this code is to let the
compiler automatically transform or expand the loop inside the
function (I do not care the code size) if the caller has a SMALL
CONSTANT integer 'd' in its argument list when the compiler is doing
optimization. Because the function is really crucial for the
performance, I want to save computing time as much as I can. So do not
ask me why I want to do this. Actually I guess this idea is similar as
the template in C++.
Are there any ways to implement this idea easily with Fortran?
Thanks!
--------------------------------------------------------------------------
program main
integer :: e, c
e = ad(c, 10)
stop
end program main
integer function ad(c,d)
implicit none
integer :: c
integer, parameter :: d
integer :: i
do i=1,d
c = c + i
end do
ad = c
return
end function
.
- Follow-Ups:
- Re: Automatically transform or expand do loop in a subroutine
- From: *** Hendrickson
- Re: Automatically transform or expand do loop in a subroutine
- From: Gordon Sande
- Re: Automatically transform or expand do loop in a subroutine
- From: Louis Krupp
- Re: Automatically transform or expand do loop in a subroutine
- From: Arjen Markus
- Re: Automatically transform or expand do loop in a subroutine
- From: James Van Buskirk
- Re: Automatically transform or expand do loop in a subroutine
- From: Richard Maine
- Re: Automatically transform or expand do loop in a subroutine
- Prev by Date: Re: The concept of a record
- Next by Date: Re: The concept of a record
- Previous by thread: How to quote the " character in a format statement?
- Next by thread: Re: Automatically transform or expand do loop in a subroutine
- Index(es):