Intel ARCHITECTURE IA-32 User Manual Page 111

  • Download
  • Add to my manuals
  • Print
  • Page
    / 568
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 110
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 */
Page view 110
1 2 ... 106 107 108 109 110 111 112 113 114 115 116 ... 567 568

Comments to this Manuals

No comments