Intel PXA270 Optimization Manual page 103

Pxa27x processor family
Table of Contents

Advertisement

Unfortunately, preload loop unrolling does not work on loops with indeterminate iterations.
5.1.1.3.2
Coding Technique: Pointer Preload
Not all looping constructs contain induction variables. However, preloading techniques can still be
applied. Refer to this linked list traversal example:
while(p) {
do_something(p->data);
p = p->next;
}
The pointer variable p becomes a pseudo induction variable and the data pointed to by p->next can
be pre-loaded to reduce data transfer latency for the next iteration of the loop. Linked lists should
be converted to arrays as much as possible.
while(p) {
prefetch(p->next);
do_something(p->data);
p = p->next;
}
Recursive data structure traversal is another construct where preloading can be applied. This is
similar to linked list traversal. Refer to this pre-order traversal of a binary tree:
preorder(treeNode *t) {
if(t) {
process(t->data);
preorder(t->left);
preorder(t->right);
}
}
The pointer variable t becomes the pseudo induction variable in a recursive loop. The data
structures pointed to by the values t->left and t->right can be pre-loaded for the next iteration of
the loop.
preorder(treeNode *t) {
if(t) {
prefetch(t->right);
prefetch(t->left);
process(t->data);
preorder(t->left);
preorder(t->right);
}
}
The variables are pre-loaded in the opposite order that they are used. If there is a cache conflict and
data is evicted from the cache then only the data from the first preload is lost.
Intel® PXA27x Processor Family Optimization Guide
High Level Language Optimization
5-5

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pxa271Pxa272Pxa273

Table of Contents