slide 19 of 19
Code Optimizations
-
Don't use shared objects when locals will do
-
Minimize use of atomic locks
-
Data layout to avoid "false sharing"
-
Even with shared L2 cache, have separate L1 caches
-
a and b are in the same c-unit cache line
iff
((int) a) & ~(c - 1) == ((int) b) & ~(c - 1)
-
If a and b are >= c units apart,
they must be in different lines
-
Use
volatile
attribute only when reference requires
The next set of slides is available from
http://yara.ecn.purdue.edu/~pplinux/ICPP96/