The spot-width stage of the pre-scan copied every preprocessed frame back to the host (72 MB a frame on a 16M detector, page-locked host mirrors per worker) for measurements that read a few pixels about each spot. Now: - MeasureSpotsOnTiles: the flux curves and the footprint read (2*24+1)^2 squares about each spot, gathered on the card (ImagePreprocessorBufferGPU::GatherTiles) - no copy_image_to_host, no host mirror. The flux curves are bounded at R_BKG_OUT = 20 px. The footprint keeps its arithmetic; a per-iteration check that its window is inside the square, and a spot whose window walks off it is measured again from scratch on an 80 px square, then on the whole frame. Where the squares would be more pixels than the frame, the frame is read. Same pixels in the same order, so the same bits. Harness over 34 rotation sets (~1500 frames): 0 differences; misses at 24 on a few spots of most frames, at 54 on up to 80% of frames of a few sets, at 80 on none. - The azimuthal mapping and the per-worker spot engines are built while the frames are read. - The tiers no longer wait for each other: workers run on through the visit order, each tier's answer is drawn from exactly its own frames, and frames measured past the tier the answer stops at are thrown away - a frame is measured the same whichever tier it is read for. - PreScanMemo keeps the spot measurement, the defective pixels and the background gain under the pre-scan key plus the spot-finding and azimuthal settings, so a copy of the run that pre-scans again on the same inputs reads no frames. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EizBKhTqrAYago9KJG3dA3
48 lines
2.3 KiB
C++
48 lines
2.3 KiB
C++
// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
|
|
#include "ImagePreprocessorBuffer.h"
|
|
#include "../indexing/CUDAMemHelpers.h"
|
|
#include "../spot_finding/SpotFindingSettings.h"
|
|
|
|
class ImagePreprocessorBufferGPU : public ImagePreprocessorBuffer {
|
|
CudaDevicePtr<int32_t> gpu_image;
|
|
CudaRegisteredVector<int32_t> buffer_reg;
|
|
|
|
// Staging for Gather(). Its only caller is ImageSpotFinder::ExtractSpots, which gives up on a frame
|
|
// with StrongPixelLimit or more strong pixels (the connected-component search rejects it anyway),
|
|
// so that is the largest gather that can be asked for. It follows the detector, so this has to as
|
|
// well - sized to a constant while the caller's bar was raised, the gather would run off the end
|
|
// of the buffer rather than merely lose the frame.
|
|
const size_t max_gather;
|
|
CudaDevicePtr<uint32_t> gpu_gather_index;
|
|
CudaDevicePtr<int32_t> gpu_gather_value;
|
|
// Own stream: every analysis engine synchronises its own stream before it returns, so the device
|
|
// image is final by the time a gather is asked for. The NULL stream would serialise all workers.
|
|
CudaStream gather_stream;
|
|
|
|
// GatherTiles: the squares' centres, the squares on the card, and the page-locked landing for them.
|
|
// Grown to the largest frame's spots.
|
|
size_t tile_capacity = 0; // pixels of gpu_tiles and host_tiles
|
|
CudaDevicePtr<int32_t> gpu_tile_centre;
|
|
CudaDevicePtr<int32_t> gpu_tiles;
|
|
PinnedVector<int32_t> tile_centre;
|
|
PinnedVector<int32_t> host_tiles;
|
|
|
|
public:
|
|
// host_mirror = false skips the host copy of the preprocessed image entirely (and with it the
|
|
// page-locking): pass it when every engine reading this buffer runs on the device.
|
|
explicit ImagePreprocessorBufferGPU(size_t npixel, bool host_mirror = true);
|
|
|
|
int32_t *getGPUBuffer() override;
|
|
const int32_t *getGPUBuffer() const override;
|
|
void Gather(const std::vector<uint32_t> &npixel, std::vector<int32_t> &values) const override;
|
|
const int32_t *GatherTiles(const std::vector<int32_t> &x, const std::vector<int32_t> &y,
|
|
int width, int half) override;
|
|
const int32_t *HostImage() override;
|
|
};
|