Guillermo Ballester Valor wrote:

> i) MacLucasUNIX uses intensively the 'register' key in local
> definitions, so a processor with many internal registers can allocate
> most of them. It is a good thing because they can be accessed very fast.
> The bad thing that is that in processors with very few registers (like
> intel's) it can slowdown the speed. 

Brian Beesley replied:

<< And (according to a local computer scientist, who I think knows what 
he's talking about) with modern processors making extensive use of 
register renaming, it's not usually sensible to use the "register" 
keyword _at all_. The theory is that the instruction scheduler can do 
at least as good a job as the programmer >>

Indeed. I note that when I tried to compile MacLucasUNIX on my Alpha,
the C compiler gave me an error message about being unable to allocate
sufficient registers in routine FFT_IFFT8 - I had to delete the "register"
keyword in that routine to get it to compile. The most complex, register-
greedy routine in my Mlucas code, wrapper_square, defines 103 floating-
point temporaries, any of which deserves the "register" keyword (were
such available in f90, which it isn't) as much as the others. However,
typically at most 30 of these temporaries need be in registers at any
one time, and a good compiler should be able to decide which registers
to use for what and when at least as well (or better) than I can. Since
such decisions are going to be hardware-dependent anyway, it's better
to leave it up to the compiler.

The other nice thing about letting the compiler do this for you is that
one can use meaningful variable names, and need not worry too much about
minimizing the number of temporaries, which leads to excessive re-use
of the same temporary names, and makes understanding/debugging the code
harder.

On the other hand, I was under the impression that the C "register"
keyword was intended as a suggestion to the compiler, not an absolute,
i.e. that compilers should be free to heed or ignore the programmer's
advice on this point. Looks like whether that's true depends on the compiler.

-Ernst

_________________________________________________________________
Unsubscribe & list info -- http://www.scruz.net/~luke/signup.htm
Mersenne Prime FAQ      -- http://www.tasam.com/~lrwiman/FAQ-mers

Reply via email to