Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Floating-Point Guide: HP 9000 Computers > Chapter 7 Performance Tuning

Data Alignment

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

The term alignment refers to the type of address that a data object has in memory. Data objects can have 1-byte, 2-byte, 4-byte, or 8-byte alignment, meaning that the object is stored at an address evenly divisible by 1, 2, 4, or 8. In general, the best performance is obtained by natural alignment, which is the alignment that corresponds to the length of the object. For example, the natural alignment of an HP C int is 4-byte alignment.

For simple static variables, the compilers always naturally align data. The alignment problem occurs in C structures, Pascal records, and Fortran common blocks. By default, HP-UX compilers align this data naturally. However, you can specify directives in your program or on the command line that align data in a way that is compatible with data alignment on other HP systems. It is also possible to use Fortran EQUIVALENCE statements or other programming methods to obtain nondefault data alignment. Specifying nondefault data alignment causes the compiler to generate extra instructions, which both substantially increase code size and substantially degrade performance. Moreover, aligning data on a boundary less than its natural alignment boundary (for example, aligning a double on a 2-byte boundary) may result in a bus error or some other kind of run-time error.

In some situations, you can improve performance by aligning data on greater than natural addresses. This improvement is due to two factors, both of which concern the vector routines enabled by the +Ovectorize option:

  • A single-precision array of numbers will sometimes allow better performance if it is 8-byte aligned, because the vector routines can use double-precision load and store operations to move two operands at a time.

  • A double-precision array of numbers will sometimes allow better performance if it is 32-byte, or cache-line, aligned. This is because of the way the vector routines interact with the data caches on HP 9000 systems.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1997 Hewlett-Packard Development Company, L.P.