1

Is there any way to improve the performance of Eigen matrix multiplication using OpenMP or any other approach to enable multithreading? Currently, switching on OpenMP gives nothing.

inline void multiply1(
    Eigen::MatrixXd &m,
    std::vector<double> &vector,
    std::vector<double> &result
) 
    {
        int size = (int)vector.size();
        result.resize(size);
        Eigen::Map<Eigen::VectorXd> Evector(vector.data(), size);

        Eigen::VectorXd a;
        a.noalias() = m * Evector;

        Eigen::VectorXd::Map(&result[0], a.size()) = a;
    }

This function is called a great number of times during the runtime, so it has a very critical influence for total computation time.

  • What version of Eigen and Visual Studio are you using? Can you flesh out your method to a full [MCVE] including performance? Can you parallelize the calls to `multiply1`? – Avi Ginsburg Mar 20 '19 at 10:19
  • 2
    At the moment, Matrix-Vector products are not parallelized. You can either try to hand-code that yourself (e.g., split `m` into the number of cores you have) or make a feature-request. Ideally provide some benchmarks which prove that this is worth the overhead. – chtz Mar 20 '19 at 10:26
  • @Avi Ginsburg I use VS community 2017 and Eigen 3.3.7. Unfortunately, I can't parallelize the calls from the outside. – Pavel Kikin Mar 20 '19 at 11:01
  • Then what @chtz said. – Avi Ginsburg Mar 20 '19 at 11:04
  • 1
    Another alternative would be to use an external BLAS library, like MKL. – chtz Mar 20 '19 at 12:30

0 Answers0