Boost logo

Ublas :

From: Peter Schmitteckert (peter_at_[hidden])
Date: 2007-09-25 02:54:15


Salut,

Tan, Sarah (FID) wrote:
> Hi
>
> I am wondering whether anyone has experience with the stability issue
> when compiling ublas with Intel C++ Compiler for Windows (ICC 9.1).

I'm neither using Windows and OpenMP, however I'm using ublas in a
Posix threads environment, and it works well.

>
> std::vector< ublas::matrix<double> > outputVec;
>
> for (unsigned i = 0; i < 4; ++i)

As a remark, if you plan to use larger dimensions, and/or
dynamic insertion to std::vector I wouldn't store the matrices
in the container. If STL reorders/resizes it will copy the matrices
(at least the descriptive data). I always store pointers to dynamically
created matrices.

> #pragma omp barrier
>
> for (unsigned i = 0; i < 4; ++i)
>
> output += outputVec[i];

It is not clear for me, whether this part is in parallel mode.
If this loop gets parallelized it can't work ( or it works only accidently),
as two OpenMP thread my increment a matrix element at the same time, so some
additions can get lost.

I'm not using OpenMP, but I assume that parallelization won't stop at the
barrier, it's just a synchronisation point. Please post a working
example as suggested by Gunter (including closing brackets)

You may try to check something like

  for (unsigned i = 0; i < 4; ++i)
  {
#pragma omp barrier
        output += outputVec[i];
        }

or whatever seriell pragma is available in OpenMP ( I don't know the syntax).

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