Repository navigation
[FIX,BUILD] IdXMLFile: compile without an OpenMP runtime - #10457
Merged
Merged
Conversation
team_size was declared only under _OPENMP but is used in the num_threads clause of an unguarded '#pragma omp parallel'. With the -fopenmp-simd fallback (no OpenMP runtime found) clang still parses that clause and the build fails. Fixes OpenMS#10456 Co-authored-by: Copilot App <[email protected]>
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 17 minutes. View limit detailsLimit details: You’ve used all 4 included reviews currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Contributor
|
good catch |
7 of 11 tasks
timosachsenberg
pushed a commit
that referenced
this pull request
Oct 8, 2026
Ported from #10457 (commit 4b93cb5), which is open against develop: without an OpenMP runtime the compiler still parses the num_threads clause of the parallel pragma in IdXMLFile::store, so team_size must be declared unconditionally. No-op once develop carries it. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01UQCiwdbPoEkrebED8VQ2TJ
5 tasks done
timosachsenberg
added a commit
that referenced
this pull request
Oct 9, 2026
…ackages and review fixes (supersedes #10400 and #10403) (#10466) * [PERF] IdXMLFile: parallel, byte-identical idXML writer IdXMLFile::store formats the PeptideIdentifications in parallel and writes them in input order (omp ordered), so the file is byte-identical to the one the serial writer produces. - XMLHandler::writeUserParamValue_() writes one meta value as UserParam; writeUserParam_() and the parallel writer share it, so there is no second copy of the formatting code. - The PeptideIdentifications are assigned to their runs in one hash pass; each run is cut into blocks of 16, formatted by at most 16 threads (and at most one per block). PeptideIdentifications of no run are warned about from the same pass. - If a hit score is NaN, a copy of the hits is sorted with the call of PeptideIdentification::sort(), as before, so the order does not depend on the standard library; otherwise an index sort is used. - Exceptions of the parallel section (ElementNotFound for an unknown protein reference, ConversionError for an EMPTY meta value) are constructed one at a time inside a critical section and rethrown after it; the first error in input order is reported. Checked: byte-identical output for the 20 ProSE searches of the OpenMS#10364 benchmark at 1, 4, 8, 16 and 64 threads, an idXML load/store round trip of 323 files at 1/4/16/64 threads, and synthetic 300k-PSM files with 1 to 1000 runs. ProSE wall time (store included): 20 searches at 4 threads -11.8%, one search at 16 threads -26%; no regression at 1 thread, peak memory unchanged. New IdXMLFile_test sections cover input order, PeptideIdentifications of no run, NaN scores and exceptions from the parallel section. Co-Authored-By: Claude Opus 5.5 <[email protected]> * [FEATURE] ProSE: faster search and higher identification rates Speed, correctness, scoring and rescoring-feature changes to ProSE, measured on the frozen 20-file DDA corpus of OpenMS#10364 (issue protocol: Percolator 3.09, 3 seeds, target PSMs at q <= 0.01). Against develop f6c680f: +3.6% PSMs per file (3187.7 -> 3302.7), Velos UPS1 entrapment FDP 0.97% -> 0.91%, doubled-search-space FDP 1.13% -> 1.09%. Speed (output byte-identical: all 20 files at 4 threads, six at 1, 16 and 64 threads; together about 4.5x faster at 4 threads): - FragmentIndex::build bins fragments by m/z instead of a global sort, and counts the fragments first, then writes them straight into their bins. - Regex-free digestion in FragmentIndex::generatePeptides. - A multi-threaded peptide sort that reproduces std::sort exactly. - One bucket walk for all precursor isotope errors, with skip tables and prefetching. - postProcessHits_: PSM meta value keys resolved once and set by registry index; flat-storage Da alignment for the peak annotation. - search(file, fasta) reads the mzML while the fragment index is built; parallel FASTA reading and index release; no copy of the database. - Develop's ProSE changes (#10391, #10394, #10397, #10398, #10399) run inside the faster code: peptide:deduplicate is evaluated within the index build (same definition, no AASequence string per database peptide), and the local fragment evidence of #10399 reuses the annotation spectrum and merges the sorted alternative assignments. Output identical to develop. Correctness: - isotope_error is reported as observed minus theoretical (13C spacings), as in MS-GF+, pepXML and Sage and as PercolatorInfile expects; the search parameters record isotope_error_convention. The new report:isotope_error_convention=theoretical_minus_observed restores the previous sign. PercolatorAdapter warns about ProSE input without the record. - PercolatorInfile keeps ExpMass/mass at the observed precursor m/z for all PSMs of a spectrum and removes the isotope error from dm/absdm/deltamass only, so PSMs of one spectrum at different isotope errors no longer enter target-decoy competition as different spectra. - BREAKING: precursor:isotopes is removed (it was never used; the searched range is precursor:isotope_error_min/max). Inis that set it are rejected. FragmentIndex's default isotope range is [-2, 0]. - FragmentIndex rejects fixed terminal modifications it cannot restrict and does not add a variable whole-terminus modification on top of a fixed one; variable modification enumeration is bounded. - The MS2 preprocessing filters are per thread (data race); warnings for decoys without the targets' initial Met under clipping. Scoring: - scoring:method (auto, hyperscore, mass_accuracy): a HyperScore whose ion counts and intensity product weight each match by a Gaussian of its mass error (scoring:mass_error_sd, 7 ppm). 'auto' uses it for ppm tolerances, HyperScore otherwise. - FDR:PSM_groups (scored_charges, pooled): ProSE's own FDR:PSM competes PSMs scored with different numbers of fragment charges separately. Spectrum preprocessing: - MS2 deisotoping uses a Sage-like envelope rule: two isotope peaks make an envelope, charges up to the precursor charge (at most 3), the monoisotopic peak carries the summed intensity (fragment:deisotope_min_peaks / _charge_cap / _sum_intensity; 3 / none / false restores the earlier rule). Rescoring features: - annotate:self_trained_ion_priors (default on): a per-run fragment ion model (new class FragmentIonLikelihoodModel) learned from the run's own confident target PSMs against their reversed sequences, cross-fitted by scan parity, so no PSM is scored by a model that saw its spectrum or its label. Adds the Percolator features ion_prior_llr and ion_prior_explained; native scores and candidates are unchanged. Tests: new and extended class tests (FragmentIndex, HyperScore, ProSEAlgorithm, PercolatorInfile, FragmentIonLikelihoodModel). The TOPP references ProSE_{1,2,4,10}_out.idXML are regenerated: with the earlier deisotoping rule, HyperScore and the ion priors off, the new outputs differ from develop's references only by the four recorded search parameters. ProSE_{1,2,4,6_fdr}.ini no longer set precursor:isotopes. Credits: the mass-accuracy HyperScore ports the opt-in scorer of Timo Sachsenberg's #10379 (825c33b); the self-trained ion model builds on the design of his self-trained per-run fragment ion priors (#10378, same parameter name, different model); the speed patches started from his ProSE branch, and develop's ProSE commits above are his. Not included: the prototype dense-spectrum peak quota of Timo's benchmark branch (20b6e75), which is not part of develop and which its author did not propose for merging. Co-Authored-By: Claude Opus 5.5 <[email protected]> * [FEATURE] ProSE: round-3 speed packages from #10403 (input pipeline, protein mapping from the index, index build) Applies the delta 9bfa53b..b95fdb0 of #10403 (feature/prose-best) onto the develop-based branch of #10400: - mzML files are cut into chunks parsed in parallel, the reader gets the caller's thread budget (at most 16) and decodes in batches of 1000; in the multi-file search the spectra are read in the background, the decoys are detected once, the fragment index is released after the last file and moved instead of copied. - peptide:protein_mapping (default index): hits are mapped to their proteins from the occurrences the fragment index holds; PeptideIndexing is the fallback. Annotation results go to per-spectrum slots; PeptideIndexing sorts its matches once. - Index build: fragments are tested against the bounds that select the buckets; single-use searches index only the peptides the searched spectra can reach; huge pages for the fragment array, a parallel merge of the per-thread peptide vectors, and an index-based top-N filter for low-resolution spectra. - Regenerated ProSE_{1,2,4,10}_out.idXML of #10403. Conflicts came from the prototype dense-spectrum quota and the candidate-competition features, which #10400 removed and #10403 keeps switched off: the quota parameters, the dense arguments of filterLocalPeaks_/preprocessSpectra_, AnnotatedHit_::prefilter_matches and the prefilter-totals test are left out; filterTopNInJumpingWindows replaces the WindowMower as in #10403. The CHANGELOG entries of the PR that duplicate #10427 and #10428 are dropped. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01UQCiwdbPoEkrebED8VQ2TJ * [FIX] Thread-safe exception state and serialised Xerces initialisation for parallel XML parsing Review findings on #10403 (parallel chunked mzML reader): - GlobalExceptionHandler recorded the last exception in shared static strings that every exception constructor writes. Exceptions constructed on several threads at once (e.g. chunks of a parallel mzML read that fail to parse) raced on them; ThreadSanitizer reported 15 data races in set() for a 4-thread reproducer, none after the change. The fields are thread-local now and terminate() reports the entry of the thread it runs on. getInstance() uses a function-local static instead of a check-then-new on a pointer. - Xerces requires callers to serialise XMLPlatformUtils::Initialize() and Terminate() (its counter is a plain integer). Internal::xercesInitialize() and xercesTerminate() in CONCEPT/Init take a process-wide lock; XMLFile, ImzMLFile and MzIdentMLDOMHandler call them. Parsing stays parallel. - GlobalExceptionHandler_test is built again (it used the private constructor) and runs the concurrent-throw pattern. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01UQCiwdbPoEkrebED8VQ2TJ * [FIX] FragmentIndex: terminal slots for residue-specific terminal modifications, no variable modification on a fixed one, zero-sum SNES subsets; ProSE: validate the mass-accuracy tolerance, rethrow worker exceptions Review findings on #10403 (items 1-4 of the Debug-build review): - buildModSlots_() stored a residue-specific terminal modification such as Gln->pyro-Glu (N-term Q) in a residue slot, so reconstructModifiedSequence() called setModification() on it and ResidueDB's precondition (term specificity ANYWHERE) aborted the parallel search. Such a modification is an NTERM_SLOT/CTERM_SLOT now and is set as the terminal modification; the mass shifts the same fragments either way. It is not applied where a fixed terminal modification sits. - A variable modification is no longer applied to a residue that carries a fixed one (as in ModifiedPeptideGenerator): with Carbamidomethyl (C) fixed and variable, the index held both masses (+57.02 Da) while the reconstructed sequence kept one, and the peptidoform was indexed twice. - SNES: a Σ = 0 hit passed through as the unmodified realization only, so a nonempty subset whose shifts cancel (Deamidated (N) with Amidated (C-term)) was never produced. Such hits are expanded into the zero-sum subsets too when the configured shifts allow one (nonemptyZeroSigmaSubsetExists_()). - ProSE: scoring:method=mass_accuracy with a fragment tolerance that is not finite and positive is rejected in updateMembers_(); 'auto' resolves to HyperScore then. HyperScore::computeMassAccuracy() threw this inside the parallel scoring loop and terminated the process. - ProSE: the parallel scoring and calibration loops capture the first exception of a worker thread and rethrow it after the loop. Tests: FragmentIndex_test checks the indexed mass of every entry against its reconstructed sequence over configurations with fixed/variable overlap and residue-specific terminal modifications, finds .(Gln->pyro-Glu)QPEPTIDER, and finds AN(Deamidated)PEPTIDER.(Amidated) in SNES and conventional mode; ProSEAlgorithm_test checks the tolerance validation. All failed on the previous code (the pyro-Glu case with the ResidueDB precondition in Debug). Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01UQCiwdbPoEkrebED8VQ2TJ * [FIX] ProSE: no 'omp atomic write' in the chunked mzML reader (MSVC's OpenMP 2.0 rejects it) build-wheels-windows on #10466 failed with C7660 at the two '#pragma omp atomic write' sites of loadMzMLChunked(), a construct MSVC accepts only with -openmp:llvm. A named critical section sets the flag instead, as the parallel FASTA reader next to it does. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01UQCiwdbPoEkrebED8VQ2TJ * [FIX,BUILD] IdXMLFile: compile without an OpenMP runtime Ported from #10457 (commit 4b93cb5), which is open against develop: without an OpenMP runtime the compiler still parses the num_threads clause of the parallel pragma in IdXMLFile::store, so team_size must be declared unconditionally. No-op once develop carries it. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01UQCiwdbPoEkrebED8VQ2TJ * [TEST] FragmentIndex: check the removed occurrences recorded by peptide:deduplicate (from #10403) The deduplication test of #10403's tagged version also compares getRemovedOccurrences() with the entries the deduplication removed; the port took the recording code from that version but the test section from #10400, which predates it. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01UQCiwdbPoEkrebED8VQ2TJ * [FIX] IdXMLFile: report stream failures of the parallel block writer IdXMLFile::store could return successfully after writing a truncated idXML: - Each block of the parallel writer is formatted into a std::ostringstream without an exception mask. A std::bad_alloc while the stringbuf grows only sets badbit; str() then returns the partial text, and the block was written as if complete. - The state of the file stream was never checked, neither after the ordered block writes nor after close(), so disk-full and I/O errors went unnoticed (develop's serial writer had the same gap). Changes: - New protected static IdXMLFile::formatBlock_() formats a block with badbit | failbit exceptions on the block stream; libstdc++ then rethrows the original std::bad_alloc, which the existing per-block exception_ptr carries to the caller. The text written on success is unchanged. - The ordered section checks the file stream after each block write and stops the remaining blocks on failure; the exception is constructed after the parallel region. - After close(), a failed stream throws Exception::UnableToCreateFile. - store() never removes its output, and every failure is raised. An OpenMS exception keeps its type and gets a note that names the file and says that a partial file may remain (without the note if there is no memory for it); any other exception (e.g. std::bad_alloc) is raised unchanged, since wrapping it would need memory. Tests (IdXMLFile_test): formatBlock_ with throwing and failing stream buffers; store() into an idXML symlinked to /dev/full at 1 and 4 threads; a throwing block and protein section for a new and an existing file (also with a second hard link); a fault-injection sweep over every allocation of store() on the calling thread; a change of the working directory, a file renamed into place, an unsearchable parent directory and a read-only file; a throwing close(). The fault-injection sections replace the global operator new and run on Linux only (skipped with a message elsewhere or with OPENMS_TEST_NO_FAULT_INJECTION). Co-Authored-By: Claude Opus 5.5 <[email protected]> * [TEST] FragmentIndex: fragments on tolerance-window and bucket bounds aed31fa makes the index build test the fragments against the same float bounds of a peak's tolerance window that select the fragment buckets; the two tests rounded differently, so whether a fragment on or next to a bound was counted depended on the bucket layout. That fix came without a test. Two class test sections, written with their expectations before they were first run: - query() on hand-placed fragments: the two peaks named in the fix (511.830292 and 1024.05737 Th, 0.5 Da) with fragments on, and one ulp inside and outside of, both window bounds. The float bounds and the expected peptide indices were derived by hand (bit patterns in the test). The section checks every bucket layout of these 12 fragments (bucket sizes 1 to 12), so fragments also sit on bucket boundaries. Without the fix, the fragment at hi = 512.330322 (512.330322 - 0.5 = 511.830322 > 511.830292) was missed, and 1023.55731, one ulp below lo = 1023.55737, was accepted whenever its bucket was visited. - query() and querySpectrum() on a built index with 4096-fragment buckets: for peaks whose window starts or ends exactly on the smallest m/z of a bucket, and peaks up to 3 ulps off them, the matched fragments and the per-candidate counts must equal a brute-force count over all fragments of lo <= m/z <= hi. The SNES byte scan and candidate collection changed by the same fix are not covered by a boundary-specific test here. Co-Authored-By: Claude Opus 5.5 <[email protected]> * [TEST] ProSEAlgorithm: ion-prior gate crossing; correct the cross-fit doc The documentation of the self-trained ion priors claimed that "neither a PSM's own spectrum nor its label, nor any label of its fold, enters its features" (ProSEAlgorithm.h, annotateIonPriors_, and the ProSE TOPP page). That is not strictly true: training is enabled by a run-level gate that requires annotate:ion_prior_min_psms training PSMs in BOTH halves, and the training counts depend on the labels. At the boundary a single label flip, in either half, switches both halves between their cross-fitted features and all zeros, so a label of a half does reach that half's own features through the gate. The gate is label-symmetric (targets and decoys alike), so no code change is needed; only the wording overclaimed, and the existing label-flip test never crossed the gate. Changes (documentation and test only; no output changes): - ProSEAlgorithm.h: the model that scores a PSM never saw its spectrum or label, nor any other label of its fold; the run-level gate is the one place where a fold's labels reach its own features, one label decides at the boundary, and the gate is label-symmetric but not formally independent of the labels. - ProSE.cpp (TOPP doc page only): the same correction. - ProSEAlgorithm_test: in "[EXTRA] self-trained ion priors are cross-fitted", a new block sets annotate:ion_prior_min_psms to the training count of the smaller half (trained; features equal those of the lower minimum), then flips the label of that half's best target. It asserts ion_prior:trained == "false", the half's training count below the minimum, the all-zero fallback on every hit (complete feature columns, all 0), and that features changed in both halves. Co-Authored-By: Claude Opus 5.5 <[email protected]> * [FIX] FragmentIndex: a residue-specific terminal variable modification applies next to a fixed modification of the residue buildModSlots_() skipped every variable modification of a residue that carries a fixed one, also the residue-specific terminal ones, which sit on the terminus and not on the residue. With Carbamidomethyl (C) fixed and Ammonia-loss (N-term C) variable (N-terminal pyro-carbamidomethyl cysteine) .(Ammonia-loss)C(Carbamidomethyl)PEPTIDEK was therefore never indexed, conventionally or with SNES, while ModifiedPeptideGenerator generates it. The fixed modification of a residue now excludes only the variable residue modifications (ANYWHERE) of that residue. As in ModifiedPeptideGenerator, Pyro-carbamidomethyl (N-term C), which Unimod defines on unmodified cysteine, is now also applied next to a fixed Carbamidomethyl (C); Ammonia-loss (N-term C) is the modification for that configuration. Test: FragmentIndex_test compares the index for CPEPTIDEK and CCTESLVNR with ModifiedPeptideGenerator and searches the spectrum of .(Ammonia-loss)C(Carbamidomethyl)PEPTIDEK with and without SNES. On e910aea the two N-terminal forms were missing from the index and the spectrum got no hit in either mode. Review of #10466 (finding F1). Co-Authored-By: Claude Opus 5.5 <[email protected]> * [FIX] ProSE: fragment:mass_tolerance must be finite and positive for every scoring method updateMembers_() rejected a fragment tolerance that is zero, negative, NaN or infinite only for scoring:method=mass_accuracy and with local fragment evidence. With 'auto' or 'hyperscore' and local fragment evidence off it was accepted, and 'auto' fell back to HyperScore. HyperScore and the fragment index match within the same tolerance, so such a search ended with exit code 0 and no hits (0, -5, NaN ppm; 0 Da) or with inflated scores (inf) on the TOPP_ProSE_1 inputs. The tolerance is now checked once, for every method, where it is read. Test: the ProSEAlgorithm_test section of 74f8ed9 asserted the 'auto' fallback; it now expects InvalidParameter for {mass_accuracy, auto, hyperscore} x {ppm, Da} x {0, -1, inf, NaN} x local fragment evidence {off, on}. On e910aea, 16 of these 48 cells were accepted. Review of #10466 (finding F6). Co-Authored-By: Claude Opus 5.5 <[email protected]> * [FIX] FragmentIndex: SNES expands a hit into the modification subsets within variable_max_per_peptide only querySpectrumSNES_() expanded every Sigma hit by visiting all 2^n_slots bitmasks of the realized peptide and skipping those with more than modifications:variable_max_per_peptide slots afterwards. Since 74f8ed9 every Sigma = 0 hit is expanded too as soon as the variable modifications contain a cancelling pair (e.g. Deamidated (N) with Amidated (C-term)), so the unmodified candidates of long peptides with many modification sites paid for it as well. The loop now steps with nextSubsetWithin(), which the conventional enumeration already uses: the same subsets in the same (increasing) order, so the output does not change. Test: FragmentIndex_test queries a peptide with 31 slots (29 x Oxidation (M), Deamidated (N), Amidated (C-term); at most 2 per peptide) in SNES mode and finds the unmodified and the zero-sum form. The query took 9.49 s on e910aea (Release build) and takes 0.16 ms now; the test requires < 5 s. Review of #10466 (finding F5). Co-Authored-By: Claude Opus 5.5 <[email protected]> * [FIX] FragmentIndex, ProSE: report every variable modification that a fixed one excludes 74f8ed9 stopped applying a variable modification where a fixed one sits on the same residue (Carbamidomethyl (C) fixed and variable, Glutathione (C) with Carbamidomethyl (C) fixed) and a residue-specific terminal variable modification where a fixed one sits on the terminus (Gln->pyro-Glu (N-term Q) with TMT6plex (N-term) fixed). Neither was reported: shadowedVariableTerminalModifications() still returned only the terminal modifications without a residue preference, and its documentation said that the residue-specific ones are searched as before. - shadowedVariableTerminalModifications() also returns the residue-specific terminal modifications that a fixed terminal one excludes. - New shadowedVariableResidueModifications(): the variable residue modifications that a fixed modification of the same residue excludes. - ProSEAlgorithm::updateMembers_() warns about both. For a modification that is fixed as well, the advice is to remove it from modifications:fixed; "specify it as a variable one as well" was circular there. - The description of modifications:variable (ProSE, FragmentIndex) names both rules. Tests: FragmentIndex_test (helper expectations with Gln->pyro-Glu, the index agrees with both helpers) and ProSEAlgorithm_test (the warnings). On e910aea the helper expectations and 5 warning checks failed. Review of #10466 (finding F9). Co-Authored-By: Claude Opus 5.5 <[email protected]> * [FIX] ProSE: restore the calibrated tolerances and end the progress display when a search throws search() and searchChunked_() narrow the precursor tolerances of the instance (and the parameters of the search context's FragmentIndex) after the calibration pass, and restored them only on their return paths. Since 74f8ed9 a worker exception of the scoring or calibration loop reaches the caller; after it (or any other exception after the calibration pass) the instance kept the calibrated window, e.g. [-14, +1e-06] ppm instead of the configured [-20, +30] in the test below, for the next search of a caller that catches it. The progress display started for the loop was not ended either (ProgressLogger's recursion depth is process-wide). The restore now also runs when an exception leaves these functions (a small scope-exit helper; the return paths are unchanged), the scoring loop ends its progress display before rethrowing, and search() ends the calibration progress display when the calibration loop rethrows. Test: ProSEAlgorithm_test throws from the progress display when the scoring of the main search starts (one search context, and database chunks), then checks the tolerances and that the instance searches as a fresh one; and counts the started and ended progress displays after a worker exception of the scoring and of the calibration loop. On e910aea the tolerances stayed calibrated in both paths and one progress display was not ended. Review of #10466 (finding F7). Co-Authored-By: Claude Opus 5.5 <[email protected]> * [FIX] ProSE: no exception leaves preprocessSpectra_(), the calibration hit list or the chunked mzML reader An exception that leaves an OpenMP structured block calls std::terminate(). 74f8ed9 catches the worker exceptions of the scoring and calibration loops; three places next to them still let one escape: - preprocessSpectra_() had no exception handling, and its filters were copied per thread on entry to the region (firstprivate). The copies are now made before the loop, and the loop captures the first exception and rethrows it after the region, like the scoring loop. - The calibration loop pushed its hits inside an omp critical section; a reallocation there threw out of the critical section (GCC terminates even though the loop body catches outside it). The hit list now reserves one entry per spectrum of the subset, so the push never reallocates. - loadMzMLChunked() caught exceptions of the chunk parser only. Opening the file and resizing the block and chunk buffers (up to about 9 MB per thread) now happen inside the try of each iteration, so a failure makes the caller read the file with MzMLFile::load(), as intended. Only allocation failures were found to reach these places with the earlier fixes of this PR. Other parallel regions of ProSE (protein mapping, post-processing) and of OpenMS (e.g. PeptideIndexing) still terminate on std::bad_alloc. Test: ProSEAlgorithm_test starts itself as a child process that fails every allocation of preprocessSpectra_() on the calling thread once, one after the other (a replacement of the global operator new; Linux only). On e910aea the child terminated at allocation 59; now all 163 failures reach the caller as std::bad_alloc. Review of #10466 (finding F4). Co-Authored-By: Claude Opus 5.5 <[email protected]> * [FIX] XMLValidator: initialise Xerces under the lock of Internal::xercesInitialize() 9ce130e serialises XMLPlatformUtils::Initialize() for the parsers, but XMLValidator::isValid() (reached via XMLFile::isValid(), MzMLFile::isValid() and others) still called it directly. Its unlocked increment of Xerces' initialisation counter races with a parse on another thread. The count cannot drop to zero in practice (the static xerces_init holds one reference), so this is a formal data race rather than a crash, but it keeps the serialisation incomplete. Evidence (no class test: Xerces is not instrumented for TSan): a probe that validates on one thread while ParamXMLFile::load() runs on another, under valgrind --tool=helgrind, reported data races on Xerces' gInitFlag in XMLPlatformUtils::Initialize() and none after this change. XMLValidator_test and XMLFile_test pass. Review of #10466 (finding F2). Co-Authored-By: Claude Opus 5.5 <[email protected]> * [FIX] GlobalExceptionHandler: terminate() reports the exception that was not caught Since 9ce130e the handler records the last exception per thread, and terminate() printed the entry of the thread that terminates. Since 74f8ed9 the parallel loops of ProSE carry a worker thread's exception to the calling thread with std::exception_ptr and rethrow it there; if a caller does not catch it, terminate() printed that thread's last entry, i.e. no entry or an older exception, instead of the worker's. terminate() now reports the uncaught exception itself (an OpenMS exception carries type, file, line, function and message) and falls back to the last entry of the thread otherwise. Test: GlobalExceptionHandler_test starts itself as a child process (Linux) in which an exception constructed on a worker thread is rethrown uncaught on the main thread, and checks the report on its standard output. On e910aea it held "FATAL: uncaught exception!" and no exception. Review of #10466 (finding F10). Co-Authored-By: Claude Opus 5.5 <[email protected]> * [FIX] FragmentIndex: SNES tolerates the float rounding of a large Sigma querySpectrumSNES_() stores the Sigma of a hit as float and matched the subsets of the realized peptide to it within 1e-4 Da. Above 2048 Da the float rounding alone reaches 1.2e-4 Da, so a subset could fail to match its own Sigma: e.g. two Hex(5)HexNAc(4) (N) glycans (Sigma = 3245.163 Da, stored 1.1e-4 Da off) were never realized by SNES, while the conventional index finds the peptidoform. In Unimod, 9629 of the 52252 pairs of shifts above 1000 Da that sum to 2048 Da or more lose 1e-4 Da or more this way. The match now allows half an ulp of the stored value (|Sigma| * 2^-24) on top of the 1e-4 Da. The comment that gave 1e-6 Da as the tolerance is corrected. Test: FragmentIndex_test searches AN(Hex(5)HexNAc(4))GTPEPN(Hex(5)HexNAc(4))- ESIDER with and without SNES; on e910aea SNES did not find it. Review of #10466 (finding F8, second part; pre-existing SNES code). Co-Authored-By: Claude Opus 5.5 <[email protected]> * [FIX] ProSE: the scoring loop's progress counter is atomic for its reader too Every thread of scoreSpectraAgainstIndex_() incremented count_spectra with '#pragma omp atomic', and the master thread read it without synchronisation for setProgress(). An atomic update does not order a plain read on another thread, so this is a data race; ThreadSanitizer reports it ("Read of size 8 by main thread" in setProgress(count_spectra) after an "atomic write" by a worker). The value only feeds the progress display. The counter is a std::atomic<Size> now (fetch_add, the master shows its own result); no 'omp atomic read', which MSVC's OpenMP 2.0 lacks. The same idiom is in SimpleSearchEngineAlgorithm and IDBoostGraph (not changed here). Evidence (no class test: the race needs ThreadSanitizer): a probe that searches 839 spectra on 8 threads, linked against a TSan build of e910aea, reported the race; against a TSan build with this change it does not. ProSEAlgorithm_test and TOPP_ProSE_* pass. Review of #10466 (finding F3; pre-existing, from #10400). Co-Authored-By: Claude Opus 5.5 <[email protected]> * [FIX] ProSE: no unused-parameter warning without OpenMP readerThreads() reads its parameter 'background' only in the _OPENMP branch, so builds without an OpenMP runtime (MT_ENABLE_OPENMP=OFF, or Clang with the -fopenmp-simd fallback) warned "unused parameter 'background'". It is marked [[maybe_unused]]. Co-Authored-By: Claude Opus 5.5 <[email protected]> * [TEST] FragmentIndex: residue-specific terminal modifications on peptide and protein termini Nine fixtures compare the index with an AASequence oracle: the peptidoforms (as reconstructed sequences, which must parse back), their precursor m/z and their b/y fragment m/z. They cover Gln->pyro-Glu (N-term Q) alone, on a peptide without N-terminal Q, competing with Acetyl (N-term) for the N-terminus, next to Deamidated (Q) on the same residue, and excluded by a fixed TMT6plex (N-term); Ammonia-loss (N-term C) next to a fixed Carbamidomethyl (C); and Dehydrated (Protein C-term Q) with and without a fixed Amidated (C-term). Protein-terminal residue preferences get a slot only at the protein terminus, and SNES realizes Gln->pyro-Glu on the N-terminus. Without the fix for residue-specific terminal modifications on a residue with a fixed modification, the Ammonia-loss (N-term C) fixture gets one peptidoform instead of two; the other fixtures guard the terminal slots introduced in 74f8ed9. Co-Authored-By: Claude Opus 5.5 <[email protected]> * [DOC] CHANGELOG: ProSE entries without timing and yield figures; entries for the fixes - Remove the timing and yield figures from the ProSE entries (PERF of the search, the deisotoping envelope rule, protein mapping); measurements are reported separately. - Add the entry for the fragment bound fix of aed31fa (the fragments are tested against the bounds that select the buckets). - Update the FragmentIndex and ProSE entries for the fixes of this PR: a residue-specific terminal variable modification applies next to a fixed modification of the residue; fragment:mass_tolerance must be finite and positive for every scoring method (local fragment evidence no longer is the only check); the preprocessing loop rethrows worker exceptions too; the warning names every variable modification that a fixed one excludes. Co-Authored-By: Claude Opus 5.5 <[email protected]> * [DOC] ProSE: no timing figures on the tool page The notes on several input files and on threads keep their advice (one call for all files, OMP_WAIT_POLICY=passive on shared machines, no thread binding) but no longer quote measurements from one machine and one benchmark (0.7x, less than half the CPU time, 15-18% slower). As in the CHANGELOG, which dropped its timing and yield figures in c013052. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UQCiwdbPoEkrebED8VQ2TJ * [CI] Windows: download the custom NSIS from raw.githubusercontent.com (port of #10472) Same change as 8582fa4 on #10472, carried here so the Windows build-and-test job of this PR can build while https://github.com/OpenMS/NSIS/raw/main/NSIS.tar.gz returns GitHub's 504 error page. It becomes a no-op when develop carries #10472. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UQCiwdbPoEkrebED8VQ2TJ --------- Co-authored-by: Oliver <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Julianus Pfeuffer <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #10456. Since #10427,
IdXMLFile.cppfails to compile whenever OpenMS falls back to-fopenmp-simdbecause no OpenMP runtime was found (e.g. Apple Clang without libomp,MT_REQUIRE_OPENMP=OFF, which is the default):team_sizewas declared only under#ifdef _OPENMP, but the#pragma omp parallel ... num_threads(team_size)that uses it is unguarded, and Clang still parses its clauses in-fopenmp-simdmode. The fix declaresteam_sizeunconditionally as 1 ([[maybe_unused]]for builds that ignore the pragma) and only queriesomp_get_max_threads()under_OPENMP. OpenMP builds behave exactly as before.Verification (macOS arm64, Apple Clang):
IdXMLFile.cppcompiles without errors or warnings (-Wall -Wextra) with-fopenmp-simdand without any OpenMP flag.#pragma ompinsrc/openms,src/openswathalgo,src/openms_guiandsrc/toppin-fopenmp-simdmode.IdXMLFile.cppwas the only failure before this fix.IdXMLFile|IDFileConverter|IDFilter132/132 passed.No CHANGELOG entry, because the regression is not in any release.
Checklist