Intel ARCHITECTURE IA-32 User Manual Page 393

  • Download
  • Add to my manuals
  • Print
  • Page
    / 568
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 392
Multi-Core and Hyper-Threading Technology 7
7-47
However, the buffer space does enable the first-level data cache to be
shared cooperatively when two copies of the same application are
executing on the two logical processors in a physical processor package.
To establish a suitable stack offset for two instances of the same
application running on two logical processors in the same physical
processor package, the stack pointer can be adjusted in the entry
function of the application using the technique shown in Example 7-10.
The size of stack offsets should also be a multiple of a reference offset
that may depend on the characteristics of the application’s data access
pattern. One way to determine the per-instance value of the stack offsets
is to choose a pseudo-random number that is also a multiple of the
reference offset or 128 bytes. Usually, this per-instance pseudo-random
offset can be less than 7 KB. Example 7-10 provides a code fragment
for adjusting the stack pointer in an application entry function.
User/Source Coding Rule 36. (M impact, L generality) Add per-instance
stack offset when two instances of the same application are executing in lock
steps to avoid memory accesses that are offset by multiples of 64 KB or 1 MB,
when targeting IA-32 processors supporting Hyper-Threading Technology.
Example 7-10 Adding a Pseudo-random Offset to the Stack Pointer
in the Entry Function
void main()
{
char * pPrivate = NULL;
long myOffset = GetMod7Krandom128X()
// A pseudo-random number that is a multiple
// of 128 and less than 7K.
// Use runtime library routine to reposition.
_alloca(myOffset); // The stack pointer.
}
// The rest of application code below, stack accesses in descendant
// functions (e.g. do_foo) are less likely to cause data cache
// evictions because of the stack offsets.
do_foo();
}
Page view 392
1 2 ... 388 389 390 391 392 393 394 395 396 397 398 ... 567 568

Comments to this Manuals

No comments