From: Benjamin K. <ben...@na...> - 2008-02-09 01:43:10
|
>> Cool, so that should be the last thread-unsafe thing left in >> libmesh, right? ;) > > Heh, funny. As a matter of fact, I'm ashamed to say that if you grep > through our source code for "This should also screw up multithreading > royally" you'll find some of my own programming no-nos. But at least > my problems only affect the Clough-Tocher and Hermite elements; the > PerfLog bug can crash any code with both tbb and perf-log turned on. The how-to-instrument multithreaded code is the main point the petsc folks point to when talking about why they can't easily thread. At least in our case it is as simple as --disable-perflog. I think the immediate fix is to disable performance logging at run-time unless --n_threads=1 is specified. In the long term we could use parallel_reduce in place of parallel_for whenever logged methods will be called. The approach would be to declare a local perf_log inside each object that gets called on a separate thread. The join() method could then combine the results from the distinct perf_logs. The problem is I don't know how much overhead this will incur, and if it is worth it. Thoughts? -Ben |