How to come up with a high cache miss rate example?
问题 I'm trying to come up with an example program which would have a high cache-miss rate. I thought I could try accessing a matrix column by column like so: #include <stdlib.h> int main(void) { int i, j, k; int w = 1000; int h = 1000; int **block = malloc(w * sizeof(int*)); for (i = 0; i < w; i++) { block[i] = malloc(h * sizeof(int)); } for (k = 0; k < 10; k++) { for (i = 0; i < w; i++) { for (j = 0; j < h; j++) { block[j][i] = 0; } } } return 0; } when I compile this with -O0 flag and run using