添加2个循环以阻止内存带宽改进?

时间:2017-11-11 21:10:06

标签: optimization memory-management cpu-architecture

给定的代码有一个阻塞循环

代码是

for (body1 = 0; body1 < NBODIES; body1 ++) {
   for (body2=0; body2 < NBODIES; body2++) {
     OUT[body1] += compute(body1, body2);
   }
}

一个循环阻止

for (body2 = 0; body2 < NBODIES; body2 += BLOCK) {
   for (body1=0; body1 < NBODIES; body1 ++) {
      for (body22=0; body22 < BLOCK; body22 ++) {
         OUT[body1] += compute(body1, body2 + body22);
      }
   }
}

处理计算的两个外环 阻塞会是什么?

0 个答案:

没有答案