Subject: [ublas] thread safety of matrix multiplication
From: James C. Sutherland (James.Sutherland_at_[hidden])
Date: 2009-11-25 10:07:12
If I have a ublas matrix object, is it thread safe w.r.t. matvec operations? In other words:
typedef boost::numeric::ublas::compressed_matrix< double, boost::numeric::ublas::row_major > MatType;
MatType mat; // both threads use the same matrix object.
VecType a1, b1, a2, b2;
// ... assemble matrix and vectors ...
// thread 1 code:
axpy_prod( mat, a1, b1, true );
// thread2 code:
axpy_prod( mat, a2, b2, true );
Should this be thread safe? My observation is that it is NOT. I am getting memory corruption somewhere. Interestingly, this same approach works fine with a different linear algebra package that I have used. So I suspect that ublas is keeping some internal data in the matrix object that is being altered by application of axpy_prod?
Also, it seems that axpy_prod is no longer included in the boost documentation (html) - is that function being deprecated in favor of the prod(...) functions?