Rigid body: no JFJOCH_RIGID_BODY_CPU; GPU/CPU parity tests tightened

The GPU rigid body is chosen by whether a card is there, nothing else. A run
that must stay on the CPU says so at the process level (CUDA_VISIBLE_DEVICES=),
which RigidBodyGPUPool::Create already honours through get_gpu_count().

Parity tests ([ModelValidation][gpu], compiled into jfjoch_test on a CUDA
build):
- every GPU case now SKIPs without a card, instead of passing silently;
- ModelMaskGPU_MatchesGemmi also checks that the CPU path's PutMaskOnGrid is
  gemmi's mask bit for bit on the same grid, so the GPU mask is held against
  the CPU path itself;
- RigidBodyGPU_MatchesCPU: Jacobian columns 2e-3 -> 5e-4 relative (measured
  up to 5e-5; the floor is the 1e-4 the scale's near-tie can move every
  column by). Residuals stay at 2e-4 of <Fobs> (measured up to 3.9e-5);
- RigidBodyGPU_FitAgreesWithCPU: fit endpoint 2e-3 -> 1e-5 A rmsd (measured
  up to 5e-7 A).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D1G8gJVAy6gp1K5Dz3NE5C
This commit is contained in:
leonarski_fandClaude Opus 5.5 committed 2026-09-28 22:46:00 +02:00
1 parent b1f79ed27f
commit 23812b902c
4 files changed
+35 -33

No files matched your search

+12 -7
View File
@@ -16,6 +16,7 @@
#include <gemmi/solmask.hpp>
#include <gemmi/symmetry.hpp>
#include "../rugnux/ModelGrid.h"
#include "../rugnux/ModelMaskGPU.h"
namespace {
@@ -127,13 +128,13 @@ double DistanceToMaskEdge(const gemmi::Grid<float> &grid, const std::vector<Mode
} // namespace
// The whole mask against gemmi's put_mask_on_grid(), the island step alone against gemmi's on gemmi's
// own pre-island mask (exact), and three repeats bit for bit. The masking itself may differ from gemmi
// only at points that sit at an atom's radius, where the float distance rounds the other way.
// The whole mask against gemmi's put_mask_on_grid() - and so against the CPU path's PutMaskOnGrid() -
// the island step alone against gemmi's on gemmi's own pre-island mask (exact), and three repeats bit
// for bit. The masking itself may differ from gemmi only at points that sit at an atom's radius, where
// the float distance rounds the other way.
TEST_CASE("ModelMaskGPU_MatchesGemmi", "[ModelValidation][gpu]") {
if (get_gpu_count() == 0) {
if (get_gpu_count() == 0)
SKIP("No GPU");
}
CudaStream stream;
bool any_islands = false, any_odd_size = false;
for (const char *cryst : kCrysts) {
@@ -155,6 +156,11 @@ TEST_CASE("ModelMaskGPU_MatchesGemmi", "[ModelValidation][gpu]") {
const int islands = masker.remove_islands(ref);
masker.shrink(ref);
const size_t n = ref.data.size();
// The rigid body's CPU path masks with PutMaskOnGrid, which is gemmi's put_mask_on_grid bit
// for bit - checked here on this grid, so what the GPU is held to below is the CPU path too.
gemmi::Grid<float> cpu = MaskGrid(st, d_min);
PutMaskOnGrid(cpu, st.models[0], OrbitLeaders(cpu, 4), 4);
REQUIRE(std::memcmp(cpu.data.data(), ref.data.data(), n * sizeof(float)) == 0);
any_islands |= islands > 0;
any_odd_size |= ref.nu % 8 != 0 || ref.nv % 8 != 0 || ref.nw % 8 != 0;
@@ -198,9 +204,8 @@ TEST_CASE("ModelMaskGPU_MatchesGemmi", "[ModelValidation][gpu]") {
// The shrink is not implemented: a grid fine enough for it to change anything is refused.
TEST_CASE("ModelMaskGPU_RefusesAGridTheShrinkWouldChange", "[ModelValidation][gpu]") {
if (get_gpu_count() == 0) {
if (get_gpu_count() == 0)
SKIP("No GPU");
}
CudaStream stream;
const gemmi::Structure st = ClusterModel(kCrysts[0]);
const std::vector<ModelMaskOp> ops = MaskOps(*st.find_spacegroup());