In a C/C++ program, how to close the prefetch of each core in the Windows system?
A:
I have seen this trick mentioned in some code, although I am not 100% sure if this trick is what you're looking for, however, the code was this
Sleep(0);
By using Sleep(0)
, you are clearing the CPU instructions and cause a context switch... Now you did say 'for each core', I do not think you can explicitly select a core to do that as how do you know which core is running the code that is need of a closing the pre-fetching of the cache....
tommieb75
2010-03-08 15:53:22
`Sleep()` does not guarantee a context switch. Also context switch is sort of a brutal way to stop prefetching.
Nikolai N Fetissov
2010-03-08 16:06:51
@Nikolai: Ahhh...k.... no prob so....I wasn't really sure....thanks for your input! :)
tommieb75
2010-03-08 16:27:51
+3
A:
There is a Windows API call FlushInstructionCache()
Perhaps this is what you need? It is typically used by self modifying code to make sure changes to code in the RAM are visible to the processor.
rep_movsd
2010-03-18 05:32:13