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

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]

*To*: eigen <eigen@xxxxxxxxxxxxxxxxxxx>*Subject*: Re: [eigen] assembling a sparse matrix from multiple threads*From*: Andrea Bocci <andrea.bocci@xxxxxxx>*Date*: Thu, 5 Jul 2018 14:47:57 +0200*Authentication-results*: spf=pass (sender IP is 188.184.36.48) smtp.mailfrom=cern.ch; lists.tuxfamily.org; dkim=none (message not signed) header.d=none;lists.tuxfamily.org; dmarc=bestguesspass action=none header.from=cern.ch;*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cern.onmicrosoft.com; s=selector1-cern-ch; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=J7HuN7GKlt+RHk+ITN0VOb5ZzmjopvLOgGhpgDnlMBE=; b=EiO2FQrx1wCRgdbYhocoA0wpaeULvkpqWwvaE1/0XWw8cNlSBz64/LkgKuQ7G3Ixfy437tvg3absGuwgvIVbEcKWAoghE5BqMfymTH1BRclKJffbdIeIzOfUDrCQOE4239GLKDRCP/bRDCrgdEtCAYq9TwhOkLp1DXptwMeGyEI=*Spamdiagnosticmetadata*: NSPM*Spamdiagnosticoutput*: 1:99

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.

.A

**Follow-Ups**:**Re: [eigen] assembling a sparse matrix from multiple threads***From:*Christoph Hertzberg

**References**:**[eigen] assembling a sparse matrix from multiple threads***From:*Lorenzo Botti

**Re: [eigen] assembling a sparse matrix from multiple threads***From:*Dan Čermák

**Re: [eigen] assembling a sparse matrix from multiple threads***From:*Christoph Hertzberg

**Re: [eigen] assembling a sparse matrix from multiple threads***From:*Lorenzo Botti

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] assembling a sparse matrix from multiple threads** - Next by Date:
**Re: [eigen] assembling a sparse matrix from multiple threads** - Previous by thread:
**Re: [eigen] assembling a sparse matrix from multiple threads** - Next by thread:
**Re: [eigen] assembling a sparse matrix from multiple threads**

Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |