1
votes

I just ran gprof to profile some code of mine. Here are the first few lines of the flat profile. More than 75% of the time is being used by the first function. What is that function? What is it telling me about how I'm misusing the Eigen library?

Flat profile:

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls  Ts/call  Ts/call  name    
 75.16    368.61   368.61                             void Eigen::internal::call_assignment_no_alias<Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::internal::assign_op<double> >(Eigen::Matrix<double, -1, 1, 0, -1, 1>&, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, Eigen::internal::assign_op<double> const&)

Here's that function name in a little bit nicer formatting:

void Eigen::internal::call_assignment_no_alias<Eigen::Matrix<double, -1, 1, 0, -1, 1>, 
                                               Eigen::Matrix<double, -1, 1, 0, -1, 1>, 
                                               Eigen::internal::assign_op<double>      >(Eigen::Matrix<double, -1, 1, 0, -1, 1>&, 
                                                                                         Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, 
                                                                                         Eigen::internal::assign_op<double> const&)
1

1 Answers

1
votes

This function assign one MatrixXd to another one:

MatrixXd a, b;
b = a;

Thus means that most of the time is spent copying matrices.

So make sure that you compiled with optimizations ON (-O3), otherwise your profiling results are meaningless. If so, then make sure you pass matrices by reference and not by value, be careful if you use std::vector<MatrixXd>, etc.