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

⬆️ deps: update argminmax to 0.6.1 #56

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
80b999f
⬆️ deps: update argminmax to 0.6.1
NielsPraet Jul 26, 2023
f371df6
♻️ refactor: use rust slices in searchsorted.rs
NielsPraet Jul 26, 2023
3442ca6
♻️ refactor: use slices in m4 generic
NielsPraet Jul 27, 2023
b25df82
♻️ tests: fix m4 refactor
NielsPraet Jul 27, 2023
21e2794
♻️ tests: refactor lttb to slices
NielsPraet Jul 27, 2023
2b46ee7
♻️ tests: refactor minmax to slices
NielsPraet Jul 27, 2023
50f2d61
♻️ tests: refactor minmaxlttb to slices
NielsPraet Jul 27, 2023
72c868c
🎨 chore: cleanup code
NielsPraet Jul 28, 2023
cf7cb7a
🐛 fix: fix rust to python bindings
NielsPraet Jul 28, 2023
d1dccca
🎨 chore: remove unused variable
NielsPraet Jul 28, 2023
ec2cba0
🐛 fix: fix benchmark code
NielsPraet Jul 28, 2023
3f3877e
🔥 chore: remove Average implementation for ndarray structs
NielsPraet Jul 28, 2023
3b963b9
⏪️ chore: revert changes
NielsPraet Jul 28, 2023
c958645
♻️ refactor: remove last dependencies of ndarray
NielsPraet Jul 28, 2023
3b4b65a
➖ deps: remove ndarray dependencies
NielsPraet Jul 28, 2023
fb42622
:broom: remove unnecessary f16 import
jvdd Jul 28, 2023
b279496
🎨 chore: remove useless trait bounds
NielsPraet Jul 31, 2023
7925f21
♻️ refactor: clean up m4 code
NielsPraet Jul 31, 2023
01936a6
🏗️ fix: update lib to reflect m4 file changes
NielsPraet Jul 31, 2023
7c3f72f
♻️ refactor: clean up minmax code
NielsPraet Jul 31, 2023
af57dcf
🏗️ fix: update lib to reflect minmax file changes
NielsPraet Jul 31, 2023
8e4dd74
♻️ refactor: add new minmax file
NielsPraet Jul 31, 2023
4c47705
✅ tests: fix benchmarks
NielsPraet Jul 31, 2023
ea4828c
✅ tests: fix benchmarks for minmax
NielsPraet Jul 31, 2023
eae0693
♻️ refactor: refactor minmaxlttb files
NielsPraet Jul 31, 2023
8179bb1
🏗️ refactor: update lib to reflect changes to minmaxlttb files
NielsPraet Jul 31, 2023
f1f5883
✅ tests: fix benchmarks for minmaxlttb
NielsPraet Jul 31, 2023
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
3 changes: 1 addition & 2 deletions downsample_rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ license = "MIT"

[dependencies]
# TODO: perhaps use polars?
ndarray = {version = "0.15.6", default-features = false, features = ["rayon"] }
argminmax = { version = "0.3.1", features = ["half"] }
argminmax = { version = "0.6.1", features = ["half"] }
# argminmax = { path = "../../argminmax" , features = ["half", "ndarray"] }
half = { version = "2.1", default-features = false , features=["num-traits"], optional = true}
num-traits = { version = "0.2.15", default-features = false }
Expand Down
25 changes: 18 additions & 7 deletions downsample_rs/benches/bench_lttb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,48 @@ use downsample_rs::lttb as lttb_mod;

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use dev_utils::{config, utils};
use ndarray::Array1;

