c++ – How to avoid results change when moving from 32 bit to 64 bit system? – Education Career Blog

Lately I run my C++ program that was built and tuned in 32 bit system on a 64 bit system and I notice there are some bad performance changes. In my code, I used a lot float point variables. Now I suspect this may be the reason for the bad changes. Is there anyway to avoid such performance changes when moving code from 32bit to 64 bit system? Thanks for the helps.

,

I’m not 100% certain about this (probably closer to 20%), but if your 32-bit floating point variables are packed tightly together in an array or struct (you mentioned it was tuned for 32-bit), every second one could be “misaligned”, causing an overhead/delay in reading/writing to that address. Ideally objects should be aligned on 8-byte boundaries for a 64-bit system. On some systems, objects must be properly aligned.

,

I doubt it’s that you’ve used a lot of floating point variables. More likely the system (which you’ve not given any details about) is thunking badly 32 bit -> 64 bit.

The classic example of this is running a program compiled for Windows 32 bit and then running it on an Itanium 2 Windows 64 bit system. The WoW64 subsystem providing support for this kind of operation will need to convert the x86 instructions to Itanium instructions as well as support the 32 bit application’s address space. Itanium instruction are very different from x86. However doing the same thing on x64 will be much cheaper since x64 instructions are kind of a superset of x86.

I hope this helps. Since I know nothing about the specifics of your situation I’m not sure I can help you more at this point.

Leave a Comment