Skip to content

Commit

Permalink
Better FFT sizes for large inputs.
Browse files Browse the repository at this point in the history
benchmark                old ns/op    new ns/op    delta
BenchmarkMulFFT_20Mb    1137847000   1116964000   -1.84%
BenchmarkMulFFT_50Mb    3056503000   2913291000   -4.69%
BenchmarkMulFFT_100Mb   8142517000   5962457000  -26.77%
  • Loading branch information
Rémy Oudompheng committed Aug 20, 2012
1 parent d652e8b commit 4382f52
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
26 changes: 13 additions & 13 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ Number size old ns/op new ns/op delta
1kb 1599 1668 +4.32%
10kb 61533 62427 +1.45%
100kb 2567995 2683862 +4.51%
1Mb 105237800 33648160 -68.03%
5Mb 1272947000 219950000 -82.72%
10Mb 3834354000 578960600 -84.90%
20Mb 11514488000 1219312000 -89.41%
50Mb 49199945000 3203904000 -93.49%
100Mb 147599836000 8546686000 -94.21%
1Mb 105237800 28586820 -72.84%
5Mb 1272947000 195314800 -84.66%
10Mb 3834354000 404398400 -89.45%
20Mb 11514488000 1116964000 -90.30%
50Mb 49199945000 2913291000 -94.08%
100Mb 147599836000 5962457000 -95.96%

Benchmarking GMP vs bigfft

Number size GMP ns/op Go ns/op delta
1kb 536 1668 +211.19%
10kb 26669 62427 +134.08%
100kb 686813 2683862 +290.77%
1Mb 12100000 33648160 +178.08%
5Mb 111731843 219950000 +96.86%
10Mb 212314000 578960600 +172.69%
20Mb 490196000 1219312000 +148.74%
50Mb 1280000000 3203904000 +150.31%
100Mb 2673000000 8546686000 +219.74%

1Mb 12100000 28586820 +136.25%
5Mb 111731843 195314800 +74.81%
10Mb 212314000 404398400 +90.47%
20Mb 490196000 1116964000 +127.86%
50Mb 1280000000 2913291000 +127.60%
100Mb 2673000000 5962457000 +123.06%
Benchmarks were run on a Core 2 Quad Q8200 (2.33GHz).
FFT is enabled when input numbers are over 200kbits.
18 changes: 9 additions & 9 deletions benchmarks/bench.fft
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Benchmarks using the mulFFT function only.
BenchmarkMul_1kb 50000 31247 ns/op
BenchmarkMul_10kb 5000 311773 ns/op
BenchmarkMul_100kb 1000 2745436 ns/op
BenchmarkMul_1Mb 50 29235680 ns/op
BenchmarkMul_5Mb 10 198136700 ns/op
BenchmarkMul_10Mb 5 522288600 ns/op
BenchmarkMul_20Mb 1 1125621000 ns/op
BenchmarkMul_50Mb 1 2942162000 ns/op
BenchmarkMul_100Mb 1 8000678000 ns/op
BenchmarkMul_1kb 100000 28712 ns/op
BenchmarkMul_10kb 10000 294135 ns/op
BenchmarkMul_100kb 1000 2659472 ns/op
BenchmarkMul_1Mb 50 28586820 ns/op
BenchmarkMul_5Mb 10 195314800 ns/op
BenchmarkMul_10Mb 5 404398400 ns/op
BenchmarkMul_20Mb 1 1116964000 ns/op
BenchmarkMul_50Mb 1 2913291000 ns/op
BenchmarkMul_100Mb 1 5962457000 ns/op

4 changes: 2 additions & 2 deletions fft.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ func fftmul(x, y nat) nat {
// fft size i.
var fftSizeThreshold = [...]int64{0, 0, 0,
4 << 10, 8 << 10, 16 << 10, // 5
32 << 10, 64 << 10, 1 << 18, 1 << 20, 1 << 22, // 10
1 << 24, 1 << 26, 1 << 28, 1 << 30,
32 << 10, 64 << 10, 1 << 18, 1 << 20, 3 << 20, // 10
16 << 20, 50 << 20, 160 << 20, 500 << 20, 2 << 30,
}

// returns the FFT length k, m the number of words per chunk
Expand Down
1 change: 1 addition & 0 deletions fft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func TestFourierSizes(t *testing.T) {
2e5, 3e5, 5e5, 7e5, 10e5, 14e5,
2e6, 3e6, 5e6, 7e6, 10e6, 14e6,
2e7, 3e7, 5e7, 7e7, 10e7, 14e7,
2e8, 3e8, 5e8, 7e8, 10e8, 14e8,
}
for _, s := range sizes {
k, m := fftSize(make(nat, s/_W), make(nat, s/_W))
Expand Down

0 comments on commit 4382f52

Please sign in to comment.