Reduce Sauter-Schwab assembly allocations#207
Open
djukic14 wants to merge 1 commit into
Open
Conversation
Introduce reusable quadrature buffers for Sauter-Schwab reorder work arrays and thread them through moment-integral assembly. Replace the quadrule -> momintegrals! hot path with a callback-based dispatch path so quadrature selection can directly apply the moment integral without returning unstable rule unions through the caller. Update Sauter-Schwab quadrature call sites to use reorder! and explicit qbuffer arguments, and make wrapper quadrature strategies delegate to the callback implementation to avoid duplicated rule-selection logic. Require SauterSchwabQuadrature v2.5.0 for the new in-place reorder API.
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.
This PR reduces allocations in BEAST’s Sauter-Schwab assembly code.
The main idea is to reuse small temporary arrays instead of allocating them again and again during assembly. It also changes the quadrature dispatch so that
quadrulecan directly callmomintegrals!, instead of first returning a quadrature rule that is passed on later.This PR depends on the accompanying SauterSchwabQuadrature.jl PR krcools/SauterSchwabQuadrature.jl#10, which adds the in-place
reorder!function.Changes
quadraturebuffer(quadstrat)for reusable temporary arrays.I,J,K, andLarrays needed byreorder!.QuadruleCallback,ApplyMomintegrals, andApplyLocalMomintegrals.quadruledirectly applymomintegrals!in the assembly hot path.qbufferexplicitly throughmomintegrals!.SauterSchwabQuadrature.reorder!instead of allocating inreorder.qbufferargument.2.11.0.SauterSchwabQuadrature = "2.5.0".Motivation
Profiling showed many small allocations during singular and near-singular assembly. A large part of these came from Sauter-Schwab reordering and from passing many different quadrature rule types through the assembly code.
Reusing buffers and calling
momintegrals!directly fromquadrulereduces these allocations in the assembly.