[Trilinos-Users] Using NOX on a tbb thread

Hoemmen, Mark mhoemme at sandia.gov
Thu Jan 17 12:14:53 MST 2013


On Jan 17, 2013, at 12:00 PM, <trilinos-users-request at software.sandia.gov>
 <trilinos-users-request at software.sandia.gov> wrote:
> I tried simply taking a for loop that creates a NOX solver to a 
> parallel_for loop like so:
> 
> parallel_for (blocked_range<int> (0, rods_.size ()),
>               [&] (const blocked_range<int>& r) {
> 
> int ierr = stepObject (objs[i], h);  // builds and executes a NOX based 
> solver
> }
> 
> But I have what look like memory corruption errors.  The NOX solver is 
> using AztecOO and Epetra.  Is there a way to rebuild my libraries so I 
> can use NOX how I've been using it serially on each tbb thread or do I 
> have to re-write my code to use Tpetra/Belos based stuff.

AztecOO is not reentrant; it cannot safely be called concurrently by multiple threads.  There are no plans to fix this.  

I can't speak for NOX itself, as I am not a NOX developer.

Belos' solvers have fewer issues with this.  It is our goal to support this use case, though it might not work at present.

Right now, if each thread (or each parallel for index i) has its own Belos solver instance and its own LinearProblem to solve, and if you have created the solvers before handing them off to the threads, you should be able to call the different solver instances concurrently without problems.  

Teuchos::RCP itself is not currently thread safe, so if the threads are sharing references to the same data, you may have problems with reference counting.  This would include things like setting parameters with an RCP<ParameterList>; the different solvers shouldn't share those.  We have a plan for making RCP thread safe, but haven't had time to work on this yet.

In short: thread safety is a hard problem :-)  We're working on it, though.  If this is a high priority for you, please contact us and we'll see what we can do.

Best,
mfh





More information about the Trilinos-Users mailing list