oxifft-codegen
Version: 0.2.0
Status: ⚠️ Early Development — API may change
Procedural macro crate for OxiFFT codelet generation.
Overview
This crate replaces FFTW's OCaml-based genfft code generator with Rust procedural macros. It generates highly optimized FFT kernels (codelets) at compile time.
Features
- Compile-time code generation: Zero runtime overhead (radix 2, 4, 8, 16)
- SIMD-aware: Can generate SIMD-specific code patterns (infrastructure in place)
- Symbolic optimization: Built-in symbolic expression DAG for optimization passes
Procedural Macros
gen_notw_codelet!(size)— Non-twiddle base case codeletsgen_twiddle_codelet!(radix)— Twiddle-factor codelets for multi-radix FFTgen_simd_codelet!(size)— SIMD-optimized codelets (infrastructure, generation pending)gen_dft_codelet!(size)— Convenience wrapper (aliasesgen_notw_codelet!)
Codelet Types
Non-Twiddle Codelets (notw)
Base case FFT kernels that don't require twiddle factors. Used at the leaves of the FFT recursion.
use gen_notw_codelet;
// Generates codelet_notw_8 function
gen_notw_codelet!;
Twiddle Codelets
Codelets that apply twiddle factors as part of the Cooley-Tukey recursion.
use gen_twiddle_codelet;
// Generates codelet_twiddle_4
gen_twiddle_codelet!;
SIMD Codelets
SIMD-optimized codelets (infrastructure present, full generation pending).
use gen_simd_codelet;
// Generates SIMD-optimized size-8 codelet
gen_simd_codelet!;
Convenience Macro
use gen_dft_codelet;
// Currently aliases gen_notw_codelet!
gen_dft_codelet!;
Supported Sizes
| Size | Non-Twiddle | Twiddle | SIMD |
|---|---|---|---|
| 2 | ✓ | ✓ | Planned |
| 4 | ✓ | ✓ | Planned |
| 8 | ✓ | ✓ | Planned |
| 16 | ✓ | ✓ | Planned |
| 32 | ✓ | Planned | Planned |
| 64 | ✓ | Planned | Planned |
Code Generation Strategy
The codelet generator follows FFTW's approach:
- Symbolic representation: Build a DAG of FFT operations
- Optimization passes:
- Common subexpression elimination (CSE)
- Strength reduction (replace multiplications with additions where possible)
- Dead code elimination
- Code emission: Generate Rust code with optimal instruction ordering
Implementation Notes
- Uses
proc-macro2,quote, andsynfor macro implementation - Generated code is generic over the
Floattrait (f32/f64) - Follows FFTW's codelet naming conventions for compatibility
- All sizes 2–64 have generation infrastructure, with 2–16 fully implemented
- 8 tests passing
License
Apache-2.0 — Copyright (c) 2026 COOLJAPAN OU (Team Kitasan)