Skip to content

Commit

Permalink
Merge pull request #7 from ChillFish8/CFAVML-NONE-add-simsimd
Browse files Browse the repository at this point in the history
CFAVML-NONE: Add `simsimd` back to distance benchmarks
  • Loading branch information
ChillFish8 authored Aug 20, 2024
2 parents 3dabd35 + 5aee426 commit 31db7e4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
1 change: 1 addition & 0 deletions cfavml/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ paste = "1.0.14"
divan = "0.1.14"
num-traits = "0.2.19"
mimalloc = { version = "0.1.43", default-features = false }
simsimd = "5.0.1"

[target.'cfg(unix)'.dev-dependencies]
ndarray = { version = "0.15.6", features = ["blas"] }
Expand Down
43 changes: 38 additions & 5 deletions cfavml/benches/bench_distance_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn main() {
}

#[divan::bench_group(
sample_count = 500,
sample_count = 2500,
sample_size = 5000,
threads = false,
counters = [ItemsCount::new(DIMS)],
Expand All @@ -29,7 +29,7 @@ mod dot_product {

use super::*;

#[divan::bench(types = [f32, f64, i8, i16, i32, i64, u8, u16, u32, u64])]
#[divan::bench(types = [f32, f64])]
fn ndarray<T>(bencher: Bencher)
where
Standard: Distribution<T>,
Expand All @@ -48,7 +48,18 @@ mod dot_product {
});
}

#[divan::bench(types = [f32, f64, i8, i16, i32, i64, u8, u16, u32, u64])]
#[divan::bench(types = [f32, f64])]
fn simsimd<T>(bencher: Bencher)
where
Standard: Distribution<T>,
T: simsimd::SpatialSimilarity,
{
let (l1, l2) = utils::get_sample_vectors::<T>(DIMS);

bencher.bench_local(|| T::dot(black_box(&l1), black_box(&l2)));
}

#[divan::bench(types = [f32, f64])]
fn cfavml<T>(bencher: Bencher)
where
Standard: Distribution<T>,
Expand All @@ -66,7 +77,7 @@ mod dot_product {
}

#[divan::bench_group(
sample_count = 500,
sample_count = 2500,
sample_size = 5000,
threads = false,
counters = [ItemsCount::new(DIMS)],
Expand Down Expand Up @@ -104,6 +115,17 @@ mod cosine {
});
}

#[divan::bench(types = [f32, f64])]
fn simsimd<T>(bencher: Bencher)
where
Standard: Distribution<T>,
T: simsimd::SpatialSimilarity,
{
let (l1, l2) = utils::get_sample_vectors::<T>(DIMS);

bencher.bench_local(|| T::cosine(black_box(&l1), black_box(&l2)));
}

#[divan::bench(types = [f32, f64])]
fn cfavml<T>(bencher: Bencher)
where
Expand All @@ -122,7 +144,7 @@ mod cosine {
}

#[divan::bench_group(
sample_count = 500,
sample_count = 2500,
sample_size = 5000,
threads = false,
counters = [ItemsCount::new(DIMS)],
Expand Down Expand Up @@ -161,6 +183,17 @@ mod euclidean {
});
}

#[divan::bench(types = [f32, f64])]
fn simsimd<T>(bencher: Bencher)
where
Standard: Distribution<T>,
T: simsimd::SpatialSimilarity,
{
let (l1, l2) = utils::get_sample_vectors::<T>(DIMS);

bencher.bench_local(|| T::sqeuclidean(black_box(&l1), black_box(&l2)));
}

#[divan::bench(types = [f32, f64])]
fn cfavml<T>(bencher: Bencher)
where
Expand Down

0 comments on commit 31db7e4

Please sign in to comment.