By: Brendan (btrotter.delete@this.gmail.com), April 13, 2013 10:18 am
Room: Moderated Discussions
Hi,
Eric Bron (eric.bron.delete@this.zvisuel.privatefortest.com) on April 13, 2013 2:32 am wrote:
> > Why use NULL? Use the address of something that's likely to be
> > in cache anyway (e.g. the address of the current structure).
>
> good point, it will indeed work if the only purpose of the extra pointer is prefetching
If you're only prefetching the next node (and have no need for an extra pointer), then:
if(start_of_list != NULL) {
entry = start_of_list;
while(entry->next != NULL) {
prefetch(entry->next);
do_stuff(entry);
entry = entry->next;
}
do_stuff(entry);
}
- Brendan
Eric Bron (eric.bron.delete@this.zvisuel.privatefortest.com) on April 13, 2013 2:32 am wrote:
> > Why use NULL? Use the address of something that's likely to be
> > in cache anyway (e.g. the address of the current structure).
>
> good point, it will indeed work if the only purpose of the extra pointer is prefetching
If you're only prefetching the next node (and have no need for an extra pointer), then:
if(start_of_list != NULL) {
entry = start_of_list;
while(entry->next != NULL) {
prefetch(entry->next);
do_stuff(entry);
entry = entry->next;
}
do_stuff(entry);
}
- Brendan