Re: Cannot optimize 64bit Linux code
- From: "Bartc" <bc@xxxxxxxxxx>
- Date: Fri, 29 Feb 2008 00:37:22 GMT
<legrape@xxxxxxxxx> wrote in message
news:83f5f291-4c86-48f6-8625-5ead760a46bf@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I am porting a piece of C code to 64bit on Linux. I am using 64bit
integers. It is a floating point intensive code and when I compile
(gcc) on 64 bit machine, I don't see any runtime improvement when
optimizing -O3. If I construct a small program I can get significant
(>4x) speed improvement using -O3 versus -g. If I compile on a 32 bit
machine, it runs 5x faster on the 64 bit machine than does the 64bit
compiled code.
It seems like something is inhibiting the optimization. Someone on
comp.lang.fortran suggested it might be an alignment problem. I am
trying to go through and eliminate all 32 bit integers righ now (this
is a pretty large hunk of code). But thought I would survey this
group, in case it is something naive I am missing.
Any opinion is welcomed. I really need this to run up to speed, and I
need the big address space. Thanks in advance.
Hesitant to attempt an answer as I know nothing about 64-bit or gcc, but..
Does the program compiled in 32-bit mode run faster when compiled with
optimisation than without (or a 32 or 64-bit machine)? In other words, what
scale of improvement are you expecting? (This on the main program)
Is the improvement really likely to be 5x or more? If not, that sounds like
something wrong with the 64-bit-compiled version, forget the optimisation,
if the 32-bit version can run that much faster.
Do you have the capability to look at a sample of code and see what
exactly is the 64-compiler generating? I doubt it's going to be as silly as
using (and emulating) 128-bit floats, but it does sound like there's
something seriously wrong. It seems unlikely that using int32 instead of
int64 would slow things down 5 times or more.
An alignment fault would be a compiler error; but you can print out a few
data addresses and see whether they are on 8/16-byte boundaries or whatever
is recommended.
Is the small program doing anything similar to the big one? It may be
benefiting from smaller instruction/data cache requirements.
You might find that ints/pointers suddenly turn from 32-bits to 64-bits when
compiled on 64-bit (and therefore using twice the memory bandwidth if you
have a lot of them), that might hit some of the performance. You might like
to check the size of pointers, if you don't need 64-bit addressing.
--
Bart
.
- Follow-Ups:
- Re: Cannot optimize 64bit Linux code
- From: cr88192
- Re: Cannot optimize 64bit Linux code
- References:
- Cannot optimize 64bit Linux code
- From: legrape
- Cannot optimize 64bit Linux code
- Prev by Date: Re: Cannot optimize 64bit Linux code
- Next by Date: Free online Games play and free download - Intelligent games
- Previous by thread: Re: Cannot optimize 64bit Linux code
- Next by thread: Re: Cannot optimize 64bit Linux code
- Index(es):
Relevant Pages
|