Original Post
hi, I want to traverse a linked list to set some bit flags. To speed up the traversal I'd like to use the _mm_prefetch intrinsic function so I always have the next node in the cache. Howerver, if I prefetch the next node into L1 and L2 cache the traversal gets even slower. The code looks like this: the linked list node structure is 40 bytes on my amd64 cpu in 32bit mode. How would I use the prefetch command most efficiently in such a list traversal loop ? And why does it get slower if I use it like above ? I am not sure how many bytes are prefetched, maybe flags doesn't get prefetches at all as it is the last 4 bytes of the node struct. thanks for your opinions, quak
while( node )
{
_mm_prefetch( node->next, 2 );
node->flags |= bits;
//more operations
node = node->next;
}