Fix data race on shared molecule in batched MMFF minimizers - #237
Conversation
Batch threads built each molecule's MMFF force field inside the OpenMP loop, and RDKit's MMFFMolProperties constructor mutates the molecule it types. Conformers of one molecule can span several batches, so threads raced on the same ROMol, producing wrong atom types and heap corruption. The trigger is thread count, not GPU count. Build each molecule's MMFFMolProperties once under std::call_once and share it; contribs still build per batch through the non-mutating overload, so preprocessing stays interleaved with GPU work.
|
| Filename | Overview |
|---|---|
| src/minimizer/mmff_minimize.cpp | Shares MMFF properties across batch threads, but indexing the synchronization guard by molIdx leaves aliased ROMol entries able to initialize concurrently. |
| rdkit_extensions/mmff_flattened_builder.cpp | Extracts MMFF property construction and configuration into a shared-pointer-returning helper. |
| rdkit_extensions/mmff_flattened_builder.h | Declares the helper and documents the mutation and synchronization requirements. |
| tests/test_mmff.cu | Adds coverage for one molecule whose conformers span threads, but does not cover the supported duplicate-ROMol input shape. |
| tests/test_fmcs_primitives.cu | Qualifies three FMCS test includes with their source-tree paths. |
Reviews (1): Last reviewed commit: "Fix data race on shared molecule in batc..." | Re-trigger Greptile
evasnow1992
left a comment
There was a problem hiding this comment.
Thank you for fixing this!
Batch threads built each molecule's MMFF force field inside the OpenMP loop, and RDKit's MMFFMolProperties constructor mutates the molecule it types. Conformers of one molecule can span several batches, so threads raced on the same ROMol, producing wrong atom types and heap corruption. The trigger is thread count, not GPU count.
Build each molecule's MMFFMolProperties once under std::call_once and share it; contribs still build per batch through the non-mutating overload, so preprocessing stays interleaved with GPU work.
Fixes #236