I am wondering if someone can help me following loop tiling optimization to minimize cache misses. I am working on four 4000x4000 float matrix multiplication.
The machine has three level caches with values: L1 128kb, L2 1Mb, and L3 8Mb
There are four nested loops and is not perfectly nested.
for(int i=0; i<NN; i++) {
for (int j=0; j<NN; j++) {
if (i != j){
thirdlayer = 0;
for (int k=0; k<NN; k++) {
fourthlayer = 0;
for (int l=0; l<NN; l++) {
fourthlayer = fourthlayer + V[j*NN+l]*V[NN+l]*J[k*NN+l];
}
thirdlayer = thirdlayer + V[k]*V[i*NN+k]*fourthlayer;
}
if(pi_cod[j] != 0)
Transitions[i*NN +j] = sqrt(pi_cod[i]*pi_cod[1]/(pi_cod[0]*pi_cod[j]))*Q[i*NN +j]*thirdlayer/Padt;
}
}
}