| October 5, 2009 9:00 PM PDT | |
A move to developing for Itanium®-based systems and Intel® Extended Memory 64 Technology (Intel® EM64T) can liberate a programmer. 64-bit computing is a great technical fix for many of the design challenges that face typical applications, particularly those having to do with memory limits. As an added benefit, most software that is code-clean for the Intel® Itanium® Processor Family also runs smoothly on systems that support Intel EM64T with just a recompile.
There's a cost to those benefits, of course. At the very least, you need to have a clear understanding of the "memory model" implicit in application development, and the consequences of the move from 32 to 64 bits. To take proper advantage of them, you'll run into the same old "housekeeping" issues that have been around for years. Building 64-bit software so it is as zippy as it should be is like any other coding project: you still need to manage memory carefully.
It may come as a surprise to many developers that sensitivity to low-level memory housekeeping remains crucial for effective programming in the 64-bit environment, but it is nevertheless true.
Access to 64 bits of addressing space opens a vastly greater range of in-memory implementations. Programs have a far greater opportunity to manage large datasets as in-memory logical objects, rather than on-disk images which must be swapped in and out. This capability improves both performance and availability.
32-bit computing constrains file sizes to no more than two gigabytes. That limits many applications in active use today, especially those in the areas of database management, video processing, application service and a range of enterprise software. 64-bit operating systems, however, manage file systems with files larger than most other hardware can yet support.
64-bit platforms are ready to overcome those limitations, today. When programmers move to 64-bit computing, they leave behind whole categories of memory-related problems. That liberation, however, does not eliminate the need for developers to attend to memory issues. There are two reasons developers still must think carefully about memory. The first has to do with the basics of programming memory models.
Consider first how a language like C embodies these abstract rules in concrete coding patterns. C defines named variables, and also allows direct access to memory. The main difficulty with C's named variables with regard to memory access has to do with array types; programmers frequently make such mistakes as the following:
C's ability to access memory directly permits such mistakes as the following:
There are complementary restrictions and violations for memory retrieval in C. For instance, the following code is a mistake.
These basics aren't specific to 64-bit computing. Doesn't 64-bit computing mean it's time to move on to more important concepts?
Organizations use 64-bit systems to perform important calculations: miss ion-critical database transactions, demanding graphics computations, and so on. These investments are substantial, and it is worth a bit of engineering time and a few infrastructure tools to assure that the results of those calculations are accurate.
Security implications only reinforce all these conclusions. Memory-coding errors have been known for at least twenty years to lead directly to security vulnerabilities. Despite this fact, and despite the apparent conceptual simplicity of memory management, memory-access miscodings appear to be responsible for the majority of breaches that viruses and related security attacks exploit. The security status of software as a whole is disastrous. Moreover, for better or worse, deep security analysis is only possible once basic memory access is sanitized. Any memory-access violations can reduce the effectiveness of other security measures all the way to zero.
As a profession, we still have too many of these uncorrected memory mistakes in our applications. The good news is that it's possible to get memory access right. It's not easy, or we would have done it already. With discipline, though, it is manageable.
Java* is a safer language than C, in particular in terms of memory management. Java has more restricted semantics than C; it's more difficult to 'shoot yourself in the foot' with Java, because it simply doesn't express such mistakes as the uninitialized memory pointer above. At the same time, it is important to understand that these distinctions are relative. Many C-coded programs "leak memory" because of code fragments such as this:
Many organizations that put a premium on performance wrongly assume they should use low-level languages for 64-bit applications. As previous articles in this series have emphasized, it's far more rewarding to use high-level languages, achieve correct and reliable results quicker, and invest in hardware and algorithm development. Reliance on low-level languages for large-scale development with diffuse performance goals simply does not give the application-scale speed that is widely believed to be typical for "fast" languages.
On the other hand, problems with memory access, and especially memory security, are quite typical of code built with low-level languages. Use high-level languages. Use domain-specific languages. If your applications fail to meet performance requirements, address that as a specific, local challenge, with the help of experts who specialize in performance achievements. (Membership in the Intel Software Partner Program provides information and assistance optimizing and porting applications for Intel's latest processors.)
If you are using a language such as C or C++, you can prevent many common memory problems by substitution of higher-level libraries for more primitive memory approaches. 'Garbage-collected C' eliminates one entire sector of memory errors. Use of the Standard Template Library (STL) or other powerful C++ class libraries minimizes source code line count and therefore reduces opportunities for mistakes.
Perhaps the single most effective way to improve the cleanliness of memory coding is inspection. I use the word here in a broad sense, including everything from careful bench testing during early design stages, through the introspective collaboration Extreme Programming counsels for coding, to source-code engineering review. It's not just that academic research has demonstrated that inspection is less labor-intensive than discovery of problems in late-stage quality assurance or customer response. Inspection simultaneously has the potential to give programmers practical experience in improved techniques. It's an important investment in an employer's intellectual capital.
Meaty published literature on software inspections is available through Brad Appleton's 'jump page'*. If you must restrict yourself to one item, let it be the book titled Software Inspection*.
Why list tools last, then, after language choice and inspection? Because the selection of memory testing tools for 64-bit platforms is still relatively limited. This is not particularly surprising. While there don't appear to be any dramatic technical obstacles to porting these memory-testing products to 64-bit platforms, release of these tools may have to wait until the market for them is larger.
Developers working on 64-bit systems need the help of specific memory-testing tools. Memory tests are different from val idation of other technical requirements. Even workers with extensive general testing experience need to study the specifics of memory-management work before they can be productive in this specialized area.
Even with the limited number of memory tools for 64-bit computing available, the developer has two alternatives. The first is to perform memory tests on a supported architecture, such as Windows NT or Unix. The other is to use open-source memory-testing tools on 64-bit systems.
There are several valuable open-source testing tools, generally available through Ben Zorn's* page on 'Debugging Tools for Dynamic Storage Allocation and Memory Management'. While this page is rarely updated, it's adequate as an introduction to the available products. Several open-source products, including mpatrol* and Electric Fence*, install relatively easily and are effective at tracking down such problems in a C-coded context as the following:
Several other languages also support memory extensions or commands that help track down the memory faults characteristic of those languages. Tcl, for example, has a [memory] command to help debug memory allocation problems. Keep in mind that memory management isn't a 'sexy' topic in most programming circles. To learn more about the memory capabilities of these products, it's generally necessary to consult with specialists in the languages that interest you. Few 'advocacy' or 'language profile' pages provide specific technical details on memory hygiene.
The security (or insecurity) of computer systems has recently become important enough to be a featured topic in the popular press. In many, perhaps most, cases of security faults known to the public, the specific technical fault turns out to be a form of memory mismanagement. Programmers have had a rather sorry record in the past of delivering applications that leak and overwrite memory, often with grave security consequences. You can do better. We might soon enter an era where we're required to do better, at least with regard to well-known memory issues.
A ttention to memory issues arises in a second way in the 64-bit world. A naive port to a 64-bit platform simply carries source code over, re-compiles and re-links it as necessary, and uses the executables that are verbatim translations of their 32-bit counterparts. This should, in general, give correct functionality. It fails to take full advantage of the target architecture, however, and in some cases such a port performs more slowly than its 32-bit relative.
What should you do when porting work to 64-bit systems? Start with the resources in the Intel Software Network guide to "Porting to the Itanium Processor Family". Several of these documents deserve your attention; first among these is likely to be "IA-64 Porting Methodology". You can anticipate much of the advice there: use correct source, keep your code base clean, be precise in data declaration and Application Programming Interface (API) invocation, and use a hardware system that's been properly built. Analyze your requirements carefully; there's little advantage to tuning memory lay-out if your application is I/O-bound.
Programs that work properly on 32-bit machines might fail entirely when ported naively to Itanium processors or Intel EM64T. This often perplexes programmers whose experience is limited to a single architecture. Improper source code might yield acceptable results "by accident" on one processor, but go dramatically wrong when the memory model changes even slightly. Don't treat this as a mystery. It's best to rewrite source code to use proper idioms. Clean up your source before you start any hunt for incompatibilities between platforms. Problems are far likelier to result from deprecated coding constructs than true incompatibilities.
In C terms, keeping your source code clean starts with disciplined use of lint and related tools for static analysis. Be sure you're consistent with the semantics of your variables – casts between pointer and numeric types are usually a warning sign of confusion and even error.
Even when your code is correct, a move to an Itanium-based system or Intel EM64T can 'de-tune' it. Data and code segments expand; they're based on 64 rather than 32 bits. If you've carefully optimized your memory lay-out, you might find that your segments no longer fit.
Compilers and other language processors generally attract top talent, so, by writing in a high-level language, you're leveraging their intelligence. A great deal of direct and indirect effort has already gone into making such languag es as Java and Perl* efficient with the new processor. When you code in Java or Perl, you know that your end-users will run applications already optimized for Itanium processors at one implementation level. The Intel® Software Network Performance Optimization Center for the Itanium Processor Family presents the main issues involved in programming new projects for Itanium processors.
Whatever your programming responsibilities, keep the basics in mind: be clear about your requirements, keep designs and implementation clean, put a specific plan in place to ensure correct memory use, take advantage of programming tools that understand 64-bit computing, and keep reading the Intel Software Network for tips on expert development.
*The information, opinions and recommendations in this column are provided by the Author, Cameron Laird. Intel and its subsidiaries do not necessarily endorse or represent the accuracy of the Author's information opinions or recommendations and any reliance upon the Author's statements is solely at your own risk. |
For more complete information about compiler optimizations, see our Optimization Notice.
Comments (4) 
| March 27, 2009 2:15 AM PDT
muhammad Usman Khan |
I need to know whether Intel DP35 DPM is a 64 bit machine or not? please get back to me as quickly as possible because i need to work on a it. Thanks and Regards Usman |
| October 5, 2009 8:46 PM PDT
Diplan | OMG I'm surprise hoe big company forums take so long to answer a questions in time different from free sites/blogs on internet that will give you a fast/accurate answer for free, and they are not even on the Intel Payroll. Well Jon to ANswer your question yes you need a Windows 64 bit to for the computer to recognize all 8 GB memory, 32 bit OS only recognize 4GB. |
| October 6, 2009 7:31 AM PDT
Intel Software Network Support
| All - please note that technical support is not available via the article comments. Please post technical questions to our forums at http://software.intel.com/en-us/forums, where Intel engineers and other members of the software development community will more readily see the questions and be able to respond. |
Trackbacks (1)
- IRI Technology News » Blog Archive » Early Access to the Intel® Itanium® Processor Keeps CoSort® On the Cutting Edge
February 5, 2010 10:32 AM PST



Jon Camangeg