Please answer and explain letter a. 23 [15/201 With software prefetching it is i
ID: 669070 • Letter: P
Question
Please answer and explain letter a.
23 [15/201 With software prefetching it is important to be careful to have the prefetches occur in time for use but also to minimize the number of outstanding prefetches to live within the capabilities of the microarchitecture and minimize cache pollution. This is complicated by the fact that different processors have dif- ferent capabilities and limitations a. [15] Create a blocked version of the matrix transpose with software prefetching b. [20] Estimate and compare the performance of the blocked and unblocked transpose codes both with and without software prefetchingExplanation / Answer
a)
if you want to use software pre-fetching then you should do transpose by below code:
for (int i = 0; i < n; i += blocksize) {
for (int j = 0; j < n; j += blocksize) {
for (int k = i; k < i + blocksize; ++k) {
for (int l = j; l < j + blocksize; ++l) {
dst[k + l*n] = src[l + k*n];
}
}
}
}
Here two loops will be used to iterate over the blocks, and then another two loops will be used to perform the transpose-copy of a single block. With this software pre-fetching will be used in your program.