Answer the question
In order to leave comments, you need to log in
Is this method of measuring the length of the hardware cache prefetch correct?
I was given the task to determine the length of the hardware cache prefetch. The prefetch is arranged according to the following method: after 2 consecutive cache misses, it determines the direction of movement and begins to make friends with the data in the cache with lines of unknown length. I need to experimentally determine the length of this string.
In my program, I have one array, which I pass to a function that already does 2 misses and then delays for the prefetch to load the data into the cache, and measures the access time to the 3rd element. Then it prints the result to a file. But unfortunately I don't see any patterns in the output file. There are indeed minor jumps over 30 int elements, but they are not constant. This function takes as input the array itself and an offset, which is set in a loop from 1 to 1024 int , which is equal to the size of the window, more than which, by definition, hardware prefetching cannot work. I have misses on the 0th element, on cache_string_size (64 b) * 2 and the next access I make cache_string_size * 4 + i. 4 because after a miss, 2 lines will probably be loaded into the cache after the second miss.
Misses construction:
if (array[0] == 0){ // first cache miss
if (array[string_size * 2] == 0){ // second cache miss
usleep(100);
asm("rdtsc\n":"=a"(start.t32.th),"=d"(start.t32.tl));
if (array[string_size * 4 + offset] == 0){ // acess to the element
asm("rdtsc\n":"=a"(end.t32.th),"=d"(end.t32.tl));
}
}
}
Answer the question
In order to leave comments, you need to log in
Unfortunately, there are no regularities in the output file
Look at the ATLAS sources , it automatically detects the cache width and optimizes for it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question