Software prefetching

Hey there,

In order to get a fast piece of code, I'd like to give a try to software prefetching (I don't want to use OpenMP at the moment). I'm running MSVS 2010 C++ compiler. However the code snippet below is slower than its non-prefetched version.

1
2
3
4
5
6
7
8
for (i=0; i<NRA; i++) {
	for(k=0; k<NCA; k++) {
		for (j=0; j<NCB; j++) {
			_mm_prefetch(((char*)(&b[k+1,j])), _MM_HINT_T0);
			c[i][j] += a[i][k] * b[k][j];
		}
	}
}


Is my usage of _nm_prefetch() correct?


Thanks for any comments on that,
-SebGR

There are better forums to address this question. _mm_prefetch() isn't a standard C++ function. It's x86 specific. Intel has forums dedicated to this sort of question.

With that said, there is little guarantee that prefetching will always help. LWN had a great series of articles on optimizing memory access: http://lwn.net/Articles/255364/
PanGalactic - Sorry for being at the wrong place, but thanks a bunch for this very helpful link.

-SebGR
Topic archived. No new replies allowed.