Skip to content

Instantly share code, notes, and snippets.

@lettergram
Created March 19, 2015 00:55
Show Gist options
  • Save lettergram/03c567591f70ca55ce5a to your computer and use it in GitHub Desktop.
Save lettergram/03c567591f70ca55ce5a to your computer and use it in GitHub Desktop.
double cache_opt(int ** matrix, long int size, int blocksize){
double total_begin = omp_get_wtime();
for(int x = 0; x < size; x += blocksize){
for(int i = x; i < x + blocksize; i++){
for(int y = 0; y < size; y+= blocksize){
__builtin_prefetch(&matrix[i][y + blocksize]);
for(int j = y; j < y + blocksize; j++){
matrix[i][j] = matrix[i][j] * 2;
}
}
}
}
double total_end = omp_get_wtime();
return double(total_end - total_begin);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment