Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functions to support interleaved complex num #27

Merged
merged 27 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
21d77db
Add a function to separate AoS to SoA
smu160 Apr 30, 2024
58374f1
Fix formatting
smu160 Apr 30, 2024
59de096
Add reverse separate fn and add test
smu160 May 1, 2024
a716cd7
Add fft_*_interleaved impls and tests
smu160 May 1, 2024
ecca75b
Fix formatting
smu160 May 1, 2024
23c1d21
Simplify separate_re_im
Shnatsel May 3, 2024
13fe64c
Update docs for interleaved fft
smu160 May 8, 2024
a0d2822
Transition `num-complex` dependency to optional
smu160 May 8, 2024
05713ff
Fix formatting
smu160 May 8, 2024
2923d53
Merge branch 'main' into feature/interleaved-complex-nums
smu160 May 8, 2024
1377ead
Fix formatting
smu160 May 8, 2024
9699f9e
Vectorize deinterleaving of AoS --> SoA
smu160 May 22, 2024
4d43190
Put macro definition begind feature flag
smu160 May 22, 2024
356e468
Fix formatting
smu160 May 22, 2024
fbb1bad
Remove index tracker from hot path
smu160 May 22, 2024
3957834
Add benchmark using criterion
smu160 May 22, 2024
b429a32
Fix formatting
smu160 May 22, 2024
b8affb2
Account for different signal sizes
smu160 May 22, 2024
c7856d0
Merge branch 'main' into feature/interleaved-complex-nums
smu160 May 22, 2024
f639900
Merge branch 'main' into feature/interleaved-complex-nums
smu160 Jun 27, 2024
5c09b89
Merge branch 'main' into feature/interleaved-complex-nums
smu160 Jul 14, 2024
98503e9
Add new python benchmarking "framework"
smu160 Jul 14, 2024
a201e2c
Update todo
smu160 Jul 14, 2024
403684b
Make examples output time elapsed in nanoseconds
smu160 Jul 14, 2024
1343268
Remove `array_chunks`
smu160 Jul 14, 2024
e94f2fc
Use new de-interleaving function
smu160 Jul 17, 2024
713b3a6
Update pre-commit hook to run clippy everywhere
smu160 Jul 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features

coverage:
runs-on: ubuntu-latest
Expand Down
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ exclude = ["assets", "scripts", "benches"]
[dependencies]
num-traits = "0.2.18"
multiversion = "0.7"
num-complex = { version = "0.4.6", features = ["bytemuck"], optional = true }
bytemuck = { version = "1.16.0", optional = true }

[features]
default = []
complex-nums = ["dep:num-complex", "dep:bytemuck"]

[dev-dependencies]
criterion = "0.5.1"
Expand All @@ -33,3 +39,5 @@ panic = "abort"
inherits = "release"
debug = true

[package.metadata.docs.rs]
all-features = true
26 changes: 5 additions & 21 deletions benches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,26 @@

### Setup Environment

1. Install [FFTW3](http://www.fftw.org/download.html)[^1]
1. Clone the `PhastFT` git repository [^2].

It may be possible to install `fftw3` using a package manager.

##### debian
```bash
sudo apt install libfftw3-dev
```

2. Clone the `PhastFT` git repository [^2].

3. Create virtual env
2. Create virtual env

```bash
cd ~/PhastFT/benches && python3 -m venv .env && source .env/bin/activate
```

4. Install python dependencies[^1]
3. Install python dependencies[^1]

```bash
pip install -r requirements.txt
cd ~/PhastFT/pyphastft
pip install .
```

5. Run the `FFTW3` vs. `RustFFT` vs. `PhastFT` benchmark for all inputs of size `2^n`, where `n \in [4, 30].`
5. Run the `FFTW3-RB` vs. `RustFFT` vs. `PhastFT` benchmarks`

```bash
./benchmark.sh 4 29
python run_benches.py
```

6. Plot the results
Expand Down Expand Up @@ -101,13 +92,6 @@ On linux, open access to performance monitoring, and observability operations fo
echo -1 | sudo tee /proc/sys/kernel/perf_event_paranoid
```

Add debug to `Cargo.toml` under `profile.release`:

```bash
[profile.release]
debug = true
```

Finally, run:

```bash
Expand Down
53 changes: 37 additions & 16 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use utilities::rustfft::num_complex::Complex;
use utilities::rustfft::FftPlanner;

const LENGTHS: &[usize] = &[
6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
];

fn generate_numbers<T: Float>(n: usize) -> (Vec<T>, Vec<T>)
Expand Down Expand Up @@ -69,7 +69,7 @@ fn benchmark_forward_f32(c: &mut Criterion) {
let planner = Planner32::new(len, Direction::Forward);
let (mut reals, mut imags) = generate_numbers(len);

group.bench_with_input(BenchmarkId::new(id, len), &len, |b, &len| {
group.bench_with_input(BenchmarkId::new(id, len), &len, |b, &_len| {
b.iter(|| {
fft_32_with_opts_and_plan(
black_box(&mut reals),
Expand All @@ -85,7 +85,7 @@ fn benchmark_forward_f32(c: &mut Criterion) {
let fft = planner.plan_fft_forward(len);
let mut signal = generate_complex_numbers(len);

group.bench_with_input(BenchmarkId::new(id, len), &len, |b, &len| {
group.bench_with_input(BenchmarkId::new(id, len), &len, |b, &_len| {
b.iter(|| fft.process(black_box(&mut signal)));
});
}
Expand All @@ -103,31 +103,49 @@ fn benchmark_inverse_f32(c: &mut Criterion) {
c.bench_function(&id, |b| {
let (mut reals, mut imags) = generate_numbers(len);
b.iter(|| {
black_box(fft_32_with_opts_and_plan(
&mut reals, &mut imags, &options, &planner,
));
fft_32_with_opts_and_plan(
black_box(&mut reals),
black_box(&mut imags),
black_box(&options),
black_box(&planner),
);
});
});
}
}

fn benchmark_forward_f64(c: &mut Criterion) {
let options = Options::default();
let mut group = c.benchmark_group("Forward f64");

for n in LENGTHS.iter() {
let len = 1 << n;
let id = format!("FFT Forward f64 {} elements", len);
let id = "PhastFT FFT Forward";
let options = Options::guess_options(len);
let planner = Planner64::new(len, Direction::Forward);
let (mut reals, mut imags) = generate_numbers(len);
group.throughput(Throughput::Elements(len as u64));

c.bench_function(&id, |b| {
let (mut reals, mut imags) = generate_numbers(len);
group.bench_with_input(BenchmarkId::new(id, len), &len, |b, &_len| {
b.iter(|| {
black_box(fft_64_with_opts_and_plan(
&mut reals, &mut imags, &options, &planner,
));
fft_64_with_opts_and_plan(
black_box(&mut reals),
black_box(&mut imags),
black_box(&options),
black_box(&planner),
);
});
});

let id = "RustFFT FFT Forward";
let mut planner = FftPlanner::<f64>::new();
let fft = planner.plan_fft_forward(len);
let mut signal = generate_complex_numbers(len);

group.bench_with_input(BenchmarkId::new(id, len), &len, |b, &_len| {
b.iter(|| fft.process(black_box(&mut signal)));
});
}
group.finish();
}

fn benchmark_inverse_f64(c: &mut Criterion) {
Expand All @@ -141,9 +159,12 @@ fn benchmark_inverse_f64(c: &mut Criterion) {
c.bench_function(&id, |b| {
let (mut reals, mut imags) = generate_numbers(len);
b.iter(|| {
black_box(fft_64_with_opts_and_plan(
&mut reals, &mut imags, &options, &planner,
));
fft_64_with_opts_and_plan(
black_box(&mut reals),
black_box(&mut imags),
black_box(&options),
black_box(&planner),
);
});
});
}
Expand Down
Loading
Loading