Sum factorisation on simplices - #5263
Conversation
pbrubeck
left a comment
There was a problem hiding this comment.
TSFC codegen diff should be as tight as possible. Add the new code in a separate finat submodule.
rckirby
left a comment
There was a problem hiding this comment.
This just checks that the code gives a correct answer. Do we have a way of checking whether the algorithm has the right complexity?
This PR adds both correctness and complexity tests. Complexity in flops is not enough, I also had to enforce tests on temporaries |
I see those tests, was thinking about FIAT. We should also test out Bernstein in the one-element benchmarks -- it doesn't have the indirection internally that modified C^0 expansions have but can be directly (after Duffy) sum-factored. |
7cfae19 to
6e30e23
Compare
eeb157d to
72c2ee7
Compare
Stack\n\n- Base: #5335\n- Paired FIAT simplex PR: firedrakeproject/fiat#262\n- Paired FIAT generic base: firedrakeproject/fiat#276\n\n## Summary\n\n- exercise simplex and Bernstein sum factorisation through TSFC spectral lowering\n- check compact parameterized loop domains instead of rectangular masked loops\n- benchmark Bernstein Laplacian code generation with copyable Markdown output\n- retain Johnson--Mercier FLOP, temporary, storage, and AST metrics for the generic stack\n\n## Bernstein code-generation snapshot\n\nReproduce with:\n\n python benchmarks/bernstein_laplacian.py --cell tetrahedron --degrees 10\n python benchmarks/bernstein_laplacian.py --cell triangle --degrees 10\n\n| cell | degree | scheme | compile (s) | FLOPs | scalar temps | array temps | stored values | largest | AST lines |\n| :--- | ---: | :--- | ---: | ---: | ---: | ---: | ---: | ---: | ---: |\n| tetrahedron | 10 | collapsed | 0.404 | 585,587,154 | 33 | 27 | 153,524 | 28,600 | 168 |\n| tetrahedron | 10 | canonical | 0.366 | 576,863,054 | 29 | 7 | 859,887 | 286,000 | 106 |\n| triangle | 10 | collapsed | 0.101 | 2,323,413 | 16 | 14 | 4,348 | 1,210 | 91 |\n| triangle | 10 | canonical | 0.102 | 2,217,713 | 14 | 5 | 13,446 | 6,600 | 69 |\n\nThe collapsed kernels materially reduce temporary storage. Their remaining degree-10 FLOP overhead is explicit: about 1.5% in 3D and 4.8% in 2D.\n\n## Johnson--Mercier snapshot\n\n| dim | compile (s) | FLOPs | scalar temps | array temps | stored elements | largest | AST lines |\n| ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |\n| 2 | 0.507 | 39,619 | 41 | 29 | 1,509 | 135 | 196 |\n| 3 | 3.216 | 1,016,342 | 130 | 69 | 17,992 | 672 | 530 |\n\nReproduce with benchmarks/johnson_mercier.py --dims 2 3.\n\n## Validation\n\n- make srclint\n- TSFC sum-factorisation and refactorisation tests\n- paired FIAT documentation, source lint, and 68 selected regression tests\n\n## AI assistance\n\nOpenAI Codex was used for implementation, refactoring, testing, benchmarking, and drafting this PR. The human contributor remains responsible for understanding, validating, and maintaining the changes.