13.07.2015 Views

Intel® 64 and IA-32 Architectures Optimization Reference Manual

Intel® 64 and IA-32 Architectures Optimization Reference Manual

Intel® 64 and IA-32 Architectures Optimization Reference Manual

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

GENERAL OPTIMIZATION GUIDELINESExample 3-35 shows how a data structure could be rearranged to reduce its size.Example 3-35. Rearranging a Data Structurestruct unpacked { /* Fits in 20 bytes due to padding */int a;char b;int c;char d;int e;};struct packed { /* Fits in 16 bytes */int a;int c;int e;char b;char d;}Cache line size of <strong>64</strong> bytes can impact streaming applications (for example, multimedia).These reference <strong>and</strong> use data only once before discarding it. Data accesseswhich sparsely utilize the data within a cache line can result in less efficient utilizationof system memory b<strong>and</strong>width. For example, arrays of structures can be decomposedinto several arrays to achieve better packing, as shown in Example 3-36.Example 3-36. Decomposing an Arraystruct { /* 1600 bytes */int a, c, e;char b, d;} array_of_struct [100];struct { /* 1400 bytes */int a[100], c[100], e[100];char b[100], d[100];} struct_of_array;struct { /* 1200 bytes */int a, c, e;} hybrid_struct_of_array_ace[100];3-57

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!