Understanding Data Alignment

Aligning data on boundaries can help performance. The IntelŪ compiler attempts to align data on boundaries for you. However, as in all areas of optimization coding practices either help or hinder the compiler and can lead to performance problems. Always attempt to optimize using compiler options first. See Optimization Options Summary for more information.

To avoid performance problems you should keep the following guidelines in mind, which are separated by architecture:

IA-32, IntelŪ EM64T, IntelŪ ItaniumŪ architectures:

IA-32 and IntelŪ EM64T architectures:

ItaniumŪ architecture:

In general, keeping data in cache has a better performance impact than keeping the data aligned. Try to use techniques that align the data without greatly expanding data size.

Pack

When structures are packed with the pack pragma, pointers to interior members of the structure can cause unaligned access. Unaligned access will cause an application on ItaniumŪ-based systems to terminate prematurely by default. You can get around this limitation by calling WINAPI function seterrormode. The condition is not fatal, only less efficient. The following considerations apply: