From: Nicholas N. <n.n...@gm...> - 2009-05-27 23:45:11
|
On Thu, May 28, 2009 at 9:12 AM, Ivan Novick <nov...@gm...> wrote: > Hi, > I would like to detect cases of false sharing in my program. > By this I mean cases where multiple threads are both trying to write data to > different memory locations but those locations are closest enough in memory > that they are on the on the same cache line. > The result would be delays on threads even though there are enough CPU's to > do the work. > Are there any tools in valgrind to do this? No, but it wouldn't be too hard to write a new one that did this. For each cache-line-sized chunk of memory, you'd record which thread last wrote to it and when, and then if another thread wrote to a chunk sufficiently soon after a previous thread you'd give a warning. You could record thread numbers and addresses and stack traces and the like, there'd be trade-offs in how much overhead you'd have vs. how much info you'd get in each report. Nick |