FZGPUModules 2.0
GPU-accelerated modular compression pipelines
Loading...
Searching...
No Matches
stage_registry.h File Reference

Central registry that reconstructs a Stage from a serialized FZM header. More...

#include "stage/stage.h"
#include "fzm_format.h"
#include <cstddef>
#include <cstdint>

Go to the source code of this file.

Classes

struct  fz::detail::StageFactoryRegistrar
 

Namespaces

namespace  fz
 

Macros

#define FZ_REGISTER_STAGE_FACTORY(TYPE, FN)
 
#define FZ_REGISTER_SIMPLE_STAGE(TYPE, STAGE_CLASS)
 

Typedefs

using fz::StageHeaderFactory = Stage *(*)(const uint8_t *config, size_t config_size)
 

Functions

void fz::registerStageHeaderFactory (StageType type, StageHeaderFactory fn)
 
bool fz::hasStageHeaderFactory (StageType type)
 
Stagefz::createStage (StageType type, const uint8_t *config, size_t config_size)
 

Detailed Description

Central registry that reconstructs a Stage from a serialized FZM header.

Stages self-register their reconstruction function at static-init time via FZ_REGISTER_STAGE_FACTORY / FZ_REGISTER_SIMPLE_STAGE (placed at file scope in the stage's own .cu). The decompressor calls createStage(), which looks the StageType up in the registry — there is no central switch to edit when a new stage is added.

Adding a stage therefore touches only the stage's own directory for this axis; see docs/how_to_add_a_stage.md.

Macro Definition Documentation

◆ FZ_REGISTER_STAGE_FACTORY

#define FZ_REGISTER_STAGE_FACTORY (   TYPE,
  FN 
)
Value:
namespace { \
const ::fz::detail::StageFactoryRegistrar \
FZ_STAGE_CONCAT(FZ_STAGE_FACTORY_REGISTRAR_, __LINE__){(TYPE), (FN)}; \
}

Register a custom header factory for a StageType. Place at file scope in the stage's .cu, after the factory function is defined:

static fz::Stage* MyStage_fromHeader(const uint8_t* c, size_t n) { ... } FZ_REGISTER_STAGE_FACTORY(fz::StageType::MY_STAGE, MyStage_fromHeader);

◆ FZ_REGISTER_SIMPLE_STAGE

#define FZ_REGISTER_SIMPLE_STAGE (   TYPE,
  STAGE_CLASS 
)
Value:
namespace { \
::fz::Stage* FZ_STAGE_CONCAT(FZ_STAGE_SIMPLE_FACTORY_, __LINE__)(const uint8_t* config, \
size_t config_size) { \
auto* s = new STAGE_CLASS(); \
s->deserializeHeader(config, config_size); \
return s; \
} \
const ::fz::detail::StageFactoryRegistrar \
FZ_STAGE_CONCAT(FZ_STAGE_SIMPLE_REGISTRAR_, __LINE__){(TYPE), \
&FZ_STAGE_CONCAT(FZ_STAGE_SIMPLE_FACTORY_, __LINE__)}; \
}
Definition stage.h:31

Convenience for a stage with no template dispatch — reconstruction is just new StageClass() + deserializeHeader(). Place at file scope in the .cu:

FZ_REGISTER_SIMPLE_STAGE(fz::StageType::RZE, fz::RZEStage);