The cache characteristics of a processor can have a dramatic impact on the performance of memory-intensive algorithms. It's often helpful to align key data structures on cache line boundaries. However, cache characteristics vary from processor to processor, and it would be nice to be able to select behavior at run time based on the characteristics of the current processor. Since 2008, IBM processors have included the "EXTRACT CPU ATTRIBUTE (ECAG)" non-privileged instruction (originally called "EXTRACT CACHE... [More]
First, the authors describe basic usage syntax for inline
assembly (inline asm) embedded within C and C++ programs. Then they
explain intermediate concepts, such as addressing modes, the
clobbers list, and branching stanzas, as well as more advanced
topics, such as memory clobbers, the volatile attribute, and locks
are discussed for those who want to use inline asm in multithreaded
applications. See the article here.