fn lttb_f32_random_array_long(c: &mut Criterion) {
let n = config::ARRAY_LENGTH_LONG;
let x = Array1::from((0..n).map(|i| i as i32).collect::<Vec<i32>>());
let x = (0..n).map(|i| i as i32).collect::<Vec<i32>>();
let y = utils::get_random_array::<f32>(n, f32::MIN, f32::MAX);
c.bench_function("lttb_scalx_f32", |b| {
b.iter(|| lttb_mod::lttb_with_x(black_box(x.view()), black_box(y.view()), black_box(2_000)))
b.iter(|| {
lttb_mod::lttb_with_x(
black_box(x.as_slice()),
black_box(y.as_slice()),
black_box(2_000),
)
})
});
}
fn lttb_f32_random_array_50m(c: &mut Criterion) {
let n = 50_000_000;
let x = Array1::from((0..n).map(|i| i as i32).collect::<Vec<i32>>());
let x = (0..n).map(|i| i as i32).collect::<Vec<i32>>();
let y = utils::get_random_array::<f32>(n, f32::MIN, f32::MAX);
c.bench_function("lttb_scalx_50M_f32", |b| {
b.iter(|| lttb_mod::lttb_with_x(black_box(x.view()), black_box(y.view()), black_box(2_000)))
b.iter(|| {
lttb_mod::lttb_with_x(
black_box(x.as_slice()),
black_box(y.as_slice()),
black_box(2_000),
)
})
});
}

fn lttb_without_x_f32_random_array_long(c: &mut Criterion) {
let n = config::ARRAY_LENGTH_LONG;
let y = utils::get_random_array::<f32>(n, f32::MIN, f32::MAX);
c.bench_function("lttb_scal_f32", |b| {
b.iter(|| lttb_mod::lttb_without_x(black_box(y.view()), black_box(2_000)))
b.iter(|| lttb_mod::lttb_without_x(black_box(y.as_slice()), black_box(2_000)))
});
}
fn lttb_without_x_f32_random_array_50m(c: &mut Criterion) {
let n = 50_000_000;
let y = utils::get_random_array::<f32>(n, f32::MIN, f32::MAX);
c.bench_function("lttb_scal_50M_f32", |b| {
b.iter(|| lttb_mod::lttb_without_x(black_box(y.view()), black_box(2_000)))
b.iter(|| lttb_mod::lttb_without_x(black_box(y.as_slice()), black_box(2_000)))
});
}

Expand Down
43 changes: 21 additions & 22 deletions downsample_rs/benches/bench_m4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ use downsample_rs::m4 as m4_mod;

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use dev_utils::{config, utils};
use ndarray::Array1;

fn m4_f32_random_array_long_single_core(c: &mut Criterion) {
let n = config::ARRAY_LENGTH_LONG;
let data = utils::get_random_array::<f32>(n, f32::MIN, f32::MAX);
c.bench_function("m4_scal_f32", |b| {
b.iter(|| m4_mod::m4_scalar_without_x(black_box(data.view()), black_box(2_000)))
b.iter(|| m4_mod::m4_scalar_without_x(black_box(data.as_slice()), black_box(2_000)))
});
c.bench_function("m4_simd_f32", |b| {
b.iter(|| m4_mod::m4_simd_without_x(black_box(data.view()), black_box(2_000)))
b.iter(|| m4_mod::m4_simd_without_x(black_box(data.as_slice()), black_box(2_000)))
});
}

