From 27c4306b7a924da7dacb6695efdadccca1729b30 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Wed, 18 Nov 2026 18:49:54 +0100 Subject: [PATCH] jfjoch_fpga_stills_test: -m sums frames into each image The card sums up to 256, above that the largest divisor up to 256 and the host the rest (hybrid summation); images are 32-bit. jfjoch_fpga_test already has -S for the card-only case. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HVeDQrPqZ52Tp6rzzZGxf3 --- docs/TOOLS.md | 6 ++++-- tools/jfjoch_fpga_stills_test.cpp | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/docs/TOOLS.md b/docs/TOOLS.md index bfb11fd86..c1baf283d 100644 --- a/docs/TOOLS.md +++ b/docs/TOOLS.md @@ -74,7 +74,7 @@ synthesis C model on the CPU, so no FPGA device is required. Measures rugnux live stills on the FPGA card(s), with a stored dataset standing in for the detector: ``` -jfjoch_fpga_stills_test [-i ] [-s ] [-N ] [-B ] [-C a,b,c,al,be,ga] [-X ] [-r ,...] [-p ] [-k ] [-d] [-v] [-K[]] +jfjoch_fpga_stills_test [-i ] [-s ] [-N ] [-B ] [-C a,b,c,al,be,ga] [-X ] [-r ,...] [-p ] [-k ] [-m ] [-d] [-v] [-K[]] ``` - The dataset must be a stored JUNGFRAU dataset with its modules assembled (1030 x 514 each, any placement @@ -89,7 +89,9 @@ jfjoch_fpga_stills_test [-i ] [-s ] [-N ] [-B ] [-C conversion off, so the card returns them verbatim; the host assembles them as signed 16-bit photon counts and rugnux live stills analyses them through `FPGAImagePuller`, as the broker does with rugnux live on (`-d`: not blocking, as the broker runs; `-v`: each card's progress every 0.5 s; `-k `: analyse 1 of every - F images on average, the rugnux live setting `stills_downsample`). Beam centre, distance, energy and the cell + F images on average, the rugnux live setting `stills_downsample`; `-m `: N frames summed into each image, by + the card up to 256 and above that the largest divisor of N up to 256 on the card and the rest on the host, 32-bit + images). Beam centre, distance, energy and the cell come from the file (`-C` overrides the cell; without one the frames are indexed de novo). Nothing is written. - Each card's generator holds module frames of its own modules only: as many images as its memory holds diff --git a/tools/jfjoch_fpga_stills_test.cpp b/tools/jfjoch_fpga_stills_test.cpp index 4fd6a8282..d33901c3d 100644 --- a/tools/jfjoch_fpga_stills_test.cpp +++ b/tools/jfjoch_fpga_stills_test.cpp @@ -45,6 +45,8 @@ void print_usage(Logger &logger) { logger.Info(" -p Images FPGAImagePuller keeps compressed for the receiver (default 128)"); logger.Info(" -U No dummy modules: where the cards carry different numbers of modules, they run apart"); logger.Info(" -k Analyse 1 of every images on average (rugnux live stills_downsample, default 1)"); + logger.Info(" -m Frames summed into an image (default 1): the card sums the largest divisor up to 256, the"); + logger.Info(" host the rest (1000 = 250 on the card x 4 on the host)"); logger.Info(" -d Not blocking, as the broker runs: images the host has no room for are dropped. The cards'"); logger.Info(" generators run free, each at a speed that goes with its modules: where the modules do not"); logger.Info(" divide evenly, each card is given dummy modules up to the largest count (-U: not)"); @@ -94,7 +96,7 @@ bool RunDataset(Logger &logger, AcquisitionDeviceGroup &aq_devices, const std::s std::optional nimages, uint16_t nstreams, uint16_t nthreads, size_t send_buffer_size_MiB, const IndexingSettings &indexing, const std::optional &cell, size_t puller_queue, const std::vector &rates, bool dropping, bool pad, bool verbose, int64_t downsample, - const std::optional &space_group) { + const std::optional &space_group, int64_t summation) { RegisterHDF5Filter(); JFJochHDF5Reader reader; reader.ReadFile(file); @@ -116,6 +118,9 @@ bool RunDataset(Logger &logger, AcquisitionDeviceGroup &aq_devices, const std::s .UseInternalPacketGenerator(true).DataStreams(nstreams); // The card returns the frames as loaded; the host assembles them as signed 16-bit photon counts x.JungfrauConvPhotonCnt(false).GeometryTransformation(true).PixelSigned(true).BitDepthImage(16); + // Summed: 32-bit images + if (summation > 1) + x.Summation(summation).BitDepthImage(32); x.Compression(CompressionAlgorithm::BSHUF_LZ4); x.IncidentEnergy_keV(file_x.GetIncidentEnergy_keV()).DetectorDistance_mm(file_x.GetDetectorDistance_mm()) .BeamX_pxl(file_x.GetBeamX_pxl()).BeamY_pxl(file_x.GetBeamY_pxl()); @@ -332,10 +337,11 @@ int main(int argc, char **argv) { bool dropping = false; bool pad = true; int64_t downsample = 1; + int64_t summation = 1; std::optional space_group; int opt; - while ((opt = getopt(argc, argv, "vi:s:N:B:C:S:X:t:r:p:dUk:K::")) != -1) { + while ((opt = getopt(argc, argv, "vi:s:N:B:C:S:X:t:r:p:dUk:m:K::")) != -1) { switch (opt) { case 'v': verbose = true; @@ -394,6 +400,9 @@ int main(int argc, char **argv) { case 'k': downsample = atol(optarg); break; + case 'm': + summation = atol(optarg); + break; case 'S': { const gemmi::SpaceGroup *sg = gemmi::find_spacegroup_by_name(optarg); if (sg == nullptr) { @@ -445,7 +454,8 @@ int main(int argc, char **argv) { bool ret = false; try { ret = RunDataset(logger, aq_devices, argv[optind], nimages, nstreams, nthreads, send_buffer_size_MiB, - i_settings, cell, puller_queue, rates, dropping, pad, verbose, downsample, space_group); + i_settings, cell, puller_queue, rates, dropping, pad, verbose, downsample, space_group, + summation); } catch (std::exception &e) { logger.Error(e.what()); }