From c4807950c120d95cea3c3d0c80ae3a1ce4fbc34f Mon Sep 17 00:00:00 2001 From: Zachary Ferguson Date: Mon, 7 Sep 2026 21:03:58 -0400 Subject: [PATCH 1/2] Hoist the reciprocal out of the LBVH Morton code loop 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. --- src/ipc/broad_phase/lbvh.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ipc/broad_phase/lbvh.cpp b/src/ipc/broad_phase/lbvh.cpp index f2107839d..97ba8a9c6 100644 --- a/src/ipc/broad_phase/lbvh.cpp +++ b/src/ipc/broad_phase/lbvh.cpp @@ -149,13 +149,14 @@ void LBVH::init_bvh( { IPC_TOOLKIT_PROFILE_BLOCK("compute_morton_codes"); - const Eigen::Array3d mesh_width = mesh_aabb.max - mesh_aabb.min; + const Eigen::Array3d mesh_width_inv = + 1.0 / (mesh_aabb.max - mesh_aabb.min); tbb::parallel_for(size_t(0), boxes.size(), [&](size_t i) { const auto& box = boxes[i]; const Eigen::Array3d center = 0.5 * (box.min + box.max); const Eigen::Array3d mapped_center = - (center - mesh_aabb.min) / mesh_width; + (center - mesh_aabb.min) * mesh_width_inv; if (dim == 2) { morton_codes[i].morton_code = From edfe7999b92332030ecf0486f602070c8f2315f2 Mon Sep 17 00:00:00 2001 From: Zachary Ferguson Date: Mon, 7 Sep 2026 21:04:08 -0400 Subject: [PATCH 2/2] Honor CMAKE_CUDA_ARCHITECTURES when building the tests 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. --- tests/CMakeLists.txt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 716cb3c87..7cfa3e9ef 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -76,9 +76,15 @@ if(IPC_TOOLKIT_WITH_CUDA) # other libraries and executables. set_target_properties(ipc_toolkit_tests PROPERTIES CUDA_SEPARABLE_COMPILATION ON) - # Use the same CUDA architectures Scalable CCD - # get_target_property(CMAKE_CUDA_ARCHITECTURES scalable_ccd CUDA_ARCHITECTURES) - set_target_properties(ipc_toolkit_tests PROPERTIES CUDA_ARCHITECTURES "native") + # Use the CUDA architectures specified by the user (e.g. via + # -DCMAKE_CUDA_ARCHITECTURES) and only fall back to auto-detecting the local + # GPU ("native") when none were given. "native" requires a physical GPU, so + # the fallback fails in GPU-less environments such as CI/Docker builds. + if(DEFINED CMAKE_CUDA_ARCHITECTURES) + set_target_properties(ipc_toolkit_tests PROPERTIES CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}") + else() + set_target_properties(ipc_toolkit_tests PROPERTIES CUDA_ARCHITECTURES "native") + endif() endif() if (IPC_TOOLKIT_TESTS_CCD_BENCHMARK)