Software Archive
Read-only legacy content
17061 Discussions

Problem with CPU?

alex_borsen
Beginner
358 Views
This simple program below runs 10 times slower when I change PAR form 8 to 128:

main ()
{
#define PAR 128
#define s 1024*1024*8 // array size
char *n=new char;int i,j,m=0;
for(i=0;i=(char)(i&0xFF);
// main loop
for(j=0;j<1000;j++)
for(i=0;i<10000000;i++)
m+= // + prevents compiler from optimization, it has no influence on test time
n[((i+j)*PAR+i)&(s-1)]; // there are only shifts and &s after compilation, no multiplications!
}
My real problem is even more complicated because I can't predict index change. Help please!
I tried C-compilers under Windows and Linux and any optimizaton posible.
So it seems to be a problem with INTEL CPU.
0 Kudos
2 Replies
TimP
Honored Contributor III
358 Views
With your larger stride, you are using only 1 byte from each cache line, so the performance necessarily is degraded. In fact, with Alternate Sector Prefetch in force, you are fetching 2 cache lines for each byte used, so you may recover some performance by shutting off ASP.
0 Kudos
alex_borsen
Beginner
358 Views
Thank you for you quick reply. Could you advice me how can I shut off ASP?
Alex
0 Kudos
Reply