Porting to 64-Bit Intel® Architecture

Introduction

By Andrew Binstock

Due to the strategic importance of the 64-bit Intel® Itanium architecture and Intel® Extended Memory 64 Technology (Intel® EM64T) to Intel's growth, the company has put numerous resources in place to assist developers in porting software. As discussed elsewhere on this site, 64-bit computing places different demands upon the developer than 32-bit computing.


Porting Application Source Code

The most significant issues that software developers should face in porting source code to the 64-bit world concern the changes in pointer size and fundamental integer types. As such, these differences should appear most prominently in C and C++ programs. Code written in Fortran*, COBOL*, Visual Basic* and most other languages (except assembly language, which must be completely rewritten), will need no modification. A simple recompilation is often all that is needed. Java* code should not even need recompilation; Java classes should execute the same on a 64-bit JVM as on any 32-bit virtual machine.

C (from here on, C++ is included in all discussions of C) code, however, by allowing casting across types and direct access to machine-specific integral types will need some attention.  The first aspect is the size of pointers; 64-bit operating systems use 64-bit pointers. As a result, structures that contain pointers will have different sizes as well. As such, if data laid out for these structures is stored on disk, reading it in or writing it out will cause errors. Likewise, unions with pointer fields will have different sizes and can cause unpredictable results.

The greatest effect, though, is felt wherever pointers are cast to integral types. This practice, which has been condemned for years as inimical to portability, will come back to haunt programmers who did not abandon it. The problems caused by it are traceable to the different widths used by pointers, integers and longs on the various platforms. Let's examine these.

Microsoft Windows* – Microsoft's Windows 64 (or Win64*) migrates from the ILP32 model, in which integer, long, and pointer (the ILP) were all 32 bits, to the P64 model where pointers are 64 bits and integers and longs remain at 32 bits. This perforce means that changes will occur in the Windows API. For example, the function GetClassLong() returned a 32-bit quantity that could be either an integer or a pointer. Under the Win64 API, this has been changed to GetClassLongPtr(), which is properly behaved. UINT64 and INT64 represent the Microsoft names for the new integral types.

Information on porting to Win64 is available in many places on Microsoft's Web site. A quick search will lead to material that covers many different aspects of migrating to 64 bits. A fine treatment of the topic appears in an article by Jim Howard titled "Code Clean Enables Software in both IA-32 and IA-64 Worlds".

Linux* – 64-bit Linux uses the LP64 model, where longs and pointers are 64 bits wide and integers remain fixed at 32 bits. This will involve changes similar to those described in the previous section.

The resources for 64-bit Linux are unfortunately rather scattered. Originally, the Trillian project was in charge of the Itanium architecture port. This became the IA-64 Linux Project with its home at www.linuxia64.org*. Many links on the site are out-of-date, as are the links to almost all vendors contributing to the project. Despite this, there are useful resources available for developers.

Developers who want the source code for the 64-bit Linux port can download it from www.kernel.org*.

HP-UX* – Hewlett-Packard is the co-creator of the Itanium architecture and its implementation, and its main site on the subject, www.hp.com* is packed with useful information. For porting information, an examination of this site will reveal how much direct compatibility with PA-RISC* processor applications has been built into the Itanium® Processor Family. Most of the information there that is specific to the Itanium Processor Family is relevant to Intel EM64T as well.


Porting Device Drivers

Device drivers are a unique class of software and far more sensitive to the internal changes between 64-bit and 32-bit operating systems. The specific nature of the changes range from those already discussed, including especially changes to the OS APIs, to changes in data structures for internal systems tables and data blocks. Further information is available from the major vendors. For example, this Microsoft site* contains a wealth of information about the Device Driver Kit (DDK) from Microsoft.


Binary Portability

Existing binaries will generally run unmodified on 64-bit operating systems. Intel x86 binaries are translated by the Itanium Processor Family and Intel EM64T and executed natively with all necessary register mappings performed correctly, such that you can take 32-bits Windows binaries and run them on 64-bit Windows without recompilation.

Interestingly, binaries for Hewlett-Packard's PA-RISC architecture can also be run without modification. To run these binaries, sites must use Aries* software that HP will bundle with all its systems. Aries performs two primary functions: it performs dynamic translation of PA-RISC binaries into native 64-bit processor instructions for immediate execution, and it performs interpretation of other, lesser-used PA-RISC commands


Conclusion

It appears that most vendors, as well as the Linux community, are dedicated to making it easy to port application code to the Itanium Processor Family and Intel EM64T. Watch out for the effects of larger pointers and the differences between the 32-bit and 64-bit envi ronments with regard to the widths of ints and longs in C, and you will have covered most of the difficulties. Fortunately, the more recondite problems are documented well by the respective vendors.


Additional Resources

  • Intel® Migration Center provides resources to guide you in deciding what resources to migrate, as well as crafting an intelligent, structured migration methodology.
  • Porting on Intel® Extended Memory 64 Technology Platforms provides a high-level examination of porting applications to Intel EM64T, including capabilities of the technology, as well as related caveats and limitations.
  • Data Alignment when Migrating to 64-Bit Intel® Architecture - Proper data alignment is important on both the Itanium® Processor Family and on processors that support Intel Extended Memory 64 Technology. Learn to avoid exceptions and costly performance deficits associated with incorrect data alignment.
  • Take Advantage of the Memory Features of 64-Bit Computing - Correct memory management is vital to the design and execution of applications on any platform. Gain sound practices to help manage the greater memory resources gained when porting applications to the Itanium® Processor Family or Intel® Extended Memory 64 Technology.
  • 64-Bit Solutions On Intel® Architecture - 64-bit capability is likely to become a baseline expectation for the enterprise. Get the information you need to make the most of this important new technology.

 


About the Author

Andrew Binstock is the principal analyst at Pacific Data Works LLC. He was previously a senior technology analyst at PricewaterhouseCoopers, and earlier editor in chief of UNIX Review and C Gazette. He is the lead author of "Practical Algorithms for Programmers," from Addison-Wesley Longman, which is currently in its 12th printing and in use at more than 30 computer-science departments in the United States.

Catégories:
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.