Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* how efficient are functions
@ 1999-08-13  2:47 Christopher T. Lansdown
  1999-08-13  4:06 ` Wes Bauske
  0 siblings, 1 reply; 2+ messages in thread
From: Christopher T. Lansdown @ 1999-08-13  2:47 UTC (permalink / raw)
  To: axp-list

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

-- 
lansdoct@cs.alfred.edu
"If I had had more time I would have not written you at all." - Pascal
Linux Programs: http://cs.alfred.edu/~lansdoct/linux/
Linux - Get there. Today.
Evil Overlord Quote of the Day:
150.I will provide funding and research to develop tactical and strategic
weapons covering a full range of needs so my choices are not limited to
"hand to hand combat with swords" and "blow up the planet".


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: how efficient are functions
  1999-08-13  2:47 how efficient are functions Christopher T. Lansdown
@ 1999-08-13  4:06 ` Wes Bauske
  0 siblings, 0 replies; 2+ messages in thread
From: Wes Bauske @ 1999-08-13  4:06 UTC (permalink / raw)
  To: axp-list

"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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-08-13  4:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-08-13  2:47 how efficient are functions Christopher T. Lansdown
1999-08-13  4:06 ` Wes Bauske

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