Skip to content

Commit

Permalink
Autogenerate entire prime butterfly files, rather than just chunks (#137
Browse files Browse the repository at this point in the history
)

* Created a rust tool to autogenerate the full SSE prime butterfly file

* Removed unnecessary include

* added prime-specific benches

* formatting fix

* Make template architecture-agnostic

* Added wasm simd prime butterfly benches

* wasm simd refactor: rename the non-newtype util methods to _v128

* Hook up wasm simd to use the prime butterfly generator

* add neon prime butterfly benchmarks

* Check in cargo.lock for gen_simd_butterflies

* Converted neon prime butterflies over to the autogenerated system and FMA

* Use the same testing feature detection as neon

* Delete gen_sse_butterflies.py

* Exclude wasm simd benchmarks from rustfmt

* Simplify the template by pre-packaging the struct names

* Simplified butterfly macro invocation by removing unused parameters

* Fix macro parameter

* Fix struct name

* Use handlebars templates to avoid preprocessing

* Added "--check" mode to the simd butterfly script

* Added a CI step to verify autogenerated code match

* Test new CI step by submitting mismatching code

* Back out test code, remove handlebars import
  • Loading branch information
ejmahler authored Mar 25, 2024
1 parent e9c4ec2 commit 801d6a4
Show file tree
Hide file tree
Showing 28 changed files with 14,102 additions and 19,175 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/run_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,23 @@ jobs:
- name: Run cargo fmt
run: cargo fmt -- --check

autogeneration:
name: Check Autogenerated Code Match
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install toolchain
uses: dtolnay/rust-toolchain@nightly

- name: Check SSE Prime Butterflies
run: cargo run --manifest-path ./tools/gen_simd_butterflies/Cargo.toml -- sse 7 11 13 17 19 23 29 31 --check src/sse/sse_prime_butterflies.rs
- name: Check NEON Prime Butterflies
run: cargo run --manifest-path ./tools/gen_simd_butterflies/Cargo.toml -- neon 7 11 13 17 19 23 29 31 --check src/neon/neon_prime_butterflies.rs
- name: Check Wasm SIMD Prime Butterflies
run: cargo run --manifest-path ./tools/gen_simd_butterflies/Cargo.toml -- wasm_simd 7 11 13 17 19 23 29 31 --check src/wasm_simd/wasm_simd_prime_butterflies.rs

