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

[ Thread Index | Date Index | More Archives ]

On 5 July 2018 at 14:37, Lorenzo Botti <bottilorenzo@xxxxxxxxx> wrote:

However, there is no synchronization happening. If you insert from 
multiple threads, you need to lock the access to the matrix, which most 
certainly is less efficient than inserting from a single thread.
You have the same problem when inserting values into a std::vector from 
multiple threads.

The point here is that I know that the code is thread safe, that is no more than one thread will try write in position row i col j.
Accondingly performing the assembly in parallel should not required to lock the insertion operation, am I wrong?

Yes, unfortunately: if I understand correctly how it works, a sparse matrix does not preallocate all its elements; they are allocated as the matrix is filled, and this part that is not safe for concurrent operations.


Mail converted by MHonArc 2.6.19+