title: Troubleshooting parallel code
body: <p>What tools are there for troubleshooting parallel programs?</p>
  
  <p>Say I have a code that performs worse than expected (4 times instead of theoretical 8 times  of serial version executing speed). I suspect the cause is either some locking caused by threads accessing shared variables (say adjacent elements of a shared vector), or locking caused by threads accessing heap (which I suppose is also a shared resource). But I don't know what tools are there available to check what might be the cause of excessive thread sleeps, threads switching, etc. E.g. profiler will tell me what function took how much time, and perhaps that there was a lot of activity related to threads management, but not what the cause and state of threads was (or perhaps I don't know how to use one well).</p>
  
  <p>I'm working in C++ on OS X.</p>