check_no_features:
name: Check+Test no features
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/target
/Cargo.lock
Tools/gen_simd_butterflies/target
*.swp
.vscode/
19 changes: 19 additions & 0 deletions benches/bench_rustfft_neon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,25 @@ fn bench_planned_multi_f64(b: &mut Bencher, len: usize) {
#[bench] fn neon_butterfly32_31(b: &mut Bencher) { bench_planned_multi_f32(b, 31);}
#[bench] fn neon_butterfly32_32(b: &mut Bencher) { bench_planned_multi_f32(b, 32);}


#[bench] fn neon_prime_butterfly32_07(b: &mut Bencher) { bench_planned_multi_f32(b, 7);}
#[bench] fn neon_prime_butterfly32_11(b: &mut Bencher) { bench_planned_multi_f32(b, 11);}
#[bench] fn neon_prime_butterfly32_13(b: &mut Bencher) { bench_planned_multi_f32(b, 13);}
#[bench] fn neon_prime_butterfly32_17(b: &mut Bencher) { bench_planned_multi_f32(b, 17);}
#[bench] fn neon_prime_butterfly32_19(b: &mut Bencher) { bench_planned_multi_f32(b, 19);}
#[bench] fn neon_prime_butterfly32_23(b: &mut Bencher) { bench_planned_multi_f32(b, 23);}
#[bench] fn neon_prime_butterfly32_29(b: &mut Bencher) { bench_planned_multi_f32(b, 29);}
#[bench] fn neon_prime_butterfly32_31(b: &mut Bencher) { bench_planned_multi_f32(b, 31);}

#[bench] fn neon_prime_butterfly64_07(b: &mut Bencher) { bench_planned_multi_f64(b, 7);}
#[bench] fn neon_prime_butterfly64_11(b: &mut Bencher) { bench_planned_multi_f64(b, 11);}
#[bench] fn neon_prime_butterfly64_13(b: &mut Bencher) { bench_planned_multi_f64(b, 13);}
#[bench] fn neon_prime_butterfly64_17(b: &mut Bencher) { bench_planned_multi_f64(b, 17);}
#[bench] fn neon_prime_butterfly64_19(b: &mut Bencher) { bench_planned_multi_f64(b, 19);}
#[bench] fn neon_prime_butterfly64_23(b: &mut Bencher) { bench_planned_multi_f64(b, 23);}
#[bench] fn neon_prime_butterfly64_29(b: &mut Bencher) { bench_planned_multi_f64(b, 29);}
#[bench] fn neon_prime_butterfly64_31(b: &mut Bencher) { bench_planned_multi_f64(b, 31);}

#[bench] fn neon_butterfly64_02(b: &mut Bencher) { bench_planned_multi_f64(b, 2);}
#[bench] fn neon_butterfly64_03(b: &mut Bencher) { bench_planned_multi_f64(b, 3);}
#[bench] fn neon_butterfly64_04(b: &mut Bencher) { bench_planned_multi_f64(b, 4);}
Expand Down
18 changes: 18 additions & 0 deletions benches/bench_rustfft_sse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,24 @@ fn bench_planned_multi_f64(b: &mut Bencher, len: usize) {
#[bench] fn sse_butterfly64_31(b: &mut Bencher) { bench_planned_multi_f64(b, 31);}
#[bench] fn sse_butterfly64_32(b: &mut Bencher) { bench_planned_multi_f64(b, 32);}

// prime butterflies
#[bench] fn sse_prime_butterfly32_07(b: &mut Bencher) { bench_planned_multi_f32(b, 7);}
#[bench] fn sse_prime_butterfly32_11(b: &mut Bencher) { bench_planned_multi_f32(b, 11);}
#[bench] fn sse_prime_butterfly32_13(b: &mut Bencher) { bench_planned_multi_f32(b, 13);}
#[bench] fn sse_prime_butterfly32_17(b: &mut Bencher) { bench_planned_multi_f32(b, 17);}
#[bench] fn sse_prime_butterfly32_19(b: &mut Bencher) { bench_planned_multi_f32(b, 19);}
#[bench] fn sse_prime_butterfly32_23(b: &mut Bencher) { bench_planned_multi_f32(b, 23);}
#[bench] fn sse_prime_butterfly32_29(b: &mut Bencher) { bench_planned_multi_f32(b, 29);}
#[bench] fn sse_prime_butterfly32_31(b: &mut Bencher) { bench_planned_multi_f32(b, 31);}
#[bench] fn sse_prime_butterfly64_07(b: &mut Bencher) { bench_planned_multi_f64(b, 7);}
#[bench] fn sse_prime_butterfly64_11(b: &mut Bencher) { bench_planned_multi_f64(b, 11);}
#[bench] fn sse_prime_butterfly64_13(b: &mut Bencher) { bench_planned_multi_f64(b, 13);}
#[bench] fn sse_prime_butterfly64_17(b: &mut Bencher) { bench_planned_multi_f64(b, 17);}
#[bench] fn sse_prime_butterfly64_19(b: &mut Bencher) { bench_planned_multi_f64(b, 19);}
#[bench] fn sse_prime_butterfly64_23(b: &mut Bencher) { bench_planned_multi_f64(b, 23);}
#[bench] fn sse_prime_butterfly64_29(b: &mut Bencher) { bench_planned_multi_f64(b, 29);}
#[bench] fn sse_prime_butterfly64_31(b: &mut Bencher) { bench_planned_multi_f64(b, 31);}

// Powers of 2
#[bench] fn sse_planned32_p2_00000064(b: &mut Bencher) { bench_planned_f32(b, 64); }
#[bench] fn sse_planned32_p2_00000128(b: &mut Bencher) { bench_planned_f32(b, 128); }
Expand Down
18 changes: 18 additions & 0 deletions benches/bench_rustfft_wasm_simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,24 @@ fn wasm_simd_butterfly64_32(b: &mut Bencher) {
bench_planned_multi_f64(b, 32);
}

// prime butterflies
#[bench] fn wasm_simd_prime_butterfly32_07(b: &mut Bencher) { bench_planned_multi_f32(b, 7);}
#[bench] fn wasm_simd_prime_butterfly32_11(b: &mut Bencher) { bench_planned_multi_f32(b, 11);}
#[bench] fn wasm_simd_prime_butterfly32_13(b: &mut Bencher) { bench_planned_multi_f32(b, 13);}
#[bench] fn wasm_simd_prime_butterfly32_17(b: &mut Bencher) { bench_planned_multi_f32(b, 17);}
#[bench] fn wasm_simd_prime_butterfly32_19(b: &mut Bencher) { bench_planned_multi_f32(b, 19);}
#[bench] fn wasm_simd_prime_butterfly32_23(b: &mut Bencher) { bench_planned_multi_f32(b, 23);}
#[bench] fn wasm_simd_prime_butterfly32_29(b: &mut Bencher) { bench_planned_multi_f32(b, 29);}
#[bench] fn wasm_simd_prime_butterfly32_31(b: &mut Bencher) { bench_planned_multi_f32(b, 31);}
#[bench] fn wasm_simd_prime_butterfly64_07(b: &mut Bencher) { bench_planned_multi_f64(b, 7);}
#[bench] fn wasm_simd_prime_butterfly64_11(b: &mut Bencher) { bench_planned_multi_f64(b, 11);}
#[bench] fn wasm_simd_prime_butterfly64_13(b: &mut Bencher) { bench_planned_multi_f64(b, 13);}
#[bench] fn wasm_simd_prime_butterfly64_17(b: &mut Bencher) { bench_planned_multi_f64(b, 17);}
#[bench] fn wasm_simd_prime_butterfly64_19(b: &mut Bencher) { bench_planned_multi_f64(b, 19);}
#[bench] fn wasm_simd_prime_butterfly64_23(b: &mut Bencher) { bench_planned_multi_f64(b, 23);}
#[bench] fn wasm_simd_prime_butterfly64_29(b: &mut Bencher) { bench_planned_multi_f64(b, 29);}
#[bench] fn wasm_simd_prime_butterfly64_31(b: &mut Bencher) { bench_planned_multi_f64(b, 31);}

// Powers of 2
#[bench]
fn wasm_simd_planned32_p2_00000064(b: &mut Bencher) {
Expand Down
8 changes: 6 additions & 2 deletions rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ ignore = [
"benches/bench_rustfft.rs",
"benches/bench_rustfft_sse.rs",
"benches/bench_rustfft_neon.rs",
"benches/bench_rustfft_wasm_simd.rs",
"benches/bench_compare_scalar_neon.rs",

# disable the prime butterfly files because they're autogenerated
"src/sse/sse_prime_butterflies.rs",
"src/neon/neon_prime_butterflies.rs",
"benches/bench_compare_scalar_neon.rs",
]
"src/wasm_simd/wasm_simd_prime_butterflies.rs",
]

Loading

0 comments on commit 801d6a4

Please sign in to comment.