General Optimization Guidelines
2
2-39
An example of a loop-carried dependence chain is shown in
Example 2-17.
Data Layout Optimizations
User/Source Coding Rule 2. (H impact, M generality) Pad data structures
defined in the source code so that every data element is aligned to a natural
operand size address boundary.
If the operands are packed in a SIMD instruction, align to the packed
element size (64-bit or 128-bit).
Align data by providing padding inside structures and arrays.
Programmers can reorganize structures and arrays to minimize the
amount of memory wasted by padding. However, compilers might not
have this freedom. The C programming language, for example, specifies
the order in which structure elements are allocated in memory. Section
“Stack and Data Alignment” of Chapter 3, and Appendix D, “Stack
Alignment”, further defines the exact storage layout.
Example 2-18 shows how a data structure could be rearranged to reduce
its size.
Example 2-17 An Example of Loop-carried Dependence Chain
for (i=0; i<MAX; i++) {
a[i] = b[i] * foo;
foo = a[i]/3;
}
// foo is a loop-carried dependence
Example 2-18 Rearranging a Data Structure
struct unpacked { /* fits in 20 bytes due to padding */
int
a;
char
b;
int
c;
char
d;
int
e;
}
struct packed { /* fits in 16 bytes */
Содержание ARCHITECTURE IA-32
Страница 1: ...IA 32 Intel Architecture Optimization Reference Manual Order Number 248966 013US April 2006...
Страница 220: ...IA 32 Intel Architecture Optimization 3 40...
Страница 434: ...IA 32 Intel Architecture Optimization 9 20...
Страница 514: ...IA 32 Intel Architecture Optimization B 60...
Страница 536: ...IA 32 Intel Architecture Optimization C 22...
Страница 560: ...IA 32 Intel Architecture Optimization E 14...