|
| 1 | +# Contributing to FZGPUModules |
| 2 | + |
| 3 | +Thanks for your interest in improving FZGPUModules. Contributions of all kinds |
| 4 | +are welcome: bug reports, documentation, examples, tests, and code changes. |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## Ways to contribute |
| 9 | + |
| 10 | +- **Bug reports** — file an issue with environment details and a minimal reproducer |
| 11 | +- **Documentation** — fix typos, clarify confusing sections, add usage examples |
| 12 | +- **Tests** — add regression tests for existing behavior or cover edge cases |
| 13 | +- **New stages** — see [How to Add a Stage](docs/how_to_add_a_stage.md) |
| 14 | +- **Bug fixes and features** — open an issue to discuss first for non-trivial changes |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +## Build and test |
| 19 | + |
| 20 | +```bash |
| 21 | +# Clone with submodules (googletest) |
| 22 | +git clone https://github.com/szcompressor/FZGPUModules.git |
| 23 | +cd FZGPUModules |
| 24 | +git submodule update --init --recursive |
| 25 | + |
| 26 | +# Build (tests disabled by default; enable explicitly) |
| 27 | +cmake --preset release -DBUILD_TESTING=ON |
| 28 | +cmake --build build/release -j$(nproc) |
| 29 | +``` |
| 30 | + |
| 31 | +Run the test suite: |
| 32 | + |
| 33 | +```bash |
| 34 | +ctest --preset default # all tests |
| 35 | +ctest --preset stages # stage unit tests only |
| 36 | +ctest --preset pipeline # pipeline integration tests only |
| 37 | +``` |
| 38 | + |
| 39 | +Run with sanitizers before submitting: |
| 40 | + |
| 41 | +```bash |
| 42 | +cmake --preset asan |
| 43 | +cmake --build --preset asan -j$(nproc) |
| 44 | +LD_PRELOAD=$(gcc --print-file-name=libasan.so) \ |
| 45 | + ASAN_OPTIONS=detect_leaks=0:abort_on_error=0:protect_shadow_gap=0 \ |
| 46 | + UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=0 \ |
| 47 | + ctest --preset asan |
| 48 | +``` |
| 49 | + |
| 50 | +See [Building from Source](docs/building.md) for preset details and sanitizer flags. |
| 51 | + |
| 52 | +--- |
| 53 | + |
| 54 | +## Code style and conventions |
| 55 | + |
| 56 | +- **C++17**, CUDA 11.2+. Match the style of nearby files. |
| 57 | +- **No bare printf/cout/cerr** in library code — use `FZ_LOG(LEVEL, ...)` or `FZ_PRINT(...)`. |
| 58 | +- **No `cudaDeviceSynchronize()`** inside `Stage::execute()` — enqueue all work on the provided `stream`. |
| 59 | +- **Public API only in user-facing code** — include `fzgpumodules.h`; do not include `cuda_check.h` or internal headers in examples. |
| 60 | +- **`connect()` argument order** — `pipeline.connect(downstream, upstream, "port")`. |
| 61 | +- **Lorenzo downstream port** — connect to `"codes"`, not `"output"`. |
| 62 | +- **Template instantiations** — many stages are templates with explicit instantiations (e.g., `RLEStage<uint16_t>`). Check the stage's documentation (e.g., `docs/stages/rle.md`) for available types before using a template stage. Adding a new type requires adding an `extern template` declaration in the header and instantiation in the `.cu` file. |
| 63 | + |
| 64 | +--- |
| 65 | + |
| 66 | +## Changelog |
| 67 | + |
| 68 | +For any code change (fix, feature, refactor, removal), add a one-line entry to |
| 69 | +`CHANGELOG.md` under the appropriate `[Unreleased]` subsection (`Added`, `Changed`, |
| 70 | +`Fixed`, or `Removed`) before finishing the change. Documentation-only edits do |
| 71 | +not need a changelog entry. |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +## Adding a new stage |
| 76 | + |
| 77 | +Use the scaffold script and follow the step-by-step guide: |
| 78 | + |
| 79 | +```bash |
| 80 | +scripts/new_stage.sh MyStageName <category> # category: predictors, quantizers, coders, shufflers, transforms, fused |
| 81 | +``` |
| 82 | + |
| 83 | +Full instructions: [docs/how_to_add_a_stage.md](docs/how_to_add_a_stage.md) |
| 84 | + |
| 85 | +Key requirements for any new stage: |
| 86 | +- All required `Stage` virtual methods implemented |
| 87 | +- `StageType` enum value chosen (unique integer, never reuse or renumber existing values) |
| 88 | +- Registered in `StageFactory`, `config.cpp` (TOML), and root `CMakeLists.txt` |
| 89 | +- Tests: ForwardRoundTrip, ZeroInput, SerializeDeserialize, PipelineIntegration, SaveRestoreState |
| 90 | + |
| 91 | +--- |
| 92 | + |
| 93 | +## Submitting a pull request |
| 94 | + |
| 95 | +1. Fork and create a branch from `main`. |
| 96 | +2. Make your changes and confirm tests pass (including sanitizers for code changes). |
| 97 | +3. Add a `CHANGELOG.md` entry for code changes. |
| 98 | +4. Open a PR against `main` with a clear description and rationale. |
| 99 | +5. Link any relevant issues; include reproduction steps for bug fixes. |
| 100 | +6. Mention any build flags or environment details required to validate the change. |
| 101 | + |
| 102 | +For non-trivial new features or API additions, open an issue first to discuss the |
| 103 | +approach before writing code — this avoids wasted effort if the design needs revision. |
| 104 | + |
| 105 | +--- |
| 106 | + |
| 107 | +## API compatibility |
| 108 | + |
| 109 | +Avoid breaking public API unless the change warrants a major version bump. See |
| 110 | +[API Reference — Stability and Versioning](docs/api_reference.md#api_stability) for the full policy and a |
| 111 | +per-PR checklist. |
0 commit comments