Windows x64, a story about porting

July 14th, 2011

We’ve finished a “port” of one of our larger Windows/Linux projects from Visual Studio 2003, to Visual Studio 2010(sp1) in order to create a Windows x64 version.

We had stayed with Visual Studio 2003 due to the performance advantage.  Visual Studio 2005, and 2008 both generated slower binaries.  Also, we were required to maintain support for Windows 98 and 2000!

Now we’re finally biting the bullet and saying that Windows XP(SP3) (or XPx64 SP2) is the minimum supported platform.

Performance Numbers for our “rule of thumb” benchmark:

  • Visual Studio 2003 (x86)
    • Time: 117.497235 ms
    • Time: 1136.909457 ms
    • Time: 126.083901 ms
    • Time: 1133.747273 ms
  • Visual Studio 2010 (x86) with PGO
    • Time: 112.262443 ms
    • Time: 893.446397 ms
    • Time: 129.282765 ms
    • Time: 882.757780 ms
  • Visual Studio 2010 (x64) with PGO
    • Time: 108.315252 ms
    • Time: 880.750309 ms
    • Time: 137.448487 ms
    • Time: 885.515196 ms

Without PGO, the execution times for Visual Studio 2010 are 25% longer.  So, PGO is well worth doing!

How we did the port

The process itself was fairly painless.  We started by updating all out 3rd party libraries: boost, Qt, etc.  Then we converted each of our projects to VS2010.  After converting them, we reviewed the project files to ensure that we understood each and every setting that was being applied.  This seemed to be the longest part of the process!

We did think about using qmake to abstract the build process another level.  The rewards just didn’t outweigh the effort.  We have a set of makefiles for Linux already, and we’re stuck with VS2010 for the conceivable future.

After the x86 projects were converted, we built and fixed a handful of issues from VS2003 being a bit more forgiving than VS2010.  We also added a number of #pragma’s around code blocks to prevent warnings that were understood, but not wanted.  

Adding a x64 Target was accomplished by several clicks, followed by another trip through the project files. 

Building the x64 version ended up being fairly painless.  We had to replace some x86 assembly:

align 16
    public  _AFTOL@8
_AFTOL@8:
    fld     qword ptr FVAL
    fistp   dword ptr IVAL
    mov     eax, IVAL
    ret     RETSIZE

inline int iFTOL(double d)
{
    return _mm_cvttsd_si32(_mm_load_sd(&d));
}

We also discovered that fopen() under VS2010 is much more strict than fopen() under VS2003 (unit tests are worth their weight in gold).  Yes we still use FILE’s, our testing shows that they are faster than HANDLE’s for file IO (likely because they buffer in User mode memory).

The entire process was fairly easy, but also time consuming.  Our codebase is over 1 MLOC.  From start to beta was 6 man weeks including unit testing, manual testing, and building the PGO scripts.

The wisdom I can pass along is to plan your port, take your time, and invest in unit tests.

Entry Filed under: Uncategorized

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Calendar

July 2011
M T W T F S S
« May   Oct »
 123
45678910
11121314151617
18192021222324
25262728293031

Most Recent Posts