IndexerThreadPool collapsed two different outcomes into the same empty reply. A worker that threw set result = nullptr, and so did a dispatch that never found a free worker; both then became a default-constructed IndexerResult, indistinguishable downstream from an indexer that ran and found no lattice. The first says nothing about the frame at all - the indexer never looked, and it will fail again on the next one - while the second is a real negative result about the crystal. The visible cost was the advice a failed run gave. With the card full, rugnux printed "Indexer thread 0 failed: CUDA (GPU) error" and then ended with "Two-pass rotation indexing found no lattice. Check the beam centre (--beam-x / --beam-y), raise --max-spots ..." - sending the operator to look at geometry that was never wrong, for a machine that was simply out of memory. None of those remedies can help when the frames were not examined. IndexerResult gains an optional error, set by the worker and by the pool's own catch; the remaining nullptr path keeps its meaning of "not attempted" and deliberately carries no error. RotationIndexer records it and exposes GetIndexerError(), and rugnux's first pass branches on it at the throw site, naming the resource failure instead. The error travels as DATA through image_analysis/ rather than as an exception, because RotationIndexer::RunIndexing() is on the online path - IndexAndRefine calls it on a schedule from the broker and the receiver, where dropping a frame is the right failure and killing a live acquisition is not. Only rugnux, which owns the "this run is over" decision, turns it into one. The failure result is byte-identical to the default-constructed one it replaces, so any_executed and the online frame-drop behaviour are unchanged. The new IndexerError category exists because the category is only the display prefix on what() - Category() is read nowhere - and the old line read "Processing failed: Input parameter invalid" for a GPU fault, which is the same defect one layer up. SpotFinderError is the precedent. msg.indexing_result is deliberately left alone: of its three states, "not attempted" is the honest one for a frame the indexer never examined, and asserting false would be the same collapse again. Verified on a squeezed card (246 MB free, -N 4): exit 1, zero dropped frames, the new message, and no mention of --beam-x. On a free card, against the previous binary at -N 6 on the same input, the logs differ only in paths and timing - same space group, cell and merge statistics. Targeted Catch2 cases pass, including three that drive the pool through the online path. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lc5JG6kJqZoCWaoZ43JGTW
44 lines
1.5 KiB
C++
44 lines
1.5 KiB
C++
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
#include <optional>
|
|
|
|
#include "../../common/CrystalLattice.h"
|
|
|
|
#include "../../common/DiffractionExperiment.h"
|
|
#include "../../common/JFJochMessages.h"
|
|
#include "../../common/SpotToSave.h"
|
|
|
|
struct IndexerResult {
|
|
std::vector<CrystalLattice> lattice;
|
|
float indexing_time_s;
|
|
bool executed = false; // If indexing was not performed (due to indexer being not-available) mark it, so indexing result is marked accordingly
|
|
// What the indexer threw, when it threw. A THIRD outcome, not a flavour of the other two: an
|
|
// empty lattice list with no error is a real negative result about the frame - it was examined
|
|
// and no lattice fits it - whereas an error says nothing about the frame at all, the indexer
|
|
// never having got to look, and will recur on the next one.
|
|
std::optional<std::string> error;
|
|
};
|
|
|
|
class Indexer {
|
|
protected:
|
|
int64_t viable_cell_min_spots = 9;
|
|
float indexing_tolerance = 0.1;
|
|
float dist_tolerance_vs_reference = 0.05;
|
|
bool index_ice_rings = true;
|
|
|
|
DiffractionGeometry geom;
|
|
std::optional<UnitCell> reference_unit_cell;
|
|
|
|
virtual void SetupUnitCell(const std::optional<UnitCell>& cell) = 0;
|
|
virtual std::vector<CrystalLattice> RunInternal(const std::vector<Coord> &coord, size_t nspots) = 0;
|
|
public:
|
|
virtual ~Indexer() = default;
|
|
void Setup(const DiffractionExperiment& experiment);
|
|
IndexerResult Run(const std::vector<Coord> &coord);
|
|
};
|
|
|
|
|