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

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


Ok, got it. 
Thank you very much for pointing this out. 

Bests
Lorenzo

Il giorno gio 5 lug 2018 alle ore 16:50 Christoph Hertzberg <chtz@xxxxxxxxxxxxxxxxxxxxxxxx> ha scritto:
On 2018-07-05 14:47, Andrea Bocci wrote:
> 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.

You can actually pre-allocate a sparse matrix (using
SparseMatrix::reserve():
http://eigen.tuxfamily.org/dox/classEigen_1_1SparseMatrix.html#ac2b219eb36fbab0bfae535cfbfc74a76

Even then (i.e., if you can guarantee that sufficiently many elements
are reserved per inner vector), insertion is still not completely
thread-safe, because elements can get moved, and the `m_data.m_size`
member variable will be modified by different threads -- you may get
lucky here, but you should really not rely on that.

Christoph





--
  Dr.-Ing. Christoph Hertzberg

  Besuchsadresse der Nebengeschäftsstelle:
  DFKI GmbH
  Robotics Innovation Center
  Robert-Hooke-Straße 5
  28359 Bremen, Germany

  Postadresse der Hauptgeschäftsstelle Standort Bremen:
  DFKI GmbH
  Robotics Innovation Center
  Robert-Hooke-Straße 1
  28359 Bremen, Germany

  Tel.:     +49 421 178 45-4021
  Zentrale: +49 421 178 45-0
  E-Mail:   christoph.hertzberg@xxxxxxx

  Weitere Informationen: http://www.dfki.de/robotik
  -----------------------------------------------------------------------
  Deutsches Forschungszentrum fuer Kuenstliche Intelligenz GmbH
  Firmensitz: Trippstadter Straße 122, D-67663 Kaiserslautern
  Geschaeftsfuehrung: Prof. Dr. Dr. h.c. mult. Wolfgang Wahlster
  (Vorsitzender) Dr. Walter Olthoff
  Vorsitzender des Aufsichtsrats: Prof. Dr. h.c. Hans A. Aukes
  Amtsgericht Kaiserslautern, HRB 2313
  Sitz der Gesellschaft: Kaiserslautern (HRB 2313)
  USt-Id.Nr.:    DE 148646973
  Steuernummer:  19/672/50006
  -----------------------------------------------------------------------




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