4 releases
| new 0.1.3 | Feb 12, 2026 |
|---|---|
| 0.1.2 | Jan 26, 2026 |
| 0.1.1 | Jan 15, 2026 |
| 0.1.0 | Jan 12, 2026 |
#107 in #fft
49 downloads per month
Used in 3 crates
(via oxifft)
46KB
965 lines
oxifft-codegen
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
- Optimized kernels: Common subexpression elimination, strength reduction
- Multiple sizes: Support for sizes 2, 4, 8, 16, 32, 64
- Twiddle variants: Both non-twiddle (base case) and twiddle codelets
- SIMD-aware: Can generate SIMD-specific code patterns
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 oxifft_codegen::gen_notw_codelet;
// Generates codelet_notw_8 function
gen_notw_codelet!(8);
Twiddle Codelets
FFT kernels that apply twiddle factors as part of the Cooley-Tukey recursion.
use oxifft_codegen::gen_twiddle_codelet;
// Generates codelet_twiddle_4 function
gen_twiddle_codelet!(4);
SIMD Codelets
Architecture-specific SIMD-optimized kernels.
use oxifft_codegen::gen_simd_codelet;
// Generates SIMD-optimized size-8 codelet
gen_simd_codelet!(8);
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
Supported Sizes
| Size | Non-Twiddle | Twiddle | SIMD |
|---|---|---|---|
| 2 | ✓ | ✓ | Planned |
| 4 | ✓ | ✓ | Planned |
| 8 | ✓ | ✓ | Planned |
| 16 | ✓ | Planned | Planned |
| 32 | ✓ | Planned | Planned |
| 64 | ✓ | Planned | Planned |
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
License
Same as the parent OxiFFT project.
Dependencies
~125–510KB
~12K SLoC