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Ū 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 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 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.

For the Itanium compiler packed structures are smaller in size but much slower. You will get software exceptions almost every time you access unaligned data.