Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR makes the BitReverse function generic by moving it from field-specific packages to a centralized utils package, allowing it to work with any type while maintaining performance optimizations. The function now accepts func BitReverse[T any](v []T) instead of being tied to specific field element types.
- Move BitReverse implementation from field-specific fft packages to utils/bitreverse.go as a generic function
- Update all references throughout the codebase to use
utils.BitReverseinstead offft.BitReverse - Remove field-specific bitreverse.go and bitreverse_test.go files that are no longer needed
Reviewed Changes
Copilot reviewed 125 out of 125 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| utils/bitreverse.go | New generic BitReverse implementation with performance optimizations |
| utils/bitreverse_test.go | Comprehensive tests for the generic BitReverse function |
| Multiple fft packages | Removal of field-specific bitreverse implementations |
| Multiple files | Updated import statements and function calls to use utils.BitReverse |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| } else { | ||
| bitReverseNaive(v) | ||
| } | ||
| bitReverseCobraInPlace(v) |
There was a problem hiding this comment.
Bug: BitReverse Function Fallback Issue
The bitReverseCobra function's default case no longer falls back to bitReverseNaive for small input sizes. This makes the len(v) < (1<<21) check in the top-level BitReverse function essential. Without it, small inputs would incorrectly use bitReverseCobraInPlace, which may lead to performance regressions.
Description
BitReverseis now generic. With tweaks, benchmarks are actually slightly faster (tested on c7a.8xlarge for koalabear and bls12377),, and faster for most sizes on koalabear E4: