dolfinx
dolfinx copied to clipboard
Reduce dynamic memory allocation inside tight loops in PlazaRefinementND
The PlazaRefinementND has considerable dynamic memory allocation inside loops over all cells. This should be eliminated for performance.
A data structure that may help is an Eigen::Matrix
with an upper limit on the size (https://eigen.tuxfamily.org/dox/group__TutorialMatrixClass.html), e.g.
Eigen::Matrix<int, 1, Dynamic, 0, 1, 16> a;
for a row vector whose size will not exceed 16.
The problem with the Eigen::
structure is that it is not that easy to dynamically add data. cf:
Eigen::Matrix<int, Dynamic, 4, RowMajor, 8, 4> a;
...
a.conservativeResize(a.rows() + 1, NoChange);
a.bottomRows<1>() << i, j, k, l;
versus a.insert(a.end(), {i, j, k, l});
Can always index into it. I don't much like the Eigen <<
syntax.
Hi, I wanted to ask if the issue is still current and open?
It's not high priority. Obviously, we are not using Eigen any more. I've made a branch which reduces the dynamic allocation, but I couldn't see any difference in the run time when refining a large mesh. https://github.com/FEniCS/dolfinx/tree/chris/refinement-alloc