| Rick Smith 2005-07-25, 10:02 pm |
|
"Joe Zitzelberger" <joe_zitzelberger@nospam.com> wrote in message
news:joe_zitzelberger-2F5770.11542623072005@ispnews.usenetserver.com...
> In article <11due6mb9fhfac3@corp.supernews.com>,
> "Rick Smith" <ricksmith@mfi.net> wrote:
>
> <snip>
>
>
> Interesting, but you seem to have intentionally handicapped the loop
> version.
>
> Had you written it like this:
>
> "perform varying strlen-1 from length of str by -1"
>
> Then you would have had a flexible routine that will work in pretty much
> any case and could be reused frequently. This benefit would surely
> outweigh the trivial speed gain you would receive from the unrolled-loop
> version.
It is not clear to me that I "intentionally handicapped" anything.
I do not use LENGTH OF because it is non-standard and, with
the exception of COMP-5, I believe the extensions that I did use
(such as, unnamed paragraphs in sections, exit perform, and
partial expressions in the EVALUATE statement) are all
available in the 2002 standard. For flexibility, I would normally
write something like:
compute x = function length (str)
perform varying strlen from x by -1 ...
This is, at least, standard. However, flexibility was not a
consideration, code size was.
> Consider also that an optimizing compiler is likely to unroll the loop
> version for you if all of the necessary values are known at compile time.
The optimizing compiler I use does not unroll loops. In fact,
when I enabled some specific optimizations (OPTSPEED and
NOTRICKLE), the loop version slowed and the unrolled loop
sped up for lengths of 0 and 16, but slowed for a length of 32.
There is something happening that I do not yet, and may never,
understand; but the program was unimportant for all but one
reason.
> It is likely that the unrolled version of the code will never recover in
> runtime the amount of typing type the programmer spent writing it.
Which has nothing to do with the reason for the code. The
code was presented to demonstrate that *sometimes* larger
is faster. I was aware of this because I have unrolled loops
before and achieved speed gains on the order of 50 to 800
percent, in long running programs; that is, those programs
were the speed up was important (savings of hours per
execution, sometimes a hundred or more hours per year).
|