Boost logo

Ublas :

From: Peter Schmitteckert (peter_at_[hidden])
Date: 2007-09-25 04:03:17


Dear Georg,

Georg Baum wrote:
> Am Dienstag 25 September 2007 09:00 schrieb Peter Schmitteckert:
>
>> Well, there is no guarantee that a matrix gets initialized to zero.
>
> You are right.
>
>> (Or is a guarantee introduced recently?)
>
> Fortunately not. Unfortunately despite the missing guarantee its is in
> practice quite often zero, so that it is easy to forget a clear() :-(
> In this case I simply confused ublas clear() with std::vector::clear()
> (which resizes to zero).
Well, both set the matrices to zero matrices.

Fortunately it is not guaranteed, even if it is often zero. There is a big difference on NUMA
machines (non-uniform memory architecture) in a parallel environment.
Suppose you want to define some matrices in the main code and you want to fill
them in threads, then you end up with non-thread local memory, if you already
access the memory in the main part. Of course, you could then avoid it by resizing
the matrix, but that is additional programming afford.

Best regards,
Peter

-- 
--------------------------------------------------------------------------------------------
Dr. Peter Schmitteckert                                 Center for Functional Nanostructures
Institut für Theorie der Kondensierten Materie          Karlsruhe Institute of Technology
Universität Karlsruhe
Wolfgang-Gaede Str. 1
D-76128 Karlsruhe