Re: [eigen] assembling a sparse matrix from multiple threads

[ Thread Index | Date Index | More Archives ]

Hi Lorenzo,

I haven't used Eigen in a while, but afaik it uses the compressed column
storage scheme which (at least I imagine it) makes it complicated to
insert new values efficiently in parallel.

Also the documentation of insert states that it is optimized for
sequential insertion
which you probably aren't performing.

I guess you are probably better of assembling the matrix entries in the
vector of triplets and then creating the matrix afterwards. But someone
more familiar with Eigen should probably confirm that.



Lorenzo Botti <bottilorenzo@xxxxxxxxx> writes:

> Dear all,
> I'm having troubles assembling a sparse matrix in parallel, from multiple
> threads.
> In particular if I use matrix.insert(i,j)  to set the nonzero entries in
> several concurrent threads the code fails randomly in optimized mode while,
> in debug mode, an Eigen's error message is triggered saying that one of the
> matrix entries already exists. The code behavior is pretty unpredictable
> when repeatedly assembling a sparse matrix in a loop.
> I'm confident that my code is thread safe and matrix entries are unique as
> confirmed by the following: if I collect matrix entries in vectors of
> triplets (one vector for each thread) and then I assemble the matrix
> serially (using matrix.insert(triplet.row(),triplet.col()) =
> triplet.value()) everything works fine.
> I guess that concurrent insertion is not allowed/supported. Am I right?
> Thanks for help
> Lorenzo

Mail converted by MHonArc 2.6.19+