Expand All @@ -22,7 +21,7 @@ fn m4_f32_random_array_long_multi_core(c: &mut Criterion) {
c.bench_function("m4_scal_p_f32", |b| {
b.iter(|| {
m4_mod::m4_scalar_without_x_parallel(
black_box(data.view()),
black_box(data.as_slice()),
black_box(2_000),
black_box(all_threads),
)
Expand All @@ -31,7 +30,7 @@ fn m4_f32_random_array_long_multi_core(c: &mut Criterion) {
c.bench_function("m4_simd_p_f32", |b| {
b.iter(|| {
m4_mod::m4_simd_without_x_parallel(
black_box(data.view()),
black_box(data.as_slice()),
black_box(2_000),
black_box(all_threads),
)
Expand All @@ -42,27 +41,27 @@ fn m4_f32_random_array_long_multi_core(c: &mut Criterion) {
fn m4_f32_random_array_50M_single_core(c: &mut Criterion) {
let n = 50_000_000;
let data = utils::get_random_array::<f32>(n, f32::MIN, f32::MAX);
let x = Array1::from((0..n).map(|i| i as i32).collect::<Vec<i32>>());
let x = (0..n).map(|i| i as i32).collect::<Vec<i32>>();
c.bench_function("m4_scal_50M_f32", |b| {
b.iter(|| m4_mod::m4_scalar_without_x(black_box(data.view()), black_box(2_000)))
b.iter(|| m4_mod::m4_scalar_without_x(black_box(data.as_slice()), black_box(2_000)))
});
c.bench_function("m4_simd_50M_f32", |b| {
b.iter(|| m4_mod::m4_simd_without_x(black_box(data.view()), black_box(2_000)))
b.iter(|| m4_mod::m4_simd_without_x(black_box(data.as_slice()), black_box(2_000)))
});
c.bench_function("m4_scalx_50M_f32", |b| {
b.iter(|| {
m4_mod::m4_scalar_with_x(
black_box(x.view()),
black_box(data.view()),
black_box(x.as_slice()),
black_box(data.as_slice()),
black_box(2_000),
)
})
});
c.bench_function("m4_simdx_50M_f32", |b| {
b.iter(|| {
m4_mod::m4_simd_with_x(
black_box(x.view()),
black_box(data.view()),
black_box(x.as_slice()),
black_box(data.as_slice()),
black_box(2_000),
)
})
Expand All @@ -72,12 +71,12 @@ fn m4_f32_random_array_50M_single_core(c: &mut Criterion) {
fn m4_f32_random_array_50M_multi_core(c: &mut Criterion) {
let n = 50_000_000;
let data = utils::get_random_array::<f32>(n, f32::MIN, f32::MAX);
let x = Array1::from((0..n).map(|i| i as i32).collect::<Vec<i32>>());
let x = (0..n).map(|i| i as i32).collect::<Vec<i32>>();
let all_threads: usize = utils::get_all_threads();
c.bench_function("m4_scal_p_50M_f32", |b| {
b.iter(|| {
m4_mod::m4_scalar_without_x_parallel(
black_box(data.view()),
black_box(data.as_slice()),
black_box(2_000),
black_box(all_threads),
)
Expand All @@ -86,7 +85,7 @@ fn m4_f32_random_array_50M_multi_core(c: &mut Criterion) {
c.bench_function("m4_simd_p_50M_f32", |b| {
b.iter(|| {
m4_mod::m4_simd_without_x_parallel(
black_box(data.view()),
black_box(data.as_slice()),
black_box(2_000),
black_box(all_threads),
)
Expand All @@ -95,8 +94,8 @@ fn m4_f32_random_array_50M_multi_core(c: &mut Criterion) {
c.bench_function("m4_scalx_p_50M_f32", |b| {
b.iter(|| {
m4_mod::m4_scalar_with_x_parallel(
black_box(x.view()),
black_box(data.view()),
black_box(x.as_slice()),
black_box(data.as_slice()),
black_box(2_000),
black_box(all_threads),
)
Expand All @@ -105,8 +104,8 @@ fn m4_f32_random_array_50M_multi_core(c: &mut Criterion) {
c.bench_function("m4_simdx_p_50M_f32", |b| {
b.iter(|| {
m4_mod::m4_simd_with_x_parallel(
black_box(x.view()),
black_box(data.view()),
black_box(x.as_slice()),
black_box(data.as_slice()),
black_box(2_000),
black_box(all_threads),
)
Expand All @@ -118,13 +117,13 @@ fn m4_f32_random_array_50M_multi_core(c: &mut Criterion) {
// let n = config::ARRAY_LENGTH_LONG;
// let data = utils::get_worst_case_array::<f32>(n, 1.0);
// c.bench_function("overlap_worst_long_f32", |b| {
// b.iter(|| minmax_mod::min_max_overlap(black_box(data.view()), black_box(2_000)))
// b.iter(|| minmax_mod::min_max_overlap(black_box(data.as_slice()), black_box(2_000)))
// });
// c.bench_function("simple_worst_long_f32", |b| {
// b.iter(|| minmax_mod::min_max(black_box(data.view()), black_box(2_000)))
// b.iter(|| minmax_mod::min_max(black_box(data.as_slice()), black_box(2_000)))
// });
// c.bench_function("simd_worst_long_f32", |b| {
// b.iter(|| minmax_mod::min_max_simd_f32(black_box(data.view()), black_box(2_000)))
// b.iter(|| minmax_mod::min_max_simd_f32(black_box(data.as_slice()), black_box(2_000)))
// });
// }

Expand Down
49 changes: 26 additions & 23 deletions downsample_rs/benches/bench_minmax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ use downsample_rs::minmax as minmax_mod;

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use dev_utils::{config, utils};
use ndarray::Array1;

fn minmax_f32_random_array_long_single_core(c: &mut Criterion) {
let n = config::ARRAY_LENGTH_LONG;
let data = utils::get_random_array::<f32>(n, f32::MIN, f32::MAX);
c.bench_function("minmax_scal_f32", |b| {
b.iter(|| minmax_mod::min_max_scalar_without_x(black_box(data.view()), black_box(2_000)))
b.iter(|| {
minmax_mod::min_max_scalar_without_x(black_box(data.as_slice()), black_box(2_000))
})
});
c.bench_function("minmax_simd_f32", |b| {
b.iter(|| minmax_mod::min_max_simd_without_x(black_box(data.view()), black_box(2_000)))
b.iter(|| minmax_mod::min_max_simd_without_x(black_box(data.as_slice()), black_box(2_000)))
});
}

Expand All @@ -22,7 +23,7 @@ fn minmax_f32_random_array_long_multi_core(c: &mut Criterion) {
c.bench_function("minmax_scal_p_f32", |b| {
b.iter(|| {
minmax_mod::min_max_scalar_without_x_parallel(
black_box(data.view()),
black_box(data.as_slice()),
black_box(2_000),
black_box(all_threads),
)
Expand All @@ -31,7 +32,7 @@ fn minmax_f32_random_array_long_multi_core(c: &mut Criterion) {
c.bench_function("minmax_simd_p_f32", |b| {
b.iter(|| {
minmax_mod::min_max_simd_without_x_parallel(
black_box(data.view()),
black_box(data.as_slice()),
black_box(2_000),
black_box(all_threads),
)
Expand All @@ -42,55 +43,57 @@ fn minmax_f32_random_array_long_multi_core(c: &mut Criterion) {
fn minmax_f32_random_array_50M_single_core(c: &mut Criterion) {
let n = 50_000_000;
let data = utils::get_random_array::<f32>(n, f32::MIN, f32::MAX);
let x = Array1::from((0..n).map(|i| i as i32).collect::<Vec<i32>>());
let x = (0..n).map(|i| i as i32).collect::<Vec<i32>>();
c.bench_function("minmax_scal_50M_f32", |b| {
b.iter(|| minmax_mod::min_max_scalar_without_x(black_box(data.view()), black_box(2_000)))
b.iter(|| {
minmax_mod::min_max_scalar_without_x(black_box(data.as_slice()), black_box(2_000))
})
});
c.bench_function("minmax_simd_50M_f32", |b| {
b.iter(|| minmax_mod::min_max_simd_without_x(black_box(data.view()), black_box(2_000)))
b.iter(|| minmax_mod::min_max_simd_without_x(black_box(data.as_slice()), black_box(2_000)))
});
c.bench_function("minmax_scalx_50M_f32", |b| {
b.iter(|| {
minmax_mod::min_max_scalar_with_x(
black_box(x.view()),
black_box(data.view()),
black_box(x.as_slice()),
black_box(data.as_slice()),
black_box(2_000),
)
})
});
c.bench_function("minmax_simdx_50M_f32", |b| {
b.iter(|| {
minmax_mod::min_max_simd_with_x(
black_box(x.view()),
black_box(data.view()),
black_box(x.as_slice()),
black_box(data.as_slice()),
black_box(2_000),
)
})
});

// c.bench_function("minmax_scal_50M_f32", |b| {
// b.iter(|| minmax_mod::min_max_scalar_without_x(black_box(data.view()), black_box(60_000)))
// b.iter(|| minmax_mod::min_max_scalar_without_x(black_box(data.as_slice()), black_box(60_000)))
// });
// c.bench_function("minmax_simd_50M_f32", |b| {
// b.iter(|| minmax_mod::min_max_simd_without_x(black_box(data.view()), black_box(60_000)))
// b.iter(|| minmax_mod::min_max_simd_without_x(black_box(data.as_slice()), black_box(60_000)))
// });
// c.bench_function("minmax_scalx_50M_f32", |b| {
// b.iter(|| minmax_mod::min_max_scalar_with_x(black_box(x.view()), black_box(data.view()), black_box(60_000)))
// b.iter(|| minmax_mod::min_max_scalar_with_x(black_box(x.as_slice()), black_box(data.view()), black_box(60_000)))
// });
// c.bench_function("minmax_simdx_50M_f32", |b| {
// b.iter(|| minmax_mod::min_max_simd_with_x(black_box(x.view()), black_box(data.view()), black_box(60_000)))
// b.iter(|| minmax_mod::min_max_simd_with_x(black_box(x.as_slice()), black_box(data.view()), black_box(60_000)))
// });
}

fn minmax_f32_random_array_50M_long_multi_core(c: &mut Criterion) {
let n = 50_000_000;
let data = utils::get_random_array::<f32>(n, f32::MIN, f32::MAX);
let x = Array1::from((0..n).map(|i| i as i32).collect::<Vec<i32>>());
let x = (0..n).map(|i| i as i32).collect::<Vec<i32>>();
let all_threads: usize = utils::get_all_threads();
c.bench_function("minmax_scal_p_50M_f32", |b| {
b.iter(|| {
minmax_mod::min_max_scalar_without_x_parallel(
black_box(data.view()),
black_box(data.as_slice()),
black_box(2_000),
black_box(all_threads),
)
Expand All @@ -99,7 +102,7 @@ fn minmax_f32_random_array_50M_long_multi_core(c: &mut Criterion) {
c.bench_function("minmax_simd_p_50M_f32", |b| {
b.iter(|| {
minmax_mod::min_max_simd_without_x_parallel(
black_box(data.view()),
black_box(data.as_slice()),
black_box(2_000),
black_box(all_threads),
)
Expand All @@ -108,8 +111,8 @@ fn minmax_f32_random_array_50M_long_multi_core(c: &mut Criterion) {
c.bench_function("minmax_scalx_p_50M_f32", |b| {
b.iter(|| {
minmax_mod::min_max_scalar_with_x_parallel(
black_box(x.view()),
black_box(data.view()),
black_box(x.as_slice()),
black_box(data.as_slice()),
black_box(2_000),
black_box(all_threads),
)
Expand All @@ -118,8 +121,8 @@ fn minmax_f32_random_array_50M_long_multi_core(c: &mut Criterion) {
c.bench_function("minmax_simdx_p_50M_f32", |b| {
b.iter(|| {
minmax_mod::min_max_simd_with_x_parallel(
black_box(x.view()),
black_box(data.view()),
black_box(x.as_slice()),
black_box(data.as_slice()),
black_box(2_000),
black_box(all_threads),
)
Expand Down
Loading