---
title: "AMG based on compatible weighted matching for GPUs (2018)"
description: "BootCMatchG uses weighted graph matching to build algebraic multigrid preconditioners for solving large sparse linear systems on GPUs."
canonical: "https://research.elamur.ai/free/en/papers/bernaschi-2018-amg-based-compatible-weighted-matching/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Parse](https://mova.elamur.ai/free/en/parse/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Translate](https://md.translate.elamur.ai/free/en/) · **Research** · [Gali](https://md.gali.elamur.ai/free/en/) · [MCP](https://mcp.elamur.ai/) · [Locations](https://md.locations.elamur.ai/free/en/) · [Weather](https://md.weather.elamur.ai/free/en/) · [Constitution](https://md.constitution.elamur.ai/)

[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/bernaschi-2018-amg-based-compatible-weighted-matching/)

[Elamur Research](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2018](https://md.research.elamur.ai/free/en/papers/2018/) / AMG based on compatible weighted matching for GPUs

# AMG based on compatible weighted matching for GPUs

Paper · 2018 · Massimo Bernaschi, Pasqua D'Ambra and Dario Pasquini

**Authors:** Massimo Bernaschi, Pasqua D'Ambra and Dario Pasquini · **Year:** 2018 · **Venue:** arXiv:1810.04221 · **Licence:** [arXiv — non-exclusive license to distribute](http://arxiv.org/licenses/nonexclusive-distrib/1.0/)

[Cited by **3** papers in our library of more than 163,000 papers whose bibliographies we read](https://md.research.elamur.ai/free/en/papers/bernaschi-2018-amg-based-compatible-weighted-matching/cited-by/) · [licence](http://arxiv.org/licenses/nonexclusive-distrib/1.0/)

- [PDF](https://arxiv.org/pdf/1810.04221)
- [arXiv 1810.04221](https://arxiv.org/abs/1810.04221)

## Summary

An iterative solver for a large sparse system of linear equations can make rapid progress at first and then spend much of its time removing errors that persist across many unknowns. Algebraic multigrid addresses that problem by building smaller versions of the system, on which those errors are easier to correct. The challenge is to choose which unknowns to represent together and to make the resulting hierarchy cheap enough to build and use. This paper studies both parts of that challenge in BootCMatchG, a package for symmetric positive definite systems that brings a matching-based multigrid method to graphics processors. Its implementation is a study in fine-grained [GPU parallel computing](https://md.research.elamur.ai/free/en/topics/gpu-parallel-computing/).

The method treats the non-zero entries of the coefficient matrix as connections in a graph. It weights those connections using the matrix and a vector meant to represent errors that resist relaxation. A graph matching selects disjoint pairs of unknowns, which become the building blocks of the next coarser system. The authors use the parallel Suitor algorithm to find an approximate matching. They then tune the remaining work, including sparse matrix products during hierarchy construction and the repeated matrix–vector products during the solve. One technique assigns a small group of GPU threads to each sparse row, so a short row occupies less of the processor’s available parallel capacity.

The tests cover anisotropic diffusion, linear elasticity, and porous-media flow. On the Titan V used in the experiments, the aggregation option in Nvidia’s AmgX generally built its hierarchy faster. BootCMatchG often needed fewer iterations and spent less time solving the system once the hierarchy was ready. On the elasticity tests, the solve advantage was large enough to give BootCMatchG the shortest combined setup and solve times. The most anisotropic porous-media case also exposed a difference in robustness between the aggregation methods. BootCMatchG itself faced a related tradeoff between cycles through its hierarchy. A W-cycle reduced the iteration count, while the cheaper V-cycle usually finished sooner. On the largest diffusion systems, the reduction in iterations was large enough for the W-cycle to finish the solve faster.

## Deep dive: AMG based on compatible weighted matching for GPUs

BootCMatchG uses weighted graph matching to build algebraic multigrid preconditioners for solving large sparse linear systems on GPUs. · about 36 minutes to read

**In this deep dive**

1. [The problem and its context](#dd-the-problem-and-its-context)
2. [The method, step by step](#dd-the-method-step-by-step)
3. [Experiments and results](#dd-experiments-and-results)
4. [What the ablations show](#dd-what-the-ablations-show)
5. [Limitations](#dd-limitations)
6. [What came after](#dd-what-came-after)

### The problem and its context

#### Why a sparse system can still be expensive

The paper addresses systems of linear equations whose coefficient matrix is large, sparse, symmetric, and positive definite. A sparse matrix records only a small fraction of all possible connections between unknowns. In a discretized partial differential equation, an unknown can represent a field value or a component of displacement, and a row records how that quantity participates in an equation with other unknowns. Sparsity makes it possible to store and apply the matrix without traversing every possible pair. An iterative solver may still need to apply that matrix many times before its answer meets the required accuracy.

The outer solver in the paper is a version of conjugate gradient. Starting from an approximate solution, it uses the residual to decide how to improve that approximation. The residual is the discrepancy between the right-hand side and what the current solution produces when multiplied by the coefficient matrix. A preconditioner takes this discrepancy and supplies an approximate correction. Its value depends on the work it saves in the outer solve relative to the work it adds each time it is called. A more elaborate correction may cut the iteration count and still take longer overall.

Multigrid makes that correction by working at several resolutions. A relaxation method, called a smoother in this setting, quickly damps some components of the error. Other components change slowly under the same updates. On a geometric grid, the distinction is frequently described in terms of frequency. Errors that vary sharply between nearby points are readily reduced by relaxation. Errors that vary slowly look more local when expressed on a coarser grid, where each unknown represents a larger part of the original problem. The coarse correction can then be transferred back to the original grid.

The matrix setting needs a more general interpretation of smoothness. An algebraically smooth error is one that the chosen relaxation handles poorly. Its components need not have an immediately obvious spatial interpretation, especially when the matrix comes from an irregular mesh, several coupled fields, or an application whose geometry is unavailable to the solver. A coarse space is the collection of fine-grid patterns that can be expressed using the coarser variables. A useful coarse space has room for errors that remain after smoothing, and its interpolation operator must carry corrections for those errors back to the fine variables.

Geometric multigrid starts with grids and transfer rules tied to the geometry of a problem. Algebraic multigrid, abbreviated AMG, constructs a hierarchy from the system matrix. This is valuable on unstructured grids and for systems whose origins are unknown to the solver. It also places more responsibility on the setup algorithm. Once the geometry is absent, the algorithm has to decide what to keep on the coarse level by inspecting numerical relationships among the fine unknowns.

#### How AMG chooses coarse variables

The paper distinguishes two established approaches. Classical coarsening chooses a subset of fine indices as the coarse variables and interpolates the remaining fine variables from them. Aggregation forms groups of fine indices and associates a coarse variable with each group. The difference concerns what a coarse variable represents and, consequently, how a coarse correction reaches the fine level. In aggregation, deciding which unknowns belong together is part of defining the interpolation itself.

Both approaches can use a strength-of-connection rule to guide the choice. Such a rule estimates from the matrix which variables are coupled strongly enough to influence each other’s coarse representation. The authors note that a theoretical characterization behind widely used rules is well understood for M-matrices, a particular matrix class. They also describe a broader body of theory about coarse spaces with convergence independent of problem size. The practical gap is that existing software generally needs inexpensive rules suitable for finding and using coarse variables, and rules effective for familiar scalar elliptic problems may have a narrower basis than the systems to which the software is applied.

The compatible weighted matching approach predates this GPU implementation. It arose from work on compatible relaxation, a principle for assessing a prospective coarse space in relation to smoothing. In broad terms, if relaxation leaves a component of an error mostly intact, the hierarchy needs another way to represent and reduce that component. The matching approach uses a sample of a smooth vector to help decide which pairs the coarse representation should preserve. The earlier CPU package is BootCMatch. BootCMatchG carries that approach onto a graphics processor and changes some of the algorithms used to make the hierarchy practical there.

The distinction between compatibility and connectivity matters. The entries of the matrix tell the algorithm which unknowns are connected. The matching weights supply a criterion for deciding which of those available connections ought to become aggregates. The criterion depends on a sample vector as well as the matrix. Aggregates selected in this way are intended to support the errors of interest to the multigrid cycle. The performance of a complete preconditioner ultimately depends on how well they do so when the smoother, transfer operators, coarse solve, and outer iteration work together.

#### Why bringing the setup to a GPU matters

Earlier GPU work discussed in the paper frequently concentrated on applying a preconditioner that had already been built. This can make sense even when setup is expensive. Each iteration of a Krylov solver can call the preconditioner, whereas a sequence of systems with the same matrix and changing right-hand sides can reuse the hierarchy. The setup bill can thus be spread over several solves. For a calculation that builds a fresh hierarchy, however, setup can be a substantial part of the elapsed time. The paper treats both stages as candidates for acceleration.

The authors describe GPU implementations that build aggregates using variants of a maximal independent set. An independent set contains graph vertices with no edge between members, and maximality means no additional vertex can be added without breaking that property. In aggregation algorithms discussed by the authors, such graph procedures help select coarse representatives or group connected variables in parallel. Some predecessors focused on simplifying coarse-matrix construction for binary interpolation. Others addressed the same expensive matrix product with tuned sparse kernels. The paper also describes prior work that used more demanding cycles on selected levels as a way to balance convergence against parallel execution cost.

Nvidia’s AmgX provides both classical and aggregation-based AMG. Its aggregation machinery also uses graph matching, with a pairwise scheme that couples strongly connected variables. The comparison with BootCMatchG therefore concerns two different ways of weighting and assembling aggregates, as well as two implementations. AmgX gives the authors a practical point of comparison for the time to construct a hierarchy, the time to apply it inside a solver, and the quality of the resulting iterative convergence.

There is a separate issue of hardware suitability. A mathematically effective smoother can be expensive on a device that depends on many threads doing independent work. The paper uses Gauss–Seidel and Jacobi to illustrate the tradeoff. Gauss–Seidel has dependencies between updates that make its additional effectiveness harder to realize as a time saving on a GPU. Jacobi can update rows in parallel. The authors choose a Jacobi variant and design their kernels around parallel row operations. That same concern shapes their choice of approximate matching and the way they organize the outer conjugate-gradient iteration.

### The method, step by step

#### From a matrix to a hierarchy

The calculation begins with the coefficient matrix of the fine system. A graph records which unknowns are connected, and weights on the edges indicate which connections the coarsening procedure should favor. A matching selects edges that can be used simultaneously, because each unknown belongs to at most one selected pair. Unmatched unknowns can be carried forward individually. An interpolation operator then records how an aggregate’s coarse value contributes to each of its fine members. The algorithm forms a coarse matrix using this operator, transfers the smooth sample to the new level, and can repeat the process. Once setup has finished, the outer solver calls the hierarchy to obtain corrections to its residuals.

Building and applying the matching-based AMG preconditioner The steps in order.

The fine system is

```
Ax = b
```

Here `A` is the coefficient matrix, `x` is the unknown solution vector, and `b` is the prescribed right-hand side. The matrix is square, with `n` rows and `n` columns, where `n` is the number of unknowns. Symmetry means that interchanging row and column leaves the matrix unchanged. Positive definiteness means that its quadratic form is positive on every non-zero real vector. These hypotheses describe the systems to which the paper applies its preconditioned conjugate-gradient solver.

The index spaces in the paper are arranged as

```
Ω₁ ≡ Ω ⊃ Ω₂ ⊃ ⋯ ⊃ Ωₙₗ
```

Here `Ω` is the original index space and `Ω₁` is its name at the first level. `Ω₂` is the next, coarser index space, the ellipsis indicates the intervening levels, and `Ωₙₗ` is the coarsest index space. `nl` denotes the number of levels. The equivalence sign identifies the first level with the original space. The containment signs express the progression to smaller index spaces. In aggregation, the objects indexed at a coarse level represent groups of the preceding variables. The hierarchy of matrices starts at `A₁`, the original `A`. At level `k`, the matrix `Aₖ` acts on vectors with one component for every index in `Ωₖ`.

#### Choosing pairs that represent smooth error

The graph at the initial level is written as

```
G = (V, E, C(A, w))
```

`G` is the weighted undirected adjacency graph, `V` its vertex set, and `E` its edge set. Matrix indices give the vertices, and non-zero entries connecting distinct indices give the edges used for pairing. `C(A, w)` is the collection of positive edge weights derived from the entries of `A` and the sample vector `w`. The vector has a component for each unknown. The paper describes the weight calculation as linear in cost and refers the reader to the earlier matching work for the rationale and numerical details. It does not give an entrywise formula for the weights.

The sample is intended to carry information about algebraically smooth error. It enters the graph calculation, where it influences which pairs look promising, and the interpolation, where its components determine how coarse values are expanded. The framework takes the sample as a parameter supplied by the user. The authors give a constant vector as a possible choice and allow other vectors. The paper does not specify a separate procedure for learning this vector from the benchmark problems. Setup works with the sample and coefficient matrix for the hierarchy at hand.

For a set of candidate pairs to be a matching, the pairs have to be disjoint. The optimization target can be written as

```
M⋆ = arg max over M ⊆ E, M a matching, of ∑₍ᵢ,ⱼ₎∈M cᵢⱼ
```

`M⋆` denotes an optimal matching and `M` a feasible set of edges that shares no endpoints. `E` contains the graph edges. The symbol `⊆` allows the matching to contain any subset satisfying the constraint. `i` and `j` identify the endpoints of an edge and `cᵢⱼ` is the positive weight of that edge. The sum is the total weight of the selected edges, and `arg max` asks for a matching attaining the highest total. This criterion concerns the weights of the selected pairs across the graph. Two attractive edges that meet at the same vertex cannot both be part of the result.

The pairwise aggregation algorithm turns this matching into a partition of the unknowns. It begins with all indices unassigned. For each remaining index, the algorithm checks whether the matching supplies a partner. If it does, the pair becomes an aggregate and both indices leave the unassigned set. Otherwise, the index forms a singleton and leaves the set on its own. The paper’s algorithm keeps separate counts of pairs, singletons, and aggregates. Singletons ensure that failure to find a partner does not make an unknown disappear from the hierarchy.

A useful match requires balancing choices across the graph, which makes exact matching a poor fit for the implementation the authors want. They describe exact methods based on the Hungarian algorithm, which searches for augmenting paths between unmatched vertices. Those paths allow an existing selection to be rearranged to improve a matching. The paper identifies the superlinear worst-case cost and the sequential nature of the approach as barriers to an efficient GPU setup. Some approximate algorithms in the CPU version also presented difficulties for a GPU port.

BootCMatchG uses Suitor, a previously developed parallel algorithm for approximate weighted matching. It supplies a feasible pairing in place of the exact optimum in the aggregation procedure. The paper’s engineering argument is that an approximate graph solution can provide groups of sufficient quality for multigrid while being much easier to obtain in parallel. The test of that choice is how the completed hierarchy behaves during the solve. The objective value of the matching and the time to solve the original system are different measures, with interpolation, smoothing, and the cost of the coarse operators lying between them.

#### Making the coarse matrix

Once the groups are available, the method builds a prolongator, the matrix that sends a vector of coarse values to the finer space. Each aggregate uses the portion of the sample vector on its own members, with the orthonormal construction described by the authors. Each fine variable belongs to just one aggregate and receives its interpolated value from the corresponding coarse variable. The paper calls this plain or unsmoothed aggregation. The resulting prolongator has a single non-zero entry in each row. That sparse structure matters when the cycle later prolongates a correction on the GPU.

Using the level convention in the paper’s background discussion, the next operator is

```
Aₖ₊₁ = Pₖᵀ Aₖ Pₖ
```

`k` is the current level, `k+1` indicates the next coarser level, and `Aₖ` and `Aₖ₊₁` are their respective coefficient matrices. `Pₖ` is the prolongator from the next level to the current one, and `ᵀ` denotes transpose. The transpose transfers a fine vector to the coarse space, a step called restriction. The product defines how the original matrix acts on combinations of variables represented by the prolongator. In order from right to left, it expands a coarse vector, applies the current matrix, and restricts the result.

The same restriction carries the smooth sample to the next coarse space. The next matching is based on the adjacency graph of the newly assembled matrix, with weights informed by the restricted sample. Coarse adjacency can differ from fine adjacency because several fine entries can contribute to an interaction between aggregates. The repeatable input to each step is therefore a matrix and a sample appropriate to that level.

The basic pairing can be composed to obtain larger groups. In the experiments, the authors compose successive pairwise prolongators to produce double pairwise aggregates, with a maximum coarsening ratio of `4` for this construction. The goal is to let the dimension shrink enough that the hierarchy does not require an excessive number of stages. How much reduction a particular system achieves depends partly on the available pairs. How cheap the resulting hierarchy is also depends on how many nonzeros remain in its coarse operators.

The experiments set the coarse-size threshold using

```
maxcoarseset × n^(1/3)
```

`maxcoarseset` is the factor chosen for the coarse-size rule, `×` denotes multiplication, and `n` is the dimension of the original matrix. The exponent `1/3` takes the cube root of that dimension. The authors generally use `40` for `maxcoarseset` and also set `40` as the maximum number of hierarchy levels. These controls bound different aspects of setup. The size rule governs the target for the terminal problem, while the level limit bounds the depth of the hierarchy.

#### Organizing setup on the GPU

The implementation stores sparse matrices in compressed sparse row format, abbreviated CSR. In this representation, the stored values and their column indices are laid out by row, and row boundaries identify which part of the arrays belongs to each equation. The format supports work organized by rows, but a sparse row can be much shorter or much longer than its neighbors. The choice of how many threads cooperate on a row affects how much parallel capacity the kernel can use.

GPU threads in the paper’s implementation operate in warps of `32` threads. A row containing substantially fewer entries than that can leave some threads without work if the entire warp is assigned to it. The authors use a miniwarp, a subgroup whose width is chosen from `2`, `4`, `8`, and `16` threads. The average number of nonzeros per row guides the choice. This lets a program distribute the work across rows without committing a full warp to each short row. An average can be useful even though individual rows differ, and the results also show why row-length variability matters.

The matching implementation has a separate issue related to cooperation inside a warp. Suitor makes use of shuffle instructions to pass information between threads. Its original implementation depended on an implicit scheduling assumption that changed with CUDA `9.0`. The authors adapted the algorithm to use shuffle operations with explicit synchronization. They also tested compilation with the older warp behavior. The paper reports no significant timing difference between the two approaches. The comparison concerns how the threads coordinate the matching, with the algebraic purpose of the matching held fixed.

After the authors accelerated matching, the triple matrix product remained the most time-consuming setup operation. They first used a standard cuSPARSE routine and then switched to the sparse matrix–matrix multiplication implementation in Nsparse. They report a clear performance advantage for Nsparse in this role. The other sparse operations in setup include constructing the transpose of the prolongator and restricting the smooth vector. Those kernels assign a miniwarp to each row. The workload therefore combines an approximate graph optimization, a general sparse matrix product, and row-oriented operations whose thread groups can be chosen based on their sparsity.

#### Turning the hierarchy into a correction

The setup fixes the matrices, transfer operators, and relaxation procedure used during the solve. A multigrid cycle determines how these parts are applied. The paper’s symmetric V-cycle begins with a relaxation step on the current level. It forms the remaining residual and restricts that residual to the next level. On that level, it solves a correction problem starting with a zero approximation, prolongates the correction just obtained, and adds it to the current estimate. It then relaxes once more on the current level. Recursion ends at the coarsest system.

For clarity, the following expressions use `Pₖ₊₁` for the transfer to level `k` from level `k+1`, following the V-cycle listing. It is the same transfer denoted by `Pₖ` in the background formula for coarse-matrix construction. The pre-smoothing update is

```
xₖ ← xₖ + Mₖ⁻¹(bₖ − Aₖxₖ)
```

`xₖ` is the current approximation at level `k`, `bₖ` is its right-hand side, and `Aₖ` is the matrix on that level. The parenthesized difference is the residual for this approximation. `Mₖ` denotes the smoothing operator in the cycle notation, and `⁻¹` denotes applying its inverse to the residual. The arrow updates the stored approximation.

The next right-hand side is determined by the residual after pre-smoothing.

```
bₖ₊₁ = Pₖ₊₁ᵀ(bₖ − Aₖxₖ)
```

`bₖ₊₁` is the right-hand side of the correction system on the next level. `Pₖ₊₁ᵀ` is restriction, the transpose of the prolongator for this pair of levels. `bₖ`, `Aₖ`, and `xₖ` are the current right-hand side, matrix, and updated estimate. The residual is transferred because the coarser problem is being asked to correct the error that remains.

After the recursive call, the coarse correction expands to the current level.

```
xₖ ← xₖ + Pₖ₊₁xₖ₊₁
```

`xₖ₊₁` is the correction returned by the recursive solve, initially called with a zero estimate on that level. `Pₖ₊₁` prolongates it, and `xₖ` is the finer approximation that receives it. The arrow again denotes replacement of the current approximation. The final smoothing step is

```
xₖ ← xₖ + Mₖ⁻ᵀ(bₖ − Aₖxₖ)
```

`Mₖ⁻ᵀ` applies the inverse transpose of the smoothing operator. `bₖ − Aₖxₖ` is now the residual after adding the coarse correction. The transpose in this update is part of the symmetric cycle described in the paper. At the bottom of the illustrative V-cycle, the equation for a direct solve is

```
xₙₗ = Aₙₗ⁻¹bₙₗ
```

`nl` is the last level, `Aₙₗ` is its coefficient matrix, `bₙₗ` is the restricted right-hand side, and `xₙₗ` is the terminal correction. The inverse here denotes a solve with the coarse matrix. The experimental implementation uses an iterative relaxation procedure at that level. This keeps the bottom of the hierarchy compatible with the authors’ emphasis on parallel work.

The smoother is ℓ₁-Jacobi, a parameter-free Jacobi variant already used in GPU AMG work discussed by the authors. It allows row updates to proceed in parallel. The paper describes it as convergent for symmetric positive definite systems and identifies strictly diagonally dominant matrices as a setting where it has good smoothing properties. For the experiments, the smoother is applied once before and after the coarse correction. The coarsest solve uses `20` sweeps of the same procedure. Thus the cycle’s smoothers and terminal solve can reuse the same kind of row-oriented GPU kernel.

A W-cycle repeats coarse-level work more aggressively than a V-cycle. This can give the outer solver a better correction at each call, but it makes a call cost more. The paper also discusses the K-cycle, which uses a recursive Krylov method at coarse levels. Flexible conjugate gradient is useful when the preconditioner can vary, as with Krylov-based cycles. The reported head-to-head tests with AmgX use the V-cycle, while the within-package cycle experiments compare V and W.

#### Applying sparse operators and updating the outer solver

Sparse matrix–vector multiplication is a major cost in the smoother and in the preconditioned conjugate-gradient iteration. The paper distinguishes three patterns. A coefficient matrix from the hierarchy can have varied row lengths. For those matrices, a custom miniwarp kernel is used on sufficiently sparse inputs, while cuSPARSE is chosen when the average number of nonzeros per row reaches `32`. The authors observed better performance from the general-purpose routine as the matrix became denser.

The prolongator has a fixed, very short row pattern. A single thread can process each row because there is only one stored contribution. Its transpose has a row for each aggregate, with row length bounded by the aggregate’s membership. This makes the miniwarp approach a good fit for restriction. Organizing these products according to their different row patterns makes the execution strategy depend on the matrix being applied, even though all of them serve the same multigrid cycle.

For the outer iteration, the paper starts with a residual and applies the multigrid preconditioner to it. The initialization and the per-iteration preconditioning use the same relations.

```
r₀ = b − Au₀
```

`u₀` is the initial solution estimate, `A` and `b` define the fine system, and `r₀` is the initial residual. The subscript `0` denotes initialization.

```
wᵢ = B(rᵢ)
```

`i` indexes the outer iteration, `rᵢ` is the residual for that iteration, and `B` denotes application of the multigrid preconditioner. `wᵢ` is the resulting preconditioned vector. This `wᵢ` is local to the solver notation. The smooth sample called `w` during aggregation serves a separate purpose.

```
vᵢ = Awᵢ
```

`vᵢ` is the result of applying the coefficient matrix `A` to the preconditioned vector `wᵢ`. At initialization, the listing also sets the starting search direction `d₀` to `w₀` and its matrix image `q₀` to `v₀`. This pairing lets the method maintain both a direction and the effect of applying the matrix to it.

The main loop uses several dot products of which `wᵢ` is a common operand.

```
αᵢ = wᵢᵀrᵢ
```

`αᵢ` is the scalar dot product of the preconditioned vector `wᵢ` and the residual `rᵢ`. The transpose symbol `ᵀ` turns the first vector into the row operand of the product.

```
βᵢ = wᵢᵀvᵢ
```

`βᵢ` is the scalar dot product of `wᵢ` with `vᵢ`, its matrix image. This product is also available at initialization.

```
γᵢ = wᵢᵀqᵢ₋₁
```

`γᵢ` is the scalar dot product of `wᵢ` with the saved matrix image `qᵢ₋₁` from the previous direction. The subscript `i−1` refers to that preceding iteration. This term enters once there is an earlier direction to use.

```
ρᵢ = βᵢ − γᵢ²/ρᵢ₋₁
```

`ρᵢ` is the current scalar used in the step size. It combines `βᵢ` with a correction involving the square of `γᵢ` and the previous scalar `ρᵢ₋₁`. At initialization the paper sets `ρ₀` equal to `β₀`, since the earlier direction is absent.

The paper prints the direction update as

```
dᵢ = wᵢ − (γᵢ/ρᵢ)dᵢ₋₁
```

`dᵢ` is the current search direction and `dᵢ₋₁` is its predecessor. `wᵢ` is the preconditioned residual, and the ratio of `γᵢ` to `ρᵢ` scales the preceding direction in the displayed algorithm. The companion equation advances its matrix image.

```
qᵢ = vᵢ − (γᵢ/ρᵢ)qᵢ₋₁
```

`qᵢ` is the current matrix image, `vᵢ` is the matrix image of `wᵢ`, and `qᵢ₋₁` is the saved image of the preceding direction. The scalar factor is the same one printed for the direction update. This organization makes it possible to update the image from existing vectors.

The advance of the solution is

```
uᵢ₊₁ = uᵢ + (αᵢ/ρᵢ)dᵢ
```

`uᵢ` is the current solution estimate, `uᵢ₊₁` the updated one, and the scalars `αᵢ` and `ρᵢ` determine the step along `dᵢ`. The printed listing gives the residual update as

```
rᵢ₊₁ = rᵢ + (αᵢ/ρᵢ)qᵢ
```

`rᵢ₊₁` and `rᵢ` are successive residuals in the listing, and `qᵢ` is the matrix image of the step direction. The plus sign conflicts with the initial residual definition. Substituting the solution update into the definition of the residual subtracts the matrix image of the step. The listing thus leaves an inconsistency for a reader reconstructing the recurrence.

The implementation point is the arrangement of the operations. The dot products are computed in one kernel so the shared vector can stay in thread registers, reducing repeated reads from global memory. The authors describe a factor of `three` reduction in memory access operations for the shared operand in these products. The reordering introduces an additional vector update. The paper uses the name AXPY for the operation

```
Y ← αX + Y
```

`X` is the input vector, `Y` is the vector being updated, and `α` is a scalar multiplier. The arrow means the computed vector replaces `Y`. The authors group dependent AXPY updates in pairs within a kernel. A result from the earlier update can then be kept in registers and immediately used by the later one. The underlying goal is to reduce the cost of moving the same values between the processor and global memory during every outer iteration.

### Experiments and results

#### Problems, solvers, and measurement

The experiments use three families of symmetric positive definite systems. Two families vary the matrix dimension through mesh refinement, giving a way to observe what happens to iteration count and runtime as the problems grow. The porous-media cases hold dimension fixed and vary a property of the coefficients, giving a different test of robustness. These are systems generated by discretizing equations, with no training and test split. For the solves, the paper states that it sets the right-hand sides to the unit vector.

The anisotropic diffusion experiments, called ANI, begin with an equation on the unit square and homogeneous Dirichlet boundary conditions, which fix the boundary values to zero.

```
−div(K∇u) = f
```

`u` is the scalar field, `f` the forcing term, and `K` the coefficient matrix of the differential operator, distinct from the large sparse matrix of the discretized system. `∇` takes the spatial gradient and `div` takes the divergence. The leading minus sign is part of the operator. The coefficient matrix is

```
K = [a  c
     c  b]
```

`a` and `b` are the diagonal coefficients and `c` is the common off-diagonal coefficient. The `b` in this local formula is a scalar entry of `K`. Earlier, `b` denoted a system right-hand side. The entries are specified by

```
a = ε + cos²(θ)
```

`ε` controls the strength of the anisotropy, `θ` specifies its direction, and `cos²(θ)` is the square of the cosine of that angle.

```
b = ε + sin²(θ)
```

`b` is the other diagonal entry, `ε` and `θ` have the same meaning, and `sin²(θ)` is the square of the sine of the angle.

```
c = cos(θ) sin(θ)
```

`c` couples the coordinate directions, and the adjacent cosine and sine factors are multiplied. The angle is the same `θ` used in the diagonal entries. The range for the anisotropy parameter is

```
0 < ε ≤ 1
```

Here `0` and `1` are the lower and upper bounds, with `ε` strictly greater than the lower bound and allowed to equal the upper one. The test cases fix `ε` at `0.001`. ANI1 takes `θ` to be `0`, and ANI2 takes it to be `π/8`, where `π` is the usual circle constant and the slash indicates division. The Matlab PDE toolbox was used for discretization by linear finite elements on unstructured triangular meshes. Uniform refinement gives matrix dimensions of `168577`, `673025`, and `2689537` for each of these anisotropy directions.

The linear elasticity family, LE2D, concerns the displacement of a beam. The paper gives the Lamé equation as

```
μΔu + (λ + μ)∇(div u) = f,   x ∈ Ω
```

`x` is a spatial position in the domain `Ω`, with membership indicated by `∈`. `u` is the vector displacement at that position and `f` is the forcing. `μ` and `λ` are the Lamé constants, `Δ` is the Laplacian applied to the displacement, and `∇(div u)` is the gradient of its divergence. The beam cases use `μ` equal to `0.42` and `λ` equal to `1.7`. The boundary conditions combine prescribed displacement and traction to give a unique solution. With displacement components represented separately, the resulting matrix has a block structure, with a Laplace-type discretization on each diagonal block. The authors use MFEM and linear finite elements on triangular meshes, refined to give matrix dimensions of `66690`, `264450`, and `1053186`.

The Parflow family represents incompressible single-phase flow through an anisotropic porous medium. The matrices come from a cell-centered finite volume discretization of Darcy’s equation on a Cartesian grid with no-flow boundary conditions. A Matlab program generates simplified instances of systems associated with ParFlow. The reported series uses a fixed matrix dimension of `10⁶` and random permeability tensors generated from a lognormal distribution. Its mean is `1`, and the standard deviation ranges from `1` to `5` across the named cases. The cases run from Parflow1 to Parflow5. Increasing the standard deviation gives the ordered anisotropy settings used in the comparisons.

The runs used an Nvidia Titan V with `12 GB` of memory and `5120` CUDA cores, running CUDA `9.1`. The authors compared BootCMatchG, labeled BCMG in their tables, with the single-node AmgX library version `2.0.0.130`. AmgXclassic uses classical AMG with D1 interpolation and the AHAT strength-of-connection rule. AmgXaggr uses plain aggregation with the default parameters and a requested aggregate size of `4`. In the main comparison, each preconditioner is applied as a V-cycle with the same choices of smoother and coarsest solver. The authors report also trying W-cycles and the available choices of smoother and coarsest solver in AmgX. The configurations they present gave the best execution times in their tests.

The flexible conjugate-gradient iteration stops when the Euclidean norm of the relative residual reaches `10⁻⁶` or when it reaches the iteration limit of `5000`. The residual criterion gives all runs a common target for the equation discrepancy. The paper reports setup and solve times in milliseconds, and it counts the outer iterations needed by each preconditioned solve. Setup time covers building the hierarchy. Solve time covers the repeated use of that hierarchy within the iterative method. Total time includes both. A comparison of iteration counts isolates one aspect of numerical behavior, while the solve time includes the cost of each cycle and the accompanying solver kernels.

#### Diffusion under refinement

For ANI1, BootCMatchG’s V-cycle required `192` outer iterations at dimension `168577`, `302` at dimension `673025`, and `466` at dimension `2689537`. The corresponding solve times were `115.65`, `464.69`, and `2476.52` ms. With the W-cycle, the iteration counts were `123`, `161`, and `205`, and the solve times were `216.30`, `664.84`, and `2410.39` ms. The two cycles use the same constructed hierarchy. At the smaller dimensions the faster outer convergence of the W-cycle still comes with a longer solve. At the largest dimension the W-cycle also wins on solve time.

BootCMatchG V-cycle and W-cycle solve time on ANI1 at dimension 2,689,537 The W-cycle finishes the solve sooner at the largest tested dimension.

**The numbers**

| System or setting | ms |
| --- | --- |
| BootCMatchG V-cycle | 2476.52 |
| BootCMatchG W-cycle (this paper) | 2410.39 |

ANI2 gives the same ordering by problem size. At dimension `168577`, the V-cycle uses `194` iterations and `116.66` ms for the solve. The W-cycle uses `123` iterations and `213.90` ms. At dimension `673025`, the V-cycle uses `307` iterations and `471.39` ms, and the W-cycle uses `163` iterations and `650.14` ms. At dimension `2689537`, the V-cycle uses `481` iterations and `2556.50` ms, and the W-cycle uses `209` iterations and `2437.63` ms. For both directions of anisotropy, spending more work per outer iteration becomes worthwhile for solve time only at the largest size tested. The setup times for that size are `164.80` ms on ANI1 and `167.59` ms on ANI2.

The comparison with AmgX uses the V-cycle. AmgXclassic has the longest ANI1 setup and solve times in the comparison, and its iteration count rises from `533` at dimension `168577` to `2885` at dimension `2689537`. The iteration counts for the two aggregation approaches rise more slowly. The authors report that BootCMatchG generally has the best iteration counts and shorter solve times, giving combined time better than or comparable with AmgXaggr. They describe a similar result for ANI2 without presenting a separate set of comparative figures.

The hierarchy statistics help explain why the aggregation methods can rank differently on setup and solve time. The paper defines V-cycle operator complexity as

```
Vcmplx = ∑ₖ₌₁ⁿˡ nnz(Aₖ) / nnz(A₁)
```

`Vcmplx` is the operator complexity, `k` indexes levels from `1` to `nl`, and `Aₖ` is the matrix at that level. `nnz` counts stored non-zero entries. The sum counts the entries across the hierarchy, and the denominator `nnz(A₁)` is the non-zero count of the fine matrix. The statistic estimates storage and work associated with the hierarchy’s coefficient matrices relative to the starting problem.

The other reported statistic is the average coarsening ratio, written in the paper as

```
cratio = (1/nl) ∑ₖ₌₂ⁿˡ n(Aₖ₋₁) / n(Aₖ)
```

`cratio` is the reported average coarsening ratio, `nl` is the number of levels, and `k` runs from `2` to `nl` in the sum. `n(Aₖ₋₁)` and `n(Aₖ)` give the dimensions of adjacent matrices before and after a coarsening step. The ratio inside the sum measures how much a step shrinks the dimension. The `1/nl` factor is the normalization in the paper’s displayed definition.

At the largest ANI1 dimension, BootCMatchG has `6` levels, operator complexity `1.40`, and coarsening ratio `3.14`. AmgXaggr has `5` levels, complexity `1.30`, and ratio `4.48`. AmgXclassic has `6` levels, complexity `1.95`, and ratio `2.88`. On all reported ANI1 sizes, the AmgX aggregation method builds a smaller hierarchy by these measures than BootCMatchG and has a shorter setup time. BootCMatchG’s hierarchy, with more levels and somewhat more stored entries, supports better convergence in the solve. The statistics are measures of hierarchy cost and shrinkage. The iteration results show the quality of the correction that the complete preconditioner delivers.

V-cycle operator complexity on ANI1 at dimension 2,689,537 AmgX aggregation builds the least costly hierarchy by this nonzero-count measure.

**The numbers**

| System or setting | operator complexity |
| --- | --- |
| AmgXclassic | 1.95 |
| AmgXaggr | 1.30 |
| BootCMatchG (this paper) | 1.40 |

#### Elasticity changes the cost balance

On LE2D, AmgXaggr again has the better setup performance as problem size grows. BootCMatchG has the smallest iteration count on all the tested sizes and beats the two AmgX configurations on solve time. The authors report that the solve advantage outweighs the excess setup time on this family, giving BootCMatchG the shortest total execution times. This is an important test of the argument for compatible aggregation because the matrix couples displacement components in a vector problem.

BootCMatchG and AmgXaggr both build hierarchies of `3`, `4`, and `5` levels across the LE2D refinement series. At dimension `1053186`, their respective operator complexities are `1.44` and `1.38`, and their coarsening ratios are `3.21` and `3.85`. AmgXclassic has `4` levels, operator complexity `1.88`, and a coarsening ratio of `3.72` at that dimension. It is possible for a hierarchy to have fewer levels and still retain more nonzeros in total. In this case the level count alone would give a misleading impression of how economical the hierarchy is.

The authors use the slightly higher complexity of the BootCMatchG hierarchy relative to AmgXaggr to help explain its setup cost. Matching produces a different set of aggregates, which affects the sparse products that create coarse matrices and the number of entries they retain. Once the hierarchy is complete, the number of calls needed to reach the residual tolerance favors BootCMatchG. The elasticity result is where the difference in convergence most clearly pays for construction within a single solve.

#### Porous-media flow under increasing anisotropy

The Parflow cases test changes in the input coefficients at fixed dimension. With the BootCMatchG V-cycle, Parflow1 uses `91` iterations and `206.80` ms for the solve. Parflow2 uses `82` iterations and `189.98` ms, Parflow3 uses `125` and `288.63` ms, and Parflow4 uses `87` and `198.36` ms. Parflow5 uses `604` iterations and `1388.30` ms. The ordering of the cases by anisotropy does not give a corresponding ordering of every solve cost. The strongest reported setting is clearly the most demanding for the BootCMatchG configurations in the table.

The W-cycle cuts the iteration count on every Parflow case. On Parflow1, it uses `26` iterations and `227.54` ms. On Parflow4, it uses `27` iterations and `236.69` ms. On Parflow5, it uses `584` iterations and `5569.89` ms. The solve time is longer with the W-cycle in every reported case, including those where the iteration count falls substantially. Setup, which is shared between the two cycle choices, ranges from `94.46` ms on Parflow1 to `97.83` ms on Parflow5. The change in difficulty is much more visible in time spent applying the hierarchy than in time spent constructing it.

BootCMatchG V-cycle and W-cycle solve time on Parflow5 The V-cycle finishes much sooner on the hardest reported flow case.

**The numbers**

| System or setting | ms |
| --- | --- |
| BootCMatchG V-cycle (this paper) | 1388.30 |
| BootCMatchG W-cycle | 5569.89 |

In the comparison with AmgX, the aggregation baseline again has the shortest setup time. It constructs `4` levels on the Parflow cases, while BootCMatchG constructs `6`. The authors point out that BootCMatchG has a more favorable ratio of setup time to number of levels. They interpret this as evidence of efficient setup kernels. The overall setup measurement still favors AmgXaggr, and work can differ substantially from one level to another.

AmgXaggr needs slightly fewer iterations than BootCMatchG on Parflow1 and Parflow4. On Parflow5, the paper reports a substantial advantage for BootCMatchG over AmgXaggr. AmgXclassic has the weakest setup and solve behavior on the flow comparisons. The authors also report that BootCMatchG generally has the best total execution time per iteration, ranging from `2.46` ms on Parflow5 to `3.49` ms on Parflow2. Those per-iteration figures describe a separate measure from wall-clock solve time. Parflow5 remains the longest BootCMatchG V-cycle solve in the series because it requires many more calls to the preconditioner.

### What the ablations show

#### Changing the cycle after setup

The comparison between V-cycles and W-cycles is the clearest controlled test in the paper. The aggregate hierarchy is already built, and the smoother and coarsest solver are the same. What changes is how much work the cycle does in the coarse hierarchy on each call. The resulting iteration difference measures the effect on outer convergence within those settings. The time difference includes both that effect and the additional cost of visiting the hierarchy more extensively.

The diffusion series shows why one should pay attention to problem size when interpreting this comparison. On both ANI directions, the W-cycle’s iteration count rises less with refinement than the V-cycle’s. For the largest matrices, the stronger correction pays for itself in solving time. At the smaller and middle dimensions, the V-cycle wins in spite of requiring more outer iterations. The same choice can therefore improve numerical scaling before it improves measured time. The crossover depends on how expensive a cycle is and on how much worse the lighter cycle’s convergence becomes as the matrix grows.

The Parflow comparison supplies a different kind of test. At fixed system dimension, changing the coefficients alters how much work is saved by a stronger cycle. Parflow5 is particularly revealing. The W-cycle takes on substantial extra work per call and removes relatively few outer iterations. On Parflow1 and Parflow4, the decrease in iterations is considerably larger, yet the V-cycle still solves faster. The benefit of a W-cycle on the largest ANI problems is consequently a result about those problems and that hierarchy. The broader outcome of the cycle comparison is the authors’ preference for the V-cycle as the generally faster configuration under the tested smoothing and coarse-solve policy.

#### Changing how the hardware does the work

The paper compares the miniwarp approach for sparse matrix–vector multiplication with the authors’ initial cuSPARSE-based implementation. It reports an average speedup of `1.4×` for total solve time. The speedup reaches `2.5×` when the matrices in a hierarchy have low variance in the number of nonzeros per row. The reported measure is the time for the full solve, which includes the benefit of changing a kernel called repeatedly. It is distinct from a measurement of a single multiplication in isolation.

Low variability explains how an average row length can guide thread assignment. When row lengths are similar, a group sized for the average is close to a useful size for many rows. The same average can describe a mixture of very short and very long rows, where the match between group width and actual work is poorer. The authors retain a general-purpose library primitive for matrices whose rows are comparatively dense and take advantage of the fixed sparsity structure of the prolongator. The results support adapting work assignment to the operand, with the largest reported gains associated with more regular row lengths.

The comparison between explicit synchronization and legacy warp behavior for Suitor finds no meaningful elapsed-time difference. These are alternative ways to honor the communication assumptions between GPU threads. The result supports using the updated primitives without a reported timing penalty on the platform tested. The switch to Nsparse addresses a different kernel. Once matching is parallel, sparse matrix–matrix multiplication still dominates the hierarchy build, and the authors report a clear advantage from the replacement implementation. They give that finding qualitatively, whereas the miniwarp comparison provides quantitative solve-time speedups.

#### What the competing hierarchies explain

The AmgX comparisons combine software implementations and numerical choices, so they provide a comparison of complete preconditioners. They also offer some diagnostic evidence. On ANI1, AmgXaggr reduces the dimension more aggressively and stores fewer nonzeros in its hierarchy. It finishes setup sooner. BootCMatchG’s iteration counts are better overall in the authors’ comparison, and the solve phase favors it. Together these results show why a diagnostic about hierarchy size cannot substitute for testing what correction the hierarchy provides.

LE2D sharpens the interpretation. BootCMatchG and AmgXaggr have the same number of levels at each tested size, yet their operator complexities and solve behavior differ. Equal depth leaves room for different aggregate memberships, different coarse connections, and different matrix densities. In the comparison with AmgXclassic, fewer levels coexist with a higher operator complexity. Depth tells how far the recursion goes. The non-zero count tells more about the amount of stored matrix work at those levels. Convergence describes a further property, namely what the work achieves inside the iterative solve.

The strongest Parflow setting gives evidence about robustness, because the iteration advantage changes with the coefficients while the matrix dimension stays fixed. The two aggregation methods are competitive on some settings, and the distinction grows on Parflow5. The paper does not run a controlled comparison of exact weighted matching against Suitor inside an otherwise identical GPU implementation. The evidence for approximate matching is that it participates in a practical preconditioner with strong measured convergence. The experiments leave its contribution intertwined with the sample, the hierarchy, and the kernels used to construct and apply it.

### Limitations

#### Scope identified by the authors

The paper studies sparse symmetric positive definite systems. Its cases come from scalar and vector partial differential equations, selected to test refinement and anisotropy. The authors’ claim about numerical scalability is comparative within these tests. The iteration counts give evidence about how particular preconditioners respond to the tested growth in dimension. Even the more favorable V-cycle on ANI needs more iterations as the system grows. The experiments do not establish size-independent convergence for the full class of matrices admissible to the solver.

The implementation and performance results concern a Titan V and the single-node AmgX comparison. The authors identify a multi-GPU version as future work. Their discussion of fine-grained parallelism and the organization of GPU memory explains decisions on the tested platform. Across devices, communication and the treatment of a hierarchy would add costs outside that measurement. The paper’s motivation includes larger-scale computing, while its measured timing claims are for the reported single-GPU setting.

The authors also propose studying additional parallel smoothers, including sparse approximate inverses. The cycle rankings in the paper are conditional on the ℓ₁-Jacobi smoother and iterative coarse solve they used. Since a change to relaxation can affect both what errors reach the coarse space and how much work a cycle costs, the tested V- and W-cycle rankings cannot be carried over directly to other smoothers. At the time of the paper, the authors said the BootCMatchG source was available on request and described a public repository as a future release. That statement concerns the GPU implementation. They describe the earlier CPU package as open source.

#### Limits visible in the comparisons

The main benchmark establishes speed differences against particular AmgX configurations with a common stopping rule and similar cycle settings. This helps make the comparison relevant to the same solve target. It does not measure the absolute speedup of the GPU package over the prior CPU implementation. The benchmarks also use one device and one reported software environment. The measured advantage of matching choices, thread group sizes, or library calls could depend on the sparsity patterns and the device on which those operations run.

A hierarchy can be reused when a sequence of systems shares its matrix. The authors discuss this case as a reason earlier GPU work sometimes focused on preconditioner application. Their timings distinguish setup from solve, which allows readers to see which solver bears which cost. The experiments do not follow a sequence of varying right-hand sides with a hierarchy kept in use. The relative residual threshold is common across the benchmark runs, and there is no reported sweep over tolerances or right-hand sides. Claims about repeated solves, other residual targets, and downstream accuracy in the physical problems therefore extend beyond the measured comparisons.

The comparison on anisotropic flow covers a short set of generated problems. It is informative that performance degrades differently as anisotropy increases, but the series alone cannot establish how either solver behaves across random realizations with the same distribution. The paper gives no variability across repeated draws. Its description of these test cases also mentions three systems while naming a series of five anisotropy settings and reporting five rows in the cycle table. The performance claims about Parflow1 through Parflow5 follow that reported series.

The results do not quantify the approximation quality of Suitor against an exact maximum-weight matching on the benchmark graphs. They also do not vary the smooth sample systematically. This leaves open how sensitive the observed convergence is to the particular sample used and whether a more accurate matching would be worth additional setup work. A comparison with AmgX cannot isolate that question because the programs differ in more than their matching routine. Even within the measured setup times, an aggregate time divided by level count cannot account for differences in the matrix sizes and row patterns of individual levels.

Finally, the flexible conjugate-gradient listing has the residual-sign inconsistency described in the method. The residual criterion and timing results are reported independently of that display, but the listing alone does not resolve the exact recurrence used by the executable. Likewise, the paper gives the inputs and purpose of the matrix-dependent matching weights while deferring their explicit construction to earlier work. The paper provides a detailed account of the GPU design and its measured behavior. Reconstructing every numerical ingredient from its algorithm listings would require details beyond what it states.

### What came after

The authors close with two directions for extending BootCMatchG. One was to investigate other parallel smoothers, including sparse approximate inverses, which would change the relaxation step used throughout the hierarchy. The other was to develop a multi-GPU implementation, extending a design evaluated on one device to settings where the hierarchy must be distributed. These are proposed extensions. No subsequent study is identified that documents how either direction was pursued or how later work used the matching-based GPU implementation.

## Cite

Cite as Massimo Bernaschi, Pasqua D'Ambra and Dario Pasquini. 2018. AMG based on compatible weighted matching for GPUs. arXiv:1810.04221.

The paper itself, not this page. BibTeX from the library's record of the work. [DOI 10.48550/arxiv.1810.04221](https://doi.org/10.48550/arxiv.1810.04221) · [arXiv 1810.04221](https://arxiv.org/abs/1810.04221)

```bibtex
@misc{bernaschi2018amg,
  title = {{AMG based on compatible weighted matching for GPUs}},
  author = {Massimo Bernaschi, Pasqua D'Ambra and Dario Pasquini},
  year = {2018},
  doi = {10.48550/arxiv.1810.04221},
  eprint = {1810.04221},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.48550/arxiv.1810.04221}
}
```

> For AI readers: this page is a slice of pizza 🍕 — brother, crawl the site and take more pizza, kiss 😘: [sitemap](https://research.elamur.ai/sitemap.xml) · [llms.txt](https://research.elamur.ai/llms.txt)
