With rugnux live mode on, a serial collection from a DECTRIS detector now runs the whole live stills workflow instead of per-image analysis only: the frames wait in the image buffer for a pre-pass that fixes the beam centre, distance and mask, are analysed on the GPU at that geometry, and are merged at half and three quarters of the images and after the last. With a model, it is placed, mapped and refined on each merge. The start message waits for the pre-pass, the end message carries the merged data, and /rugnux/status and the frontend report the run. The receiver uses only what a puller delivers, a DataMessage with a compressed image, so a later FPGA puller feeds the same code. FPGA users lose this until that puller exists: JFJochReceiverFPGA has no stills path any more, so a JUNGFRAU or PSI EIGER collection with rugnux on runs image by image on the card's results, as with the mode off, with /rugnux/status idle, no pre-pass and no live merge. From a stream there are no module packets: efficiency is the images received over those expected, a frame not delivered leaves no entry, and per-image collection efficiency, ADU histograms and pulse IDs are absent. The dark frames of the mask sequence always stay with JFJochReceiverLite. Selection used to look only at the goniometer, so POST /pedestal after a rotation /start with rugnux on went to the rugnux receiver and returned an empty mask. Frames numbered outside the collection are dropped: the analysis keeps per-image results by number, and they corrupted the heap. Carries the behaviour of the live commits of rc184, updated for this receiver: the geometry fixed when the pre-pass ends (the running refinement is removed), the q range fixed, the pre-pass holding more frames until the geometry can be fitted, frames arriving during it waiting in the whole image buffer, the indexer pool's device memory report, the stills model step on provisional merges and after the last image, /cancel cutting it, and the model and Mol* viewer of a serial run during the collection. Rotation on this receiver is unchanged: end to end, the old and new receiver wrote a byte-identical MTZ. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
66 lines
2.5 KiB
C++
66 lines
2.5 KiB
C++
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
// This include should be only included in sections of the code, where it is certain that CUDA is present
|
|
// so with JFJOCH_USE_CUDA preprocessor definition, given this file is included in the source only in this case
|
|
|
|
#include <vector>
|
|
#include <mutex>
|
|
#include <optional>
|
|
#include "CUDAMemHelpers.h"
|
|
#include "../../common/Coord.h"
|
|
#include "../../common/CrystalLattice.h"
|
|
#include "FFTIndexer.h"
|
|
#include "../common/IndexingSettings.h"
|
|
#include "FFTResult.h"
|
|
|
|
// The histograms are made and transformed FFT_BATCH_DIRECTIONS directions at a time. All at once, the
|
|
// histograms, their transforms and cuFFT's work area held 0.8 GB at the default 16384 directions and 2 GB
|
|
// at a doubled cell bound, for the length of the indexer's life; a batch holds a quarter of that. A
|
|
// direction's histogram and transform do not depend on which batch it is in - cuFFT's R2C gives the same
|
|
// bits at any batch count (checked at the histogram sizes the indexer uses) - so neither does the result.
|
|
// Kept large enough that a batch still fills the card.
|
|
constexpr int FFT_BATCH_DIRECTIONS = 4096;
|
|
|
|
class FFTIndexerGPU : public FFTIndexer {
|
|
CudaDevicePtr<float> d_dir_x;
|
|
CudaDevicePtr<float> d_dir_y;
|
|
CudaDevicePtr<float> d_dir_z;
|
|
|
|
CudaDevicePtr<float> d_spot_x;
|
|
CudaDevicePtr<float> d_spot_y;
|
|
CudaDevicePtr<float> d_spot_z;
|
|
|
|
CudaHostPtr<float> spot_x;
|
|
CudaHostPtr<float> spot_y;
|
|
CudaHostPtr<float> spot_z;
|
|
|
|
// The histograms and their transforms of one batch of directions, and the magnitudes of all of them.
|
|
CudaDevicePtr<float> d_input_fft;
|
|
CudaDevicePtr<cufftComplex> d_output_fft;
|
|
CudaDevicePtr<float> d_mag_t;
|
|
CudaDevicePtr<FFTResult> d_result_fft;
|
|
|
|
CudaRegisteredVector<FFTResult> result_fft_reg;
|
|
|
|
CudaStream stream;
|
|
|
|
// After the stream: it waits for the stream before the plan goes back, and goes before the stream.
|
|
CudaFFTPlan plan;
|
|
CudaFFTPlan plan_last; // the last batch, where FFT_BATCH_DIRECTIONS does not divide the directions
|
|
|
|
void ExecuteFFT(const std::vector<Coord> &coord, size_t nspots) override;
|
|
void DirectionsChanged() override;
|
|
public:
|
|
explicit FFTIndexerGPU(const IndexingSettings& settings);
|
|
FFTIndexerGPU(const FFTIndexerGPU &i) = delete;
|
|
const FFTIndexerGPU &operator=(const FFTIndexerGPU &i) = delete;
|
|
~FFTIndexerGPU() override = default;
|
|
size_t DeviceBytes() const override;
|
|
};
|
|
|
|
|
|
|