Build Packages / Create release (push) Successful in 7s
Build Packages / build:portable:macos-arm64:nocuda (push) Successful in 4m56s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 9m10s
Build Packages / build:portable:linux-x86_64:nocuda (push) Successful in 13m51s
Build Packages / build:portable:linux-x86_64:cuda (push) Successful in 16m56s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 20m59s
Build Packages / build:portable:windows-x86_64:nocuda (push) Successful in 21m25s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 21m17s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 14m14s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 25m59s
Build Packages / build:portable:windows-x86_64:cuda (push) Successful in 25m48s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 15m52s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 19m33s
Build Packages / Generate python client (push) Successful in 29s
Build Packages / Build documentation (push) Successful in 1m19s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 20m49s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 25m31s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 25m24s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 26m5s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 22m19s
Build Packages / Unit tests (push) Failing after 2h28m24s
Build Packages / Validation Battery (push) Successful in 40m33s
* Rugnux: Processes a collection live while jfjoch_broker writes it (`rugnux <master.h5> <broker URL>`). * Rugnux: Processing starts on the first images and confirms its choices once all are in, so analysis can begin during collection. * Rugnux: Faster processing, especially on servers with several GPUs and CPU sockets and on computers without a GPU (`--no-gpu`, macOS). * Rugnux: Uses much less GPU memory, so large data sets stay on the GPU of smaller cards, and a data set too large for the card is processed on the CPU instead. * Rugnux: On macOS, Bragg integration runs on the Apple GPU. * Rugnux: Better handling of twinning and pseudo-symmetry, with the twin hypothesis written as `<prefix>_twin_<SG>.mtz`, and a wrong `--model` no longer confirms the data or decides the hand. * Rugnux: `--model` accepts predicted (AlphaFold) models and falls back to molecular replacement when the model is not placed as a rigid body (experimental `--mr` forces it), settling space group, hand and twinning and writing a different answer as `<prefix>_mr.mtz`. * Rugnux: Molecular replacement is faster and settles the space group in more cases with several copies in the asymmetric unit. * Rugnux: Deposition-ready mmCIF, a richer report, and numbered steps on the terminal with the full log in `<prefix>_log.txt`; `_P1.mtz`, `--estimate-beam-center` and `--beam-center-search` are removed. * Rugnux: The beam-stop shadow is found correctly on tilted detectors. * Rugnux: Stills files that record a stationary goniometer axis get the default stills geometry refinement. * jfjoch_viewer: "Analyze dataset" uses the same defaults as a bare `rugnux <file>`, and shows the results of processed CBF, marCCD and SMV sweeps. * jfjoch_viewer: The Files panel refreshes on F5 and every few seconds, and the plot type and other selections stay put during live collection. * jfjoch_writer: Memory stays bounded and old data files are closed efficiently on long runs, any failure ends the run in an error state the broker is told about, and the master file appears only after its data files; the ZeroMQ pusher logs when a stalled writer makes it drop images. * Fixes: The TCP image pusher no longer blocks the broker's receiver, GPU out-of-memory failures stop with a clear message, and the XDS plugin masks module and chip edges. --------- Co-authored-by: Filip Leonarski <jungfrau@filips-mac-mini.home> Reviewed-on: #85 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
69 lines
3.1 KiB
C++
69 lines
3.1 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 "../../common/CompressedImage.h"
|
|
#include "../indexing/CUDAMemHelpers.h"
|
|
|
|
// What one tile of the byte-offset stream does to a decode that enters it at each of the 15 byte
|
|
// positions a token can straddle the tile boundary by: where the decode leaves the tile (the offset
|
|
// into the next one), how many pixels it emitted, and what they added to the running value. Entry and
|
|
// exit 15 is "the stream has ended", which every later tile passes on.
|
|
struct CBFTileMap {
|
|
static constexpr int DEAD = 15;
|
|
uint32_t count[16];
|
|
uint32_t sum[16]; // modulo 2^32, which is all an int32 pixel keeps of the int64 running value
|
|
uint8_t exit[16];
|
|
};
|
|
|
|
// x-CBF_BYTE_OFFSET decoded ON THE DEVICE, exactly as DecodeCBFByteOffset does on the host: the same
|
|
// int32 pixels, and the same refusal of a stream that ends before the image does.
|
|
//
|
|
// The format is a running sum of deltas whose tokens are 1, 3, 7 or 15 bytes long, so where a token
|
|
// starts depends on every token before it. The stream is cut into short parts; for each part and each
|
|
// of the 15 offsets a decode can enter it at, one thread works out where it leaves, how many pixels it
|
|
// emits and what they sum to (the walks from different offsets meet within a few bytes, after which
|
|
// they are the same walk). Composing those maps is a scan - over tiles of a few parts, whose maps are
|
|
// the parts' composed - which gives every part its true entry offset, its first pixel and the running
|
|
// value there; a second walk of each part then writes the pixels.
|
|
class CBFDecoderGPU {
|
|
std::shared_ptr<CudaStream> stream;
|
|
|
|
// The reader's buffer is pageable; copied here first, the upload is one DMA (see BSLZ4DecoderGPU).
|
|
CudaHostPtr<uint8_t> host_compressed;
|
|
CudaDevicePtr<uint8_t> gpu_compressed;
|
|
size_t compressed_capacity = 0;
|
|
|
|
CudaDevicePtr<CBFTileMap> gpu_part_maps;
|
|
CudaDevicePtr<CBFTileMap> gpu_maps;
|
|
CudaDevicePtr<CBFTileMap> gpu_entries; // exclusive scan of gpu_maps: the state each tile is entered in
|
|
CudaDevicePtr<uint8_t> gpu_scan_temp;
|
|
size_t scan_temp_bytes = 0;
|
|
size_t tile_capacity = 0;
|
|
|
|
CudaDevicePtr<uint32_t> gpu_total; // pixels the whole stream decodes to
|
|
CudaHostPtr<uint32_t> host_total;
|
|
size_t last_npixels = 0;
|
|
|
|
CudaEvent decode_start;
|
|
CudaEvent decode_stop;
|
|
|
|
public:
|
|
explicit CBFDecoderGPU(std::shared_ptr<CudaStream> stream);
|
|
~CBFDecoderGPU() { if (stream) cudaStreamSynchronize(*stream); }
|
|
|
|
// Upload the stream and queue its decode into gpu_out (image width x height int32 pixels) on the
|
|
// decoder's stream. The caller synchronises, then calls ThrowIfDecodeFailed().
|
|
void Decode(const CompressedImage &image, int32_t *gpu_out);
|
|
|
|
// Report a stream that ended before the image did. MUST be called after the caller has
|
|
// synchronised the stream.
|
|
void ThrowIfDecodeFailed() const;
|
|
|
|
// Device time of the last upload and decode, in seconds. Valid after the caller synchronises.
|
|
[[nodiscard]] float GetDecodeTime_s() const;
|
|
};
|