In-warp substructure search for MCS - #243
Conversation
There is exactly one topology representation. The QueryTopology / TargetTopology template parameters and the kHasAdjacencyBondIndices trait made it look like there were two, but the only type that ever set the trait false was a test double -- production code has always passed a CSR view with all four arrays populated. The trait dates from when the CSR-adjacency scan was added on top of the original linear bond-endpoint scan and the old path was kept alive behind `if constexpr`. Both paths now land together, so the fallback was dead on arrival: each `else` branch held a verbatim copy of the adjacency loop under a runtime null-check plus a linear scan nothing reaches. Hoist DeviceCsrView into a new fmcs_topology.cuh (along with the bond endpoint pack/unpack constants, which fmcs_grow.cuh had been duplicating), take it concretely in matchSingleBondWithinThread, matchIncrementalFastCooperative, and fillNewBondsCooperative, and delete the trait with both fallback branches. fmcs_match.cuh drops from 453 to 321 lines with no behaviour change. The match tests relied on the fallback -- they never populated CSR at all -- so they now build real CSR arrays via a TestGraph helper and exercise the path that actually ships.
Extends the cut in the parent commits to the exact substructure layer, which carried five more `if constexpr` sites on the same kHasAdjacencyBondIndices trait: findTargetBondBetweenAtomsWithinThread, the target-degree seeding, the mapped-neighbour count, the mapped-query- neighbour lookup, and the partial-mapping bond check. Every else branch was the same dead shape as before -- a copy of the CSR walk behind a runtime null-check, then a linear scan over all bonds that no production caller could reach. Only the test double set the trait false. Also renames the fast-path call to tryMatchIncrementalGreedyCooperative. The substructure fallback is exactly the caller the greedy contract describes: it runs the exact search when the greedy attempt returns false, rather than treating false as a rejection. test_fmcs_substructure.cu now builds real CSR via the same TestGraph helper as the match tests. fmcs_match.cuh drops another 431 lines.
|
| Filename | Overview |
|---|---|
| src/mcs/fmcs_cuda/fmcs_match.cuh | Adds the cooperative substructure search and fallback wrapper, but the wrapper is not connected to the production grow path. |
| tests/test_fmcs_substructure.cu | Adds focused CUDA tests for the new helper behavior, including the greedy-failure recovery scenario. |
| tests/CMakeLists.txt | Correctly builds and registers the new substructure test executable. |
Reviews (1): Last reviewed commit: "Formatting" | Re-trigger Greptile
| __device__ __forceinline__ bool matchSeedWithSubstructureFallbackCooperative( | ||
| const GroupT& group, | ||
| const Seed<maxAtoms, maxBonds>& seed, | ||
| const DeviceCsrView& queryTopology, | ||
| const DeviceCsrView& targetTopology, | ||
| const PairMatchTablesDevice& tables, | ||
| MatchResult<maxAtoms, maxBonds, maxTA, maxTB>& match, | ||
| FmcsSubstructureScratch<maxAtoms, maxTA>& scratch, | ||
| int* scratchLock, | ||
| std::uint8_t* partialStorage, | ||
| int partialCapacity, | ||
| bool* overflowedFlag) { | ||
| if (tryMatchIncrementalGreedyCooperative(group, seed, queryTopology, targetTopology, tables, match)) { |
There was a problem hiding this comment.
Fallback remains outside production path
When the incremental greedy matcher selects a locally valid mapping that prevents completion, production FMCS growth never invokes the new exhaustive fallback, causing valid substructures to remain incorrectly rejected even though the dedicated test path recovers them.
No description provided.