Intel
®
IXP42X Product Line of Network Processors and IXC1100 Control Plane Processor
September 2006 DM
Order Number: 252480-006US 187
Intel XScale
®
Processor—Intel
®
IXP42X product line and IXC1100 control plane processors
In the above code, data is read from both arrays a and b, but a and b are not spatially
close. Array merging can place a and b specially close.
As an example of rearranging often written to sections in a structure, consider the code
sample:
In the data structure shown above, the fields Year2DatePay, Year2DateTax,
Year2Date401KDed, and Year2DateOtherDed are likely to change with each pay check.
The remaining fields however change very rarely. If the fields are laid out as shown
above, assuming that the structure is aligned on a 32-byte boundary, modifications to
the Year2Date fields is likely to use two write buffers when the data is written out to
memory. However, we can restrict the number of write buffers that are commonly used
to 1 by rearranging the fields in the above data structure as shown below:
int a_array[NMAX];
int b_array[NMAX];
int ix;
for (i=0; i<NMAX]; i++)
{
ix = b[i];
if (a[i] != 0)
ix = a[i];
do_other calculations;
}
struct {
int a;
int b;
} c_arrays;
int ix;
for (i=0; i<NMAX]; i++)
{
ix = c[i].b;
if (c[i].a != 0)
ix = c[i].a;
do_other_calculations;
}
struct employee {
struct employee *prev;
struct employee *next;
float Year2DatePay;
float Year2DateTax;
int ssno;
int empid;
float Year2Date401KDed;
float Year2DateOtherDed;
};