Skip to content

Commit

Permalink
⬆️ deps: update argminmax to 0.6.1 (#57)
Browse files Browse the repository at this point in the history
* ⬆️ deps: update argminmax to 0.6.1

* ♻️ refactor: use rust slices in searchsorted.rs

* ♻️ refactor: use slices in m4 generic

* ♻️ tests: fix m4 refactor

* ♻️ tests: refactor lttb to slices

* ♻️ tests: refactor minmax to slices

* ♻️ tests: refactor minmaxlttb to slices

* 🎨 chore: cleanup code

* 🐛 fix: fix rust to python bindings

* 🎨 chore: remove unused variable

* 🐛 fix: fix benchmark code

* 🔥 chore: remove Average implementation for ndarray structs

* ⏪️ chore: revert changes

* ♻️ refactor: remove last dependencies of ndarray

* ➖ deps: remove ndarray dependencies

* 🧹 remove unnecessary f16 import

* 🎨 chore: remove useless trait bounds

* ♻️ refactor: clean up m4 code

* 🏗️ fix: update lib to reflect m4 file changes

* ♻️ refactor: clean up minmax code

* 🏗️ fix: update lib to reflect minmax file changes

* ♻️ refactor: add new minmax file

* ✅ tests: fix benchmarks

* ✅ tests: fix benchmarks for minmax

* ♻️ refactor: refactor minmaxlttb files

* 🏗️ refactor: update lib to reflect changes to minmaxlttb files

* ✅ tests: fix benchmarks for minmaxlttb

* 🏗️ refactor: refactor lttb files

* 🏗<fe0f> refactor: update lib to reflect changes to lttb files

* 🐛 fix: rename minmaxlttb mod name

* ✅ tests: fix test_rust_mods

* 🐛 fix: use new rust modules in python code

* 🖊️ code review

---------

Co-authored-by: Jeroen Van Der Donckt <boebievdd@gmail.com>
  • Loading branch information
NielsPraet and jvdd authored Aug 2, 2023
1 parent b70f614 commit 0359eba
Show file tree
Hide file tree
Showing 29 changed files with 1,437 additions and 2,429 deletions.
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
59 changes: 29 additions & 30 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_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_without_x(black_box(data.as_slice()), black_box(2_000)))
});
}

Expand All @@ -21,17 +20,17 @@ fn m4_f32_random_array_long_multi_core(c: &mut Criterion) {
let all_threads: usize = utils::get_all_threads();
c.bench_function("m4_scal_p_f32", |b| {
b.iter(|| {
m4_mod::m4_scalar_without_x_parallel(
black_box(data.view()),
m4_mod::m4_without_x_parallel(
black_box(data.as_slice()),
black_box(2_000),
black_box(all_threads),
)
})
});
c.bench_function("m4_simd_p_f32", |b| {
b.iter(|| {
m4_mod::m4_simd_without_x_parallel(
black_box(data.view()),
m4_mod::m4_without_x_parallel(
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_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_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()),
m4_mod::m4_with_x(
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()),
m4_mod::m4_with_x(
black_box(x.as_slice()),
black_box(data.as_slice()),
black_box(2_000),
)
})
Expand All @@ -72,41 +71,41 @@ 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()),
m4_mod::m4_without_x_parallel(
black_box(data.as_slice()),
black_box(2_000),
black_box(all_threads),
)
})
});
c.bench_function("m4_simd_p_50M_f32", |b| {
b.iter(|| {
m4_mod::m4_simd_without_x_parallel(
black_box(data.view()),
m4_mod::m4_without_x_parallel(
black_box(data.as_slice()),
black_box(2_000),
black_box(all_threads),
)
})
});
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()),
m4_mod::m4_with_x_parallel(
black_box(x.as_slice()),
black_box(data.as_slice()),
black_box(2_000),
black_box(all_threads),
)
})
});
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()),
m4_mod::m4_with_x_parallel(
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
Loading

0 comments on commit 0359eba

Please sign in to comment.