Skip to content

Conversation

@kennyweiss
Copy link
Member

Summary

  • This branch contains a slew of optimizations and performance improvements to the 3D winding number query
  • I'm seeing a roughly 3-5x speedup across a bunch of datasets
  • Details coming soon
  • Note: This PR builds off the feature/kweiss/wn-example-3D branch

@kennyweiss kennyweiss self-assigned this Jan 17, 2026
@kennyweiss kennyweiss changed the title Feature/kweiss/optimize wn 3d Performance improvements to 3D winding number query Jan 17, 2026
query_mesh --min -0.5 -0.5 --max 0.5 0.5 --res 3 3 --slice-z 0.0 --order 1)
set_tests_properties(quest_winding_number_3d_tet_slice PROPERTIES
PASS_REGULAR_EXPRESSION "4 patches .* 12 trimming curves")
# 3D query regression-style runs (20^3 grid) over several STEP models.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a bunch of tests to track performance and correctness as I worked through these optimizations.
We should not merge this into develop as is since it'll be too slow for debug configs.

Before merging, I'll update the tests to run at a reasonable resolution for normal testing.

return m_curveQuadratureMaps[curveIndex][hash_key];
// Cache quadrature data per trimming curve keyed by (refinementLevel, refinementIndex).
// Note: `quadNPts` is fixed in the 3D winding-number implementation (currently 15).
const auto make_key = [](int level, int index) -> std::uint64_t {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These map enhancements are related to things I did in my branch. I combined the curveIndex, refinementLevel and refinementIndex into a single std::uint64_t and ditched the axom::Array too. It was worth it in my timings, and it sped up creating the caches on multiple threads.


struct DerivativeBasisWorkspace
{
axom::Array<T> ders;
Copy link
Member

@BradWhitlock BradWhitlock Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are up to 5 array allocations here. Based on how these are used, it looks like they could be replaced with views that point into a single axom::Array that contains the storage for all of the arrays. On thinking about this some more, it looks like they probably do not resize that often.

Base automatically changed from feature/kweiss/wn-example-3D to develop January 18, 2026 03:02
Optionally computes and prints the L2 and Linf norms of the fields
and the number of nonzero containment entries and inout volume.
Uses a FlatMap instead of a std::map, and try_emplace to avoid extra lookups.
…pan() to avoid excessive mallocs

The associated memory will be retained between runs.
Note: This will not work for device
Increases resolution on faster tests and updates baselines.
Adds a test for the boxed_sphere.
Uses std::unordered_map instead of std::map.
Moves swithc for cases out of for loop.
Avoids extra allocations and divisions.
@kennyweiss kennyweiss force-pushed the feature/kweiss/optimize-wn-3d branch from 2f4463b to 8501b4a Compare January 18, 2026 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants