shogun icon indicating copy to clipboard operation
shogun copied to clipboard

Fix Eigen::Map to set the correct memory alignment

Open vigsterkr opened this issue 5 years ago • 4 comments

there are many places where we use Eigen::Map for wrapping SGVector and SGMatrix in the codebase. These Maps are currently not really constructed the best way, as both SGVector and SGMatrix memory chunk is 16 bytes aligned, but this is not specified to Eigen.

for example

Map<MatrixXd> eigen_cov(cov.matrix, cov.num_rows, cov.num_cols);

should be actually:

Map<MatrixXd, Eigen::Aligned16> eigen_cov(cov.matrix, cov.num_rows, cov.num_cols);

or better yet it'd be better to port all those Map definitions to use the

operator EigenMatrixXtMap()

(or vector) as in that case if we change the alignment, then it could be changed in one part of the code instead of keep changing it all over again.

see linalg codebase how one can use the EigenMatrixXtMap/EigenVectorXtMap

vigsterkr avatar Mar 22 '20 11:03 vigsterkr

I approve :+1:

gf712 avatar Mar 22 '20 11:03 gf712

https://github.com/shogun-toolbox/shogun/commit/8fb6c23865f7edae90924e8efa6f3fba8add8b3a fixes the mapping definition for alignment

vigsterkr avatar Mar 22 '20 11:03 vigsterkr

I would like to contribute to shogun. Is this issue still open or is there some work left?

YuriYumeYuu avatar Mar 29 '20 19:03 YuriYumeYuu

if you had checked the above reference yourself, you would have seen that somebody is actively doing this atm

karlnapf avatar Mar 30 '20 13:03 karlnapf