shogun
shogun copied to clipboard
Fix Eigen::Map to set the correct memory alignment
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
I approve :+1:
https://github.com/shogun-toolbox/shogun/commit/8fb6c23865f7edae90924e8efa6f3fba8add8b3a fixes the mapping definition for alignment
I would like to contribute to shogun. Is this issue still open or is there some work left?
if you had checked the above reference yourself, you would have seen that somebody is actively doing this atm