Registered Member
|
Hi you all, I would like to try OpenMP sum reduction on a Eigen Vector3d.
The code is the following:
A parallel OpenMP implementation should be
but I get the following g++ error (g++-4.5)
This seems logic to me, but I want to ask you if a OpenMP reduction can in someway be applied to Eigen types and if it makes sense both in terms of speed and code readability. |
Moderator
|
Indeed, openmp supports only native types. You could emulate this by using a Matrix<double,3,Dynamic> vals(nb_threads), each thread accumulate into vals.col(threadid), and then you do val = vals.rowsize().sum().
It might be worth it only if you have to accumulate a large number of Vector3d. As an alternative, you might simply fill a big Matrix<double,3,Dynamic, RowMajor>, and let Eigen does the reduction for you. |
Registered users: Baidu [Spider], Bing [Bot], Google [Bot], rblackwell