|
| void | setInverse (bool inv) override |
| |
| bool | isGraphCompatible () const override |
| |
| void | setBlockSize (uint32_t n) |
| |
| FusionSpec | getFusionSpec () const override |
| |
| FusedOpDecl | getFusedOp () const override |
| |
| EncodingOracleDecl | getEncodingOracle () const override |
| |
| void | setFusedCoder (std::string name) |
| |
| void | setFusedResult (size_t num_elements, size_t archive_bytes) |
| |
| void | setFusedArchiveResult (size_t archive_bytes, size_t orig_bytes) override |
| |
| void | setOutlierSelection (bool enable) |
| |
| void | execute (fz::stream_t stream, MemoryPool *pool, const std::vector< void * > &inputs, const std::vector< void * > &outputs, const std::vector< size_t > &sizes) override |
| |
| void | postStreamSync (fz::stream_t stream) override |
| |
| std::string | getName () const override |
| |
| std::vector< size_t > | estimateOutputSizes (const std::vector< size_t > &input_sizes) const override |
| |
| size_t | estimateScratchBytes (const std::vector< size_t > &input_sizes) const override |
| |
| std::unordered_map< std::string, size_t > | getActualOutputSizesByName () const override |
| |
| size_t | getActualOutputSize (int index) const override |
| |
| uint16_t | getStageTypeId () const override |
| |
| uint8_t | getOutputDataType (size_t) const override |
| |
| uint8_t | getInputDataType (size_t) const override |
| |
| size_t | serializeHeader (size_t, uint8_t *buf, size_t max_size) const override |
| |
| void | deserializeHeader (const uint8_t *buf, size_t size) override |
| |
| size_t | getMaxHeaderSize (size_t) const override |
| |
| void | saveState () override |
| |
| virtual size_t | getRequiredInputAlignment () const |
| |
| virtual std::vector< std::string > | getOutputNames () const |
| |
| int | getOutputIndex (const std::string &name) const |
| |
| virtual std::vector< std::string > | getRunNotes () const |
| |
| virtual void | setDims (const std::array< size_t, 3 > &dims) |
| |
| virtual void | onFinalize (size_t, MemoryPool *) |
| |
| virtual size_t | estimateDeviceFootprintBytes (size_t) const |
| |
| virtual size_t | estimatePinnedFootprintBytes (size_t) const |
| |
| virtual void | setTerminalOutput (bool terminal) |
| |
| virtual bool | bindDownstreamEncodingOracle (const EncodingOracleDecl &) |
| |
| virtual std::vector< FusedAuxOutputDecl > | getFusedAuxOutputs () const |
| |
| virtual void | primeFusedForwardState (const FusedPrimeContext &) |
| |
| virtual void | setFusedSideOutput (int, size_t) |
| |
template<typename T>
class fz::AdaptiveBitpackStage< T >
Per-block adaptive fixed-rate bit-plane coder — the cuSZp lossless back-end's "plain" mode, as a modular stage.
For each block of block_size signed elements it emits one rate byte (the bit width of the largest magnitude in the block) followed, when that rate is non-zero, by a per-block sign bitmap and that many bit-planes. Per-block byte offsets are resolved with a plain device-wide exclusive scan (CUB) rather than the cuSZp decoupled look-back scan, which is a fusion-time optimization left to the downstream compiler.
Pair with QuantizerStage(linear) → LorenzoStage(setBlockSize) for the cuSZp pipeline; block_size typically matches the Lorenzo block (32) but need not.
- Note
- Forward is graph-compatible; inverse is not. The forward path's data-dependent compressed-size readback (cuSZp's
cmpSize D2H) is deferred to postStreamSync() — run after the launch, outside any capture window — so execute() enqueues only stream-ordered device work. Per-block cost/offset scratch is kept persistent so the readback can happen post-sync and no allocation occurs during graph replay (mirrors RZEStage's forward). The inverse keeps a per-execute layout and stays out of capture.
-
Prior work: the per-block fixed-rate bit-plane encoding is the cuSZp lossless scheme (Yafan Huang et al., SC'23/SC'24, BSD-3-Clause). This stage is a direct port of the cuSZp encode/decode kernel logic; the byte-granular layout, CUB offset scan, and FZM/MemoryPool scaffolding are FZGPUModules code. The cuSZp BSD-3-Clause copyright is reproduced in
THIRD_PARTY.md.
- Template Parameters
-
| T | Signed element type: int16_t or int32_t. |
Whether this stage is safe inside a CUDA Graph capture.
A stage is graph-compatible if execute() enqueues only device-side work (kernel launches, cudaMemcpyAsync D2D/H2D) and makes no host-synchronous calls. Override and return false if execute() contains D2H copies or dynamic decisions based on device data — the DAG will throw at setCaptureMode(true) time rather than producing a broken graph.
Default: true. Inverse-mode stages that do D2H reads (e.g. RZE inverse) must return false.
Reimplemented from fz::Stage.
template<typename T >
| void fz::AdaptiveBitpackStage< T >::execute |
( |
fz::stream_t |
stream, |
|
|
MemoryPool * |
pool, |
|
|
const std::vector< void * > & |
inputs, |
|
|
const std::vector< void * > & |
outputs, |
|
|
const std::vector< size_t > & |
sizes |
|
) |
| |
|
overridevirtual |
Execute the stage. Inputs, outputs, and sizes are device pointers/bytes.
Stages may call cudaStreamSynchronize(stream) or issue blocking D2H copies when the algorithm requires it (e.g. Huffman histogram readback for codebook construction, ANS renormalization tables). Such stages must return false from isGraphCompatible() and must document the sync points.
Note: the DAG dispatches sibling nodes (same topological level) via a sequential CPU loop, each enqueuing to its own stream. A sync inside execute() blocks the CPU from dispatching subsequent siblings until the synced stream is idle — this delays parallel branches in wide DAGs. In a linear pipeline there are no siblings and no extra cost.
Implements fz::Stage.