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

chore(bench): rename benches #34

Merged
merged 3 commits into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 11 additions & 12 deletions benches/bench_f16_return_nan.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#![feature(stdsimd)]

extern crate dev_utils;

#[cfg(feature = "half")]
use argminmax::ArgMinMax;
use codspeed_criterion_compat::*;
Expand Down Expand Up @@ -34,50 +32,51 @@ fn get_random_f16_array(n: usize) -> Vec<f16> {
data
}

// TODO: rename _random_long_ to _nanargminmax_
// _rn stands for "return nan"

#[cfg(feature = "half")]
fn nanargminmax_f16_random_array_long(c: &mut Criterion) {
fn argminmax_rn_f16_random_array_long(c: &mut Criterion) {
let n = config::ARRAY_LENGTH_LONG;
let data: &[f16] = &get_random_f16_array(n);
c.bench_function("scalar_random_long_f16", |b| {
c.bench_function("scalar_f16_argminmax_rn", |b| {
b.iter(|| SCALAR::argminmax(black_box(data)))
});
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
if is_x86_feature_detected!("sse4.1") {
c.bench_function("sse_random_long_f16", |b| {
c.bench_function("sse_f16_argminmax_rn", |b| {
b.iter(|| unsafe { SSE::argminmax(black_box(data)) })
});
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
if is_x86_feature_detected!("avx2") {
c.bench_function("avx2_random_long_f16", |b| {
c.bench_function("avx2_f16_argminmax_rn", |b| {
b.iter(|| unsafe { AVX2::argminmax(black_box(data)) })
});
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
if is_x86_feature_detected!("avx512bw") {
c.bench_function("avx512_random_long_f16", |b| {
c.bench_function("avx512_f16_argminmax_rn", |b| {
b.iter(|| unsafe { AVX512::argminmax(black_box(data)) })
});
}
#[cfg(target_arch = "arm")]
if std::arch::is_arm_feature_detected!("neon") {
c.bench_function("neon_random_long_f16", |b| {
c.bench_function("neon_f16_argminmax_rn", |b| {
b.iter(|| unsafe { NEON::argminmax(black_box(data)) })
});
}
#[cfg(target_arch = "aarch64")]
if std::arch::is_aarch64_feature_detected!("neon") {
c.bench_function("neon_random_long_f16", |b| {
c.bench_function("neon_f16_argminmax_rn", |b| {
b.iter(|| unsafe { NEON::argminmax(black_box(data)) })
});
}
c.bench_function("impl_random_long_f16", |b| {
c.bench_function("impl_f16_argminmax_rn", |b| {
b.iter(|| black_box(data.nanargminmax()))
});
}

#[cfg(feature = "half")]
criterion_group!(benches, nanargminmax_f16_random_array_long,);
criterion_group!(benches, argminmax_rn_f16_random_array_long,);
#[cfg(feature = "half")]
criterion_main!(benches);
22 changes: 11 additions & 11 deletions benches/bench_f32_ignore_nan.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#![feature(stdsimd)]

extern crate dev_utils;

use argminmax::ArgMinMax;
use codspeed_criterion_compat::*;
use dev_utils::{config, utils};
Expand All @@ -12,46 +10,48 @@ use argminmax::{AVX2IgnoreNaN, AVX512IgnoreNaN, SIMDArgMinMaxIgnoreNaN, SSEIgnor
use argminmax::{NEONIgnoreNaN, SIMDArgMinMaxIgnoreNaN};
use argminmax::{SCALARIgnoreNaN, ScalarArgMinMax};

fn argminmax_f32_random_array_long(c: &mut Criterion) {
// _in stands for "ignore nan"

fn argminmax_in_f32_random_array_long(c: &mut Criterion) {
let n = config::ARRAY_LENGTH_LONG;
let data: &[f32] = &utils::get_random_array::<f32>(n, f32::MIN, f32::MAX);
c.bench_function("scalar_random_long_f32", |b| {
c.bench_function("scalar_f32_argminmax_in", |b| {
b.iter(|| SCALARIgnoreNaN::argminmax(black_box(data)))
});
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
if is_x86_feature_detected!("sse4.1") {
c.bench_function("sse_random_long_f32", |b| {
c.bench_function("sse_f32_argminmax_in", |b| {
b.iter(|| unsafe { SSEIgnoreNaN::argminmax(black_box(data)) })
});
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
if is_x86_feature_detected!("avx") {
c.bench_function("avx_random_long_f32", |b| {
c.bench_function("avx_f32_argminmax_in", |b| {
b.iter(|| unsafe { AVX2IgnoreNaN::argminmax(black_box(data)) })
});
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
if is_x86_feature_detected!("avx512f") {
c.bench_function("avx512_random_long_f32", |b| {
c.bench_function("avx512_f32_argminmax_in", |b| {
b.iter(|| unsafe { AVX512IgnoreNaN::argminmax(black_box(data)) })
});
}
#[cfg(target_arch = "arm")]
if std::arch::is_arm_feature_detected!("neon") {
c.bench_function("neon_random_long_f32", |b| {
c.bench_function("neon_f32_argminmax_in", |b| {
b.iter(|| unsafe { NEONIgnoreNaN::argminmax(black_box(data)) })
});
}
#[cfg(target_arch = "aarch64")]
if std::arch::is_aarch64_feature_detected!("neon") {
c.bench_function("neon_random_long_f32", |b| {
c.bench_function("neon_f32_argminmax_in", |b| {
b.iter(|| unsafe { NEONIgnoreNaN::argminmax(black_box(data)) })
});
}
c.bench_function("impl_random_long_f32", |b| {
c.bench_function("impl_f32_argminmax_in", |b| {
b.iter(|| black_box(data.argminmax()))
});
}

criterion_group!(benches, argminmax_f32_random_array_long,);
criterion_group!(benches, argminmax_in_f32_random_array_long,);
criterion_main!(benches);
22 changes: 11 additions & 11 deletions benches/bench_f32_return_nan.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#![feature(stdsimd)]

extern crate dev_utils;

use argminmax::ArgMinMax;
use codspeed_criterion_compat::*;
use dev_utils::{config, utils};
Expand All @@ -12,46 +10,48 @@ use argminmax::{SIMDArgMinMax, AVX2, AVX512, SSE};
use argminmax::{SIMDArgMinMax, NEON};
use argminmax::{ScalarArgMinMax, SCALAR};

fn nanargminmax_f32_random_array_long(c: &mut Criterion) {
// _rn stands for "return nan"

fn argminmax_rn_f32_random_array_long(c: &mut Criterion) {
let n = config::ARRAY_LENGTH_LONG;
let data: &[f32] = &utils::get_random_array::<f32>(n, f32::MIN, f32::MAX);
c.bench_function("scalar_nanargminmax_f32", |b| {
c.bench_function("scalar_f32_argminmax_rn", |b| {
b.iter(|| SCALAR::argminmax(black_box(data)))
});
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
if is_x86_feature_detected!("sse4.1") {
c.bench_function("sse_nanargminmax_f32", |b| {
c.bench_function("sse_f32_argminmax_rn", |b| {
b.iter(|| unsafe { SSE::argminmax(black_box(data)) })
});
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
if is_x86_feature_detected!("avx2") {
c.bench_function("avx2_nanargminmax_f32", |b| {
c.bench_function("avx2_f32_argminmax_rn", |b| {
b.iter(|| unsafe { AVX2::argminmax(black_box(data)) })
});
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
if is_x86_feature_detected!("avx512f") {
c.bench_function("avx512_nanargminmax_f32", |b| {
c.bench_function("avx512_f32_argminmax_rn", |b| {
b.iter(|| unsafe { AVX512::argminmax(black_box(data)) })
});
}
#[cfg(target_arch = "arm")]
if std::arch::is_arm_feature_detected!("neon") {
c.bench_function("neon_nanargminmax_f32", |b| {
c.bench_function("neon_f32_argminmax_rn", |b| {
b.iter(|| unsafe { NEON::argminmax(black_box(data)) })
});
}
#[cfg(target_arch = "aarch64")]
if std::arch::is_aarch64_feature_detected!("neon") {
c.bench_function("neon_nanargminmax_f32", |b| {
c.bench_function("neon_f32_argminmax_rn", |b| {
b.iter(|| unsafe { NEON::argminmax(black_box(data)) })
});
}
c.bench_function("impl_nanargminmax_f32", |b| {
c.bench_function("impl_f32_argminmax_rn", |b| {
b.iter(|| black_box(data.nanargminmax()))
});
}

criterion_group!(benches, nanargminmax_f32_random_array_long,);
criterion_group!(benches, argminmax_rn_f32_random_array_long,);
criterion_main!(benches);
18 changes: 9 additions & 9 deletions benches/bench_f64_ignore_nan.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#![feature(stdsimd)]

extern crate dev_utils;

use argminmax::ArgMinMax;
use codspeed_criterion_compat::*;
use dev_utils::{config, utils};
Expand All @@ -10,34 +8,36 @@ use dev_utils::{config, utils};
use argminmax::{AVX2IgnoreNaN, AVX512IgnoreNaN, SIMDArgMinMaxIgnoreNaN, SSEIgnoreNaN};
use argminmax::{SCALARIgnoreNaN, ScalarArgMinMax};

fn argminmax_f64_random_array_long(c: &mut Criterion) {
// _in stands for "ignore nan"

fn argminmax_in_f64_random_array_long(c: &mut Criterion) {
let n = config::ARRAY_LENGTH_LONG;
let data: &[f64] = &utils::get_random_array::<f64>(n, f64::MIN, f64::MAX);
c.bench_function("scalar_random_long_f64", |b| {
c.bench_function("scalar_f64_argminmax_in", |b| {
b.iter(|| SCALARIgnoreNaN::argminmax(black_box(data)))
});
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
if is_x86_feature_detected!("sse4.1") {
c.bench_function("sse_random_long_f64", |b| {
c.bench_function("sse_f64_argminmax_in", |b| {
b.iter(|| unsafe { SSEIgnoreNaN::argminmax(black_box(data)) })
});
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
if is_x86_feature_detected!("avx") {
c.bench_function("avx_random_long_f64", |b| {
c.bench_function("avx_f64_argminmax_in", |b| {
b.iter(|| unsafe { AVX2IgnoreNaN::argminmax(black_box(data)) })
});
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
if is_x86_feature_detected!("avx512f") {
c.bench_function("avx512_random_long_f64", |b| {
c.bench_function("avx512_f64_argminmax_in", |b| {
b.iter(|| unsafe { AVX512IgnoreNaN::argminmax(black_box(data)) })
});
}
c.bench_function("impl_random_long_f64", |b| {
c.bench_function("impl_f64_argminmax_in", |b| {
b.iter(|| black_box(data.argminmax()))
});
}

criterion_group!(benches, argminmax_f64_random_array_long,);
criterion_group!(benches, argminmax_in_f64_random_array_long,);
criterion_main!(benches);
18 changes: 9 additions & 9 deletions benches/bench_f64_return_nan.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#![feature(stdsimd)]

extern crate dev_utils;

use argminmax::ArgMinMax;
use codspeed_criterion_compat::*;
use dev_utils::{config, utils};
Expand All @@ -10,34 +8,36 @@ use dev_utils::{config, utils};
use argminmax::{SIMDArgMinMax, AVX2, AVX512, SSE};
use argminmax::{ScalarArgMinMax, SCALAR};

fn nanargminmax_f64_random_array_long(c: &mut Criterion) {
// _rn stands for "return nan"

fn argminmax_rn_f64_random_array_long(c: &mut Criterion) {
let n = config::ARRAY_LENGTH_LONG;
let data: &[f64] = &utils::get_random_array::<f64>(n, f64::MIN, f64::MAX);
c.bench_function("scalar_nanargminmax_f64", |b| {
c.bench_function("scalar_f64_argminmax_rn", |b| {
b.iter(|| SCALAR::argminmax(black_box(data)))
});
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
if is_x86_feature_detected!("sse4.2") {
c.bench_function("sse_nanargminmax_f64", |b| {
c.bench_function("sse_f64_argminmax_rn", |b| {
b.iter(|| unsafe { SSE::argminmax(black_box(data)) })
});
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
if is_x86_feature_detected!("avx2") {
c.bench_function("avx2_nanargminmax_f64", |b| {
c.bench_function("avx2_f64_argminmax_rn", |b| {
b.iter(|| unsafe { AVX2::argminmax(black_box(data)) })
});
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
if is_x86_feature_detected!("avx512f") {
c.bench_function("avx512_nanargminmax_f64", |b| {
c.bench_function("avx512_f64_argminmax_rn", |b| {
b.iter(|| unsafe { AVX512::argminmax(black_box(data)) })
});
}
c.bench_function("impl_nanargminmax_f64", |b| {
c.bench_function("impl_f64_argminmax_rn", |b| {
b.iter(|| black_box(data.nanargminmax()))
});
}

criterion_group!(benches, nanargminmax_f64_random_array_long,);
criterion_group!(benches, argminmax_rn_f64_random_array_long,);
criterion_main!(benches);
Loading