viennacl / viennacl-dev

Developer repository for ViennaCL. Visit http://viennacl.sourceforge.net/ for the latest releases.
Other
281 stars 89 forks source link

accessing data in Armadillo sparse matrix #260

Closed conradsnicta closed 6 years ago

conradsnicta commented 6 years ago

There is a bug in compressed_matrix.hpp, where data from an Armadillo sparse matrix is accessed: https://github.com/viennacl/viennacl-dev/blob/489c11964a1e7c32faa1c6d26e1ef43fd856e0ca/viennacl/compressed_matrix.hpp#L267

In Armadillo 8.x and onwards, the arma::SpMat<T>::sync() function needs to be called before accessing any of the following arrays: values, row_indices, col_ptrs. This is due to an internal caching mechanism. Without the call to sync(), the arrays may have outdated data and/or wrong size.

I suggest adding code along these lines, at the start of the function:

#if (ARMA_VERSION_MAJOR >= 8)
  arma_matrix.sync();
#endif

(CC: @rcurtin)

karlrupp commented 6 years ago

Thanks for the report, @conradsnicta . I just pushed the suggested fix.