|[eigen] assembling a sparse matrix from multiple threads|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: [eigen] assembling a sparse matrix from multiple threads
- From: Lorenzo Botti <bottilorenzo@xxxxxxxxx>
- Date: Thu, 5 Jul 2018 10:12:10 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=CLossEdqs36mZgIeKizyr+lp8ZUb2YdoB1b5OIHLfW4=; b=UruP9WBFWY2u8EBMobHOstP/xlk6+YSfsA4vzqG0RJr7DwVVYeZp84MRT+4RDEPSVI OnKJaqX+1IqFGlY8qVIEvro2Wcd3ClAzfalT7oGaf2Yjy6fJxoNWIeLNR68vAWygISSt +baa5GOyYtpUeto1B1ynw94ir0DZqEMzMsnx2HNwG30bLuCqIjfu0RF3c88xAdvweSRR LzajGCYXQtZuGXjuI39/yUiG94FxtjW5ky08gOiKzoGykdtEsfRZslUiVB25VzxpGUe3 w0mBIw0z12HREevavhudiRJr7kGmYsQhQ1B8HGaMJ+bYg/fXpjLJ8nygJQOMAiM6ftK8 gGLA==
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