Repository navigation
Create H5read2 - #70
Open
dimitrivlachos wants to merge 33 commits into
Open
dimitrivlachos wants to merge 33 commits into
dimitrivlachos wants to merge 33 commits into
Conversation
Column views now follow the constness of the table, so a const table hands out read-only views. Code that reads columns from a const table in fast-feedback-service needs read-only view types to build against this.
… library The installed package never declared its dependencies and did not ship mdspan, so find_package(DX2) could not be linked against. Embedded consumers inherited the test suite and relied on the parent to request position-independent code. Bitshuffle and LZ4 are added here as private dependencies for the image reader that follows.
# Conflicts: # dx2/CMakeLists.txt # include/dx2/h5/h5dispatch.hpp # requirements.txt # tests/CMakeLists.txt
…g a second copy" This reverts commit 52e1037.
# Conflicts: # CMakeLists.txt # dx2/CMakeLists.txt # include/dx2/h5/h5read_processed.hpp
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fast-feedback-service reads detector frames through [
h5read][h5read],a C library written for 16-bit data that fixes the pixel width when a
consumer is compiled, assumes bitshuffle-LZ4 without looking at the
filter pipeline, and admits one thread at a time: every worker takes a
mutex to ask whether its image has arrived and again to fetch the
chunk. The fast-feedback service used it and now
DiamondLightSource/fast-feedback-service#191 replaces it with this.
This PR adds the reader to dx2.
ImageSourceis a pixel-onlyinterface: frame count, shape, pixel type, filter pipeline, whether a
frame is available yet, and a frame either decoded into the caller's
buffer or handed over as its stored chunk for a GPU to decode. It is
pixel-only because the other sources FFS puts behind it, detector
streams and CBF files, have no NeXus metadata; a source that is not
HDF5 implements the frame methods and nothing else.
H5ImageSourceimplements it for NeXus files, flattening a plain dataset, a virtual
dataset or the numbered
data_000001..Nlinks into one frame table,with the pixel type read from the file and dispatched at run time, so
one binary reads both Eiger widths. Compression is read from the
pipeline rather than assumed, the per-chunk filter mask is honoured,
and the bitshuffle block size comes from the chunk's own header rather
than the legacy
block_size = 0.dx2::nxmxreads the rest of themaster into the models dx2 already has, scaling each quantity by its
unitsattribute, whichh5readignored.Two things make it more than a port. With
Options::swmra sourceopens as soon as the master exists, before any data file has been
written, and follows files as they appear and datasets as they grow;
wait_for_framepolls with a deadline and astd::stop_token, and afile that is not there yet is a
FileNotFound, so a consumer waitingfor the writer retries on that and fails at once on a broken file. The
other is the fetch. The conda HDF5 is the thread-safe build, which
serialises every API call behind one lock, so
H5Dread_chunkfromsixteen threads moves bytes no faster than from one. dx2 asks HDF5 for
the chunk's address and size under the lock and
preads the bytes fromits own descriptor outside it. Reading all 1000 frames of a 1.3 GB
Eiger file from tmpfs:
H5Dread_chunkpreadDecoding on the CPU costs the same on both paths, about 3.4 ms per
frame per thread, so FFS today sees the gain in #191's figures rather
than here; the point is that the fetch is the one stage that could not
otherwise scale as the decode moves to the GPU. dx2 holds no lock of
its own and refuses to open on an HDF5 built without one.
Changes:
ImageSourceandH5ImageSource(include/dx2/image/): theinterface and the HDF5 implementation, with layout discovery, SWMR
open and refresh, and the
preadpath. Chunk addresses include theuser block from HDF5 1.14.4, so the offset is added only below that.
PixelType,FrameViewandFrame: the element type as arun-time value over a type list shared with
h5dispatch, and atype-erased view with checked
as<T>(),as_mdspan<T>()andvisit(), so a GPU consumer decodes into pinned bytes and a CPUconsumer gets an mdspan.
FilterPipelineandChunkDecoder: the pipeline read back fromthe dataset, its
Compressionsummary, and codecs for bitshuffle,bitshuffle-LZ4, bitshuffle-zstd and LZ4 compiled from the upstream
bitshuffle 0.5.2 sources, since no package ships them as a library.
Anything else falls back to
H5Dreadthrough HDF5's plugins.h5link: resolves soft and external links to a file and objectpath before anything is opened, searching relative names in HDF5's
own order, so a dangling link fails naming the file and a missing one
can be waited for.
FramePrefetcher: N worker threads over anyImageSource, inorder or any order, decoded or raw, with pooled buffers; a fresh
36 MB allocation per frame cost 2.3 ms in kernel zero-fill.
nxmx:Panel,MonochromaticBeam,Scan,Goniometerandthe pixel mask from the master, with the axis mapped from McStas to
imgCIF as dxtbx does.
Panelgains getters for image size andtrusted range.
DX2_BUILD_TESTSandDX2_INSTALLso an embedding project neitherbuilds the suite nor installs dx2's files.
DX2_BITSHUFFLE_SIMD_FLAGSselects the AVX2 kernels; the default stays portable.
h5read_processed.hppis split into the generic read helpers and theDIALS format attributes, with no change in behaviour.