CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: 32bit or 64 bit

  1. #1
    Join Date
    May 2010
    Posts
    24

    Question 32bit or 64 bit

    Hi everyone...

    I'm working in a project that uses C++ and I want to get the best performance possible. My software code should be platform independent, so I can run it in any OS.
    Today, I am compiling the project only for 32 bit machines, forcing the OS of 64 bit machines to translate the compiled instructions.

    My question is: This approach I've chosen (compile only in 32 bit) impacts the performance negatively if I run it in a 64 bit machine? Is so, would it be slower than a 32 bit machine (completely equivalent machine, but 32 bit), or it would have the same speed?


    Thanks in advance for your attention

  2. #2
    Join Date
    Aug 2002
    Location
    Madrid
    Posts
    4,588

    Re: 32bit or 64 bit

    It's pretty much the same speed on most processors.

    However, why don't you also add a 64bit executable? If it's a new project, I think that would definitely make sense and then you could have speed increases over 32 bit.
    Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
    Supports C++ and VB out of the box, but can be configured for other languages.

  3. #3
    Join Date
    Jan 2009
    Posts
    1,689

    Re: 32bit or 64 bit

    If using lots of memory, then 64-bit can produce a huge speed boost as there is less swapping. What is your project?

  4. #4
    Join Date
    May 2010
    Posts
    24

    Exclamation Re: 32bit or 64 bit

    Yves
    The problem is that if we compile to 64 here, we will have to duplicate the number of tests - we would test everything in both, the 32 bit and the 64 bit to make sure there is no incompatibility (it's kind of company's rules, we have no choice here).

    ninja
    My project is being developed using QT, and will have animation and some fancy graphics to make an attractive UI mainly to touch devices, but also for netbooks, notebooks, etc. Our starting version does not use much memory, and we hope not to use too much, since some of our target are devices with low processing capability (that's why I need a good performance).


    So, by the answers I got until now, I believe there's no problem in compiling only the 32 bit version... Does anyone have another opinion?

  5. #5
    Join Date
    Jun 2009
    Location
    France
    Posts
    2,513

    Re: 32bit or 64 bit

    Well from what I understood, 64 bits is only faster when using huge amounts of memory, so typically for image processing software (photoshop), video editing etc. For any other program, (especially on embedded platforms), there are no gains to be had.
    Is your question related to IO?
    Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
    It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.

  6. #6
    Join Date
    Jan 2009
    Posts
    1,689

    Re: 32bit or 64 bit

    I would probably just recommend going with whatever is standard for the platform. Windows is still in the switching period, but Apple finished their switch 5 years ago, so if you build for OSX, go with 64, it is optimized for 64-bit. Linux still has a lot of distros in both though.

  7. #7
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: 32bit or 64 bit

    Usually 64-bit architectures have a larger number of registers available, and only programs compiled for 64-bit get access to all of them. So speed could be an issue too. You really need to try it and see; there are a lot of variables.

  8. #8
    Join Date
    Aug 2002
    Location
    Madrid
    Posts
    4,588

    Re: 32bit or 64 bit

    Quote Originally Posted by monarch_dodra View Post
    Well from what I understood, 64 bits is only faster when using huge amounts of memory, so typically for image processing software (photoshop), video editing etc. For any other program, (especially on embedded platforms), there are no gains to be had.
    No, the memory issue is an aside (that can be very helpful of course, but still).
    64 bit code is faster in these situations:
    • Your program has integer arithmetic takes advantage of 64 bit values.
      Examples are image processing libraries, matrix libraries, scientific calculations, cryptography. These benefit a lot and get to sometimes 3 to 3.5 times faster on 64 bit as compared to 32 bit. However, you (or the library developer) usually has to change the algorithms slightly to take advantage of the extra space.
      In your case, this might apply for your image processing.
    • The compiler can take advantage of the extra registers and thus speed up inner loops and other bottlenecks. The speed up is most of the time negligeable, unless you explicitly optimize your inner loops for this.
    • Huge memory requirements are an issue and you run on machines with more than 4GB of memory.
      This is quite rare and doesn't seem to apply to your case anyways.
    Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
    Supports C++ and VB out of the box, but can be configured for other languages.

  9. #9
    Join Date
    May 2010
    Posts
    24

    Resolved Re: 32bit or 64 bit

    Thank's for all answers, guys. It was very helpful.
    However, I have one extra request. Does anyone have or know an article or even a book where this comparison is made, or where the performance of 64 bit processor's are analyzed, so I can use it as a reference? I've googled it and I didn't find relevant information outside forums (maybe I was searching with the wrong terms...).

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured