Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conceal use of Eigen #1975

Open
fsimonis opened this issue Mar 4, 2024 · 0 comments
Open

Conceal use of Eigen #1975

fsimonis opened this issue Mar 4, 2024 · 0 comments
Milestone

Comments

@fsimonis
Copy link
Member

fsimonis commented Mar 4, 2024

Please describe the problem you are trying to solve.

At the time of writing, Eigen is responsible for around 40% of our overall compile time of preCICE.
Primary offender are the uses of Eigen::VectorXd all around the code-base. It is not possible to use anything related to meshes, vertices or data, without (transitively) including Eigen/Core.

A common recommendation to solve this problem is to use Eigen only inside compute-heavy compilation units and use something else for storing data. In practise, this means that data storage is handled by std::vector and then interfaced with using Eigen::Map.

Describe the solution you propose.

Remove the use of Eigen from all central headers of preCICE (related to mesh and data):

  • Use span<const double> where ranges of doubles need to be accepted or exposed.
  • Use std::vector<double> to store data-values and gradients.

Move Eigen accessor functions to separate headers that can be included if necessary:

  • Instead of Eigen::VectorXd mesh::Vertex::getCoords(), implement Eigen::Vector toCoords(const mesh::Vertex&); and Eigen::Map<const Eigen::VectorXd> asCoords(const meah::Vertex&) in a separate header.
  • Move utility functions such as Eigen::VectorXd getCenter(const Edge&) to a utility header.

Replace unnecessary use of Eigen in Tests:

  • Use mesh.createVertex({1, 2, 3}) instead of mesh.createVertex(Eigen::Vertex3d{1, 2, 3})
  • Use std::vector<double> expectedValues{1,2,3,4} instead of Eigen::VectorXd expected(4); expected << 1, 2, 3, 4;
  • If necessary, write custom comparators which internally use Eigen.

Describe alternatives you've considered

Precompiled headers could help with this, but this needs some serious testing.

Additional context

#1973

@fsimonis fsimonis added this to the Version 3.x.x milestone Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant