|
FZGPUModules 2.0
GPU-accelerated modular compression pipelines
|
How to build, use, and file-serialize a new stage that lives in your own project and links against an installed FZGPUModules — without patching the library. Use this while a stage is unpublished, private, or still being prototyped. When it is ready to upstream, follow How to Add a New Stage instead and delete the workarounds below.
The stage class is written exactly as the in-tree guide describes — same Stage base class, same required overrides, same HIP rules, same execute() contract. Everything on this page is only about the parts that normally touch shared files (fzm_format.h, the root CMakeLists.txt, config.cpp, include/fzgpumodules.h) and how to replace them from outside.
The install tree exports every header under <prefix>/include/fzgmod/ — including the internal ones this pattern needs (stage/stage.h, stage/stage_registry.h, fzm_format.h). Point CMAKE_PREFIX_PATH at the install prefix (or the build tree).
Your .cu includes the public umbrella header for the pipeline API and the internal headers for the base class:
Stage::getStageTypeId() returns a plain uint16_t, not fz::StageType, so an out-of-tree stage never has to add an enumerator:
This id is provisional. It is written into every
.fzmfile your stage produces. Two different out-of-tree stages that both pick40000will write archives that silently collide. Before you publish anything other people will read, reserve a realStageTypevalue upstream and migrate. If you must ship archives in the interim, treat the id as coupled to your build only.
stageTypeToString() lives in the library and will not know your name; that only affects diagnostic strings, not correctness.
Nothing special — addStage is a template and only needs the full class definition:
In-memory compress/decompress with the same fz::Pipeline object works with no further registration, because decompress() rebuilds the inverse DAG from the live forward pipeline.
writeToFile / decompressFromFile rebuild the inverse pipeline from the archive alone, so they look the stage up in the stage registry by id. Register a reconstruction factory at file scope in your .cu — the macro is header-only and works identically outside the tree:
Registration happens at static-init time, so the translation unit must actually be linked in. With a static library, force it:
(or -Wl,--whole-archive / --no-whole-archive, or ALWAYS_LINK / +load-all). Without this the linker drops the object and the factory never registers, so decode fails with "no factory registered for stage type 40000".
type = "MyStage" in a .toml). The toml++ loader is confined to the library's config.cpp and has no extension point. Configure the stage in C++.--stages MyStage** on the bundled fzgmod-cli. Build your own driver.docs/stages/ page. Keep your own docs until the stage lands.Move the .cu/.h into modules/<category>/<name>/, run scripts/new_stage.sh <Name> <category> to claim a real StageType id and wire CMake/tests, then work through the How to Add a NewStage" checklist. The class body and kernels carry over unchanged; only the id and the shared-file edits differ. Note the id change in your migration notes so pre-upstream archives can be regenerated.