ginkgo
ginkgo copied to clipboard
Add a uniform coarse generation algorithm
This PR is an updated version of #979 . The idea is to have a very cheap coarse grid generation algorithm that works well for matrices that are uniform, for example, matrices that arise from stencils on structured grids.
For example, for a 7 point stencil on a 3D grid, it is very competitive to PGM (with_deterministic=false
) with much faster generation and faster apply for larger problems (on OMP executor with 8 cores):
Quality Gate passed
The SonarCloud Quality Gate passed, but some issues were introduced.
44 New issues
1 Security Hotspot
66.4% Coverage on New Code
2.0% Duplication on New Code
Codecov Report
Attention: Patch coverage is 97.64310%
with 7 lines
in your changes are missing coverage. Please review.
Project coverage is 89.78%. Comparing base (
fb70ec0
) to head (0537b1e
). Report is 232 commits behind head on develop.
:exclamation: Current head 0537b1e differs from pull request most recent head 915e227. Consider uploading reports for the commit 915e227 to get more accurate results
Files | Patch % | Lines |
---|---|---|
...ence/test/multigrid/uniform_coarsening_kernels.cpp | 96.32% | 5 Missing :warning: |
core/device_hooks/common_kernels.inc.cpp | 0.00% | 2 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## develop #1526 +/- ##
===========================================
- Coverage 91.04% 89.78% -1.27%
===========================================
Files 700 707 +7
Lines 56996 57487 +491
===========================================
- Hits 51894 51612 -282
- Misses 5102 5875 +773
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Especially focusing on distributed, I think if we include this, we should try to support at least 2D and maybe 3D coarsening (i + n * j
and i + n * j + k * n * m
).
Maybe it makes sense to split the UniformCoarsening
class up. The generated object essentially stores an array with coarse row indices, so it seems natural to allow users to pass in these indices. But I don't think we can add a parameter to the existing class, since then there would be two mutually exclusive parameters.
I think Tobias' approach for the direct solvers, i.e. having multiple factories that generate the same class makes sense here.
Quality Gate passed
Issues
44 New issues
0 Accepted issues
Measures
1 Security Hotspot
66.4% Coverage on New Code
2.0% Duplication on New Code
@upsj, After a bit of thought, I think this class should not represent Geometric/Structured coarsening. Uniform coarsening is just a cheap coarsening method that just uniformly discards rows and columns to construct the coarse matrix, and hence is not suitable for Geometric coarsening, which needs to create connections between the coarse nodes.
@MarcelKoch , we already provide the users with a way to specify custom indices for coarsening with the FixedCoarsening
class
@pratikvn If we discard variables for restriction, we still need to interpolate new values for prolongation, so I don't yet see how this makes multi-dimensional coarsening impossible if 1D coarsening is possible?
In a similar fashion to PGM, the prolongation matrix will be a transpose of the restriction matrix. I think maybe I have given a wrong impression that this would be a 1D coarsening. The fine level vectors will not have extrapolated values, but just "mapped" values.
Doesn't PGM do the same thing? And I believe we are mixing two things here - coarsening and interpolation. One is structural, one concerns the actual numerical values.
Just adding more performance results on a 7pt stencil and some chosen matrices from Suitesparse, to show that this type of coarsening can help in certain cases.
Apply speedup for cage15 (v/s PGM) matrix and bcsstm39 matrix (v/s no preconditioning)
speedup_app_ss_bicgstab_cskip.pdf
Apply speedup for 7pt stencil (v/s PGM)
Generate speedup for 7pt stencil (v/s PGM)
I don't think these results matter, since even for simple stencils, the matrix loses all connectivity:
Take the poisson-solver example and plug in the following code:
auto gen = gko::multigrid::UniformCoarsening<ValueType, IndexType>::build().on(app_exec)->generate(matrix->clone());
gko::write(std::cout, matrix);
gko::write(std::cout, gko::as<mtx>(gen->get_composition()->get_operators()[1]));
The fine matrix is tridiagonal, but the coarse matrix is just a diagonal matrix.