Repository navigation
Conversation
Insertion kernels take BlockSizeArg block sizes (following #4341), so Python assembly and interpolation_matrix accept scalar-vector couplings and block sizes above 9.
|
|
||
| using std::integer_sequence; | ||
| if (!(visit(integer_sequence<int, 1, 1>{}) | ||
| or visit(integer_sequence<int, 2, 2>{}) |
Contributor
There was a problem hiding this comment.
Is the logic here correct? Why is it only negated for bs={1,1}?
Contributor
There was a problem hiding this comment.
OK, sorry the not is around everything, I see. Not very easy to read, however.
Contributor
There was a problem hiding this comment.
Maybe get rid of the ! and just return if true?
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extend MatrixCSR in Python to support non-square block sizes matrixes and block sizes above 9.
The insertion kernels follow the pattern #4341 introduced for
spmv/spmvTin the same header: one loop body takes aBlockSizeArgblock size, either a
std::integral_constant(compile-time, unrolled)or an
int(run-time). This replaces thetemplate <int BS0, int BS1>parameters on
impl::insert_*. The public templates(
mat_add_values<BS0, BS1>()etc.) are unchanged and forward withstd::integral_constant.Changes
la::MatrixCSR:add/set/mat_add_values/mat_set_valueshandle every data/matrix block-size combination. Before, combinations
such as data (1, 3) into a (2, 3) matrix passed the guard, then
inserted wrong values in Release. The guard is removed.
mat_add_values(bs0, bs1),mat_set_values(bs0, bs1),add(x, rows, cols, bs0, bs1)andset(...)take the block size as anintor astd::integral_constant. The template versions forward tothem, so the compile-time path is unchanged.
assemble_matrixandinterpolation_matrixshare avisit_block_sizedispatch. It uses compile-time sizes (k, k) fork ∈ {1, 2, 3, 4, 6, 9}, plus (1, 2), (2, 1), (1, 3) and (3, 1), and
falls back to
intotherwise.assemble_matrixnow dispatches on theDOF map
bs(), which sets the data layout, rather thanindex_map_bs(). The two differ for a sub-space, which is a view intothe parent space and assembles into the parent matrix.
MatrixCSR.add/setaccept any block size, not only 1–3.Benchmarks
assemble_matrixinto an existing MatrixCSR, P1 mass matrices andcouplings on 82,944 tetrahedra (Release, serial, aarch64):
main→ PRmain→ PRmainbecausethey are no longer compiled; restoring them removes the difference. In
C++,
intblock sizes are up to 34% slower than compile-time onesacross block sizes, hence the compiled set.
interpolation_matrix(P1 → P2) matchesmainfor value shapes(2,) and (3,) (±2%), and is about 5% slower for scalars
(0.0339 → 0.0356 s). Block sizes 4 and 5 now work.
Tests
with and without boundary conditions.
W.sub(0)arguments, wherebs() != index_map_bs(),assembled into the parent matrix.
interpolation_matrixwith 2, 4 and 5components.
MatrixCSR.add/set: block-size-4 data into matrices of blocksize 1, 2 and 4.
AI assistance: I used Claude Code (Claude Opus 5.5) to draft parts of this
PR. I reviewed, edited, tested, and take responsibility for the final
contribution.
🤖 Generated with Claude Code