Skip to content

Fix CUDA architecture selection and optimize LBVH Morton codes - #252

Merged
zfergus merged 2 commits into
mainfrom
fix/standalone-cpu-and-build-fixes
Sep 8, 2026
Merged

Fix CUDA architecture selection and optimize LBVH Morton codes#252
zfergus merged 2 commits into
mainfrom
fix/standalone-cpu-and-build-fixes

Conversation

@zfergus

@zfergus zfergus commented Sep 8, 2026

Copy link
Copy Markdown
Member

Description

Two independent small fixes, split out of the CUDA branch so they can land on their own.

  • tests/CMakeLists.txt — the test target hard-coded CUDA_ARCHITECTURES "native", which makes CMake probe for a physical GPU. Configuring therefore fails outright in GPU-less environments (CI runners, Docker image builds), even when the caller already passed -DCMAKE_CUDA_ARCHITECTURES. We now use whatever the user supplied and fall back to "native" only when they supplied nothing.
  • src/ipc/broad_phase/lbvh.cppLBVH::init_bvh divided by mesh_width inside the tbb::parallel_for over boxes. Hoisting 1 / mesh_width out of the loop turns three divides per box into three multiplies.

Behavior

  • The CMake change is inert for anyone who already passes CMAKE_CUDA_ARCHITECTURES, and unchanged for anyone building on the machine they target.
  • The Morton hoist can differ in the last bit, since a * (1/b) does not always round to a / b. At worst that shifts the Morton sort order for a near-tie, changing the tree shape. The candidate set the query returns is unaffected — the traversal is exhaustive over overlapping nodes, not order-dependent.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which improves existing functionality)

How Has This Been Tested?

  • [broad_phase] ~[!benchmark] — 13 test cases, 1,464,038 assertions, all passing. Covers LBVH::detect_*_candidates and Compare BP against brute force, which checks the LBVH candidate set against brute force.
  • Full ipc_toolkit, ipc_toolkit_tests, and ipctk builds.

The CMake change is not covered: this was a IPC_TOOLKIT_WITH_CUDA=OFF build, so the edited branch never executed. It needs a CUDA configure to exercise.

Test Configuration:

  • OS and Version: macOS 26.6 (arm64)
  • Compiler and Version: AppleClang 21.0, CMAKE_BUILD_TYPE=Release, IPC_TOOLKIT_BUILD_TESTS=ON, IPC_TOOLKIT_WITH_CUDA=OFF

Checklist

  • I have followed the project style guide
  • My code follows the clang-format style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Computing 1/mesh_width once turns three divides per box into three
multiplies. Rounding can differ in the last bit, which at worst shifts the
Morton sort order for a near-tie; the candidate set the query returns is
unaffected.
Hard-coding "native" makes CMake probe for a physical GPU, so configuring
the test target fails in GPU-less CI and Docker builds. We now use whatever
the user passed and only fall back to "native" when they passed nothing.
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.70%. Comparing base (b778f64) to head (edfe799).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #252   +/-   ##
=======================================
  Coverage   96.70%   96.70%           
=======================================
  Files         191      191           
  Lines       17292    17293    +1     
  Branches      928      927    -1     
=======================================
+ Hits        16722    16723    +1     
  Misses        570      570           
Flag Coverage Δ
unittests 96.70% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zfergus
zfergus merged commit ff5f152 into main Sep 8, 2026
21 checks passed
@zfergus
zfergus deleted the fix/standalone-cpu-and-build-fixes branch September 8, 2026 02:31
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.

1 participant