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 can 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® 64, and IA-64 architectures:

IA-32 and Intel® 64 architectures:

IA-64 architecture:

In general, keeping data in cache has a better performance impact than keeping the data aligned. Try to use techniques that conform to the rules listed above.

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 systems based on IA-64 architecture to terminate prematurely by default. You can get around this limitation by calling WINAPI function seterrormode. The condition is not fatal, only less efficient.

For the compiler for IA-64 architectures, packed structures are smaller in size but much slower. You will get software exceptions almost every time you access unaligned data.