Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: "Wes Bauske" <wsb@paralleldata.com>
To: axp-list@redhat.com
Subject: Re: how efficient are functions
Date: Thu, 12 Aug 1999 23:06:39 -0500	[thread overview]
Message-ID: <37B399CF.537B2135@paralleldata.com> (raw)
In-Reply-To: Pine.LNX.4.10.9908122246180.24621-100000@Screech

"Christopher T. Lansdown" wrote:
> 
> Hi,
>         How efficient are function calls on the Alpha?  For small (3-10
> liners) functions, is it a real speed gain to use MACROs instead?  Btw, is
> there a better place for me to be asking this sort of stuff than this
> list?
>         -Chris
> 

Depends what the code does.

If it's C, use a macro or inline the function if you can.

Some teachers go overboard with modularization if you ask
me. My rule is the subroutine/function has to be at least
100 clock cycles to be separated as a useful routine. So,
a routine that has a for/do loop in it can be quite small
but qualify to be a separate routine. Otherwise, it would
need to be a fair number of statements to be separated.
The key is to understand the overhead cost in clock cycles
and compare it to the work the routine will do. Then you 
just decide how much overhead you want to tolerate.

Of course, this assumes you're willing to read a little
ASM to see what the generated code looks like. Otherwise,
figure your average statement "a=b+c" involves 2 loads,
an add, and a store. Ignoring pipelining/memory effects,
thats 4 clocks. Doing this, you can figure out how much
work your routine does, at least approximately.

Of course, if you only call the routine once or twice, it
won't matter anyway. This all only gets interesting when
the code is in your main computing path.


Wes


      reply	other threads:[~1999-08-13  4:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-13  2:47 how efficient are functions Christopher T. Lansdown
1999-08-13  4:06 ` Wes Bauske [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox