Skip to content

Commit eea497f

Browse files
committed
Also run bench functions in release
1 parent 175b45d commit eea497f

File tree

5 files changed

+36
-38
lines changed

5 files changed

+36
-38
lines changed

ci/run.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ else
2626
run="cargo test --manifest-path testcrate/Cargo.toml --no-fail-fast --target $target"
2727
$run
2828
$run --release
29-
$run --benches
3029
$run --features c
3130
$run --features c --release
3231
$run --features no-asm
3332
$run --features no-asm --release
3433
$run --features no-f16-f128
3534
$run --features no-f16-f128 --release
35+
$run --benches
36+
$run --benches --release
3637
fi
3738

3839
if [ "${TEST_VERBATIM:-}" = "1" ]; then

testcrate/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ default-features = false
2222
features = ["public-test-deps"]
2323

2424
[dev-dependencies]
25-
criterion = { version = "0.5.1", default-features = false }
25+
criterion = { version = "0.5.1", default-features = false, features = ["cargo_bench_support"] }
2626
paste = "1.0.15"
2727

2828
[target.'cfg(all(target_arch = "arm", not(any(target_env = "gnu", target_env = "musl")), target_os = "linux"))'.dev-dependencies]

testcrate/benches/float_extend.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ float_bench! {
1414
sys_available: not(feature = "no-sys-f16"),
1515
asm: [
1616
#[cfg(target_arch = "aarch64")] {
17-
// FIXME(f16_f128): use `f16` assembly once support is added (rust-lang/rust/#116909)
17+
// FIXME(f16_f128): remove `to_bits()` after f16 asm support (rust-lang/rust/#116909)
1818
let ret: f32;
1919
asm!(
20-
"fcvt {ret:s}, h0",
21-
// a = in(vreg) a,
20+
"fcvt {ret:s}, {a:h}",
21+
a = in(vreg) a.to_bits(),
2222
ret = lateout(vreg) ret,
2323
options(nomem, nostack),
2424
);

testcrate/benches/float_trunc.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ float_bench! {
1313
sys_available: not(feature = "no-sys-f16"),
1414
asm: [
1515
#[cfg(target_arch = "aarch64")] {
16-
// FIXME(f16_f128): use `f16` assembly once support is added (rust-lang/rust/#116909)
17-
let ret = core::mem::MaybeUninit::uninit();
16+
// FIXME(f16_f128): remove `from_bits()` after f16 asm support (rust-lang/rust/#116909)
17+
let ret: u16;
1818
asm!(
19-
"fcvt h0, {a:s}",
19+
"fcvt {ret:h}, {a:s}",
2020
a = in(vreg) a,
21-
// ret = lateout(vreg) ret,
21+
ret = lateout(vreg) ret,
2222
options(nomem, nostack),
2323
);
2424

25-
ret.assume_init()
25+
f16::from_bits(ret)
2626
};
2727
],
2828
}
@@ -35,16 +35,16 @@ float_bench! {
3535
sys_available: not(feature = "no-sys-f128"),
3636
asm: [
3737
#[cfg(target_arch = "aarch64")] {
38-
// FIXME(f16_f128): use `f16` assembly once support is added (rust-lang/rust/#116909)
39-
let ret = core::mem::MaybeUninit::uninit();
38+
// FIXME(f16_f128): remove `from_bits()` after f16 asm support (rust-lang/rust/#116909)
39+
let ret: u16;
4040
asm!(
41-
"fcvt h0, {a:d}",
41+
"fcvt {ret:h}, {a:d}",
4242
a = in(vreg) a,
43-
// ret = lateout(vreg) ret,
43+
ret = lateout(vreg) ret,
4444
options(nomem, nostack),
4545
);
4646

47-
ret.assume_init()
47+
f16::from_bits(ret)
4848
};
4949
],
5050
}

testcrate/src/bench.rs

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -206,33 +206,30 @@ macro_rules! float_bench {
206206
}
207207
}
208208

209-
c.bench_function(&format!("{test_name} compiler-builtins"), |b| {
210-
b.iter(|| {
211-
for ($($arg),*) in benchvec.iter().copied() {
212-
black_box(crate_fn( $(black_box($arg)),* ));
213-
}
214-
})
215-
});
209+
let mut group = c.benchmark_group(test_name);
210+
group.bench_function("compiler-builtins", |b| b.iter(|| {
211+
for ($($arg),*) in benchvec.iter().copied() {
212+
black_box(crate_fn( $(black_box($arg)),* ));
213+
}
214+
}));
216215

217216
#[cfg($sys_available)]
218-
c.bench_function(&format!("{test_name} system"), |b| {
219-
b.iter(|| {
220-
for ($($arg),*) in benchvec.iter().copied() {
221-
black_box(sys_fn( $(black_box($arg)),* ));
222-
}
223-
})
224-
});
217+
group.bench_function("system", |b| b.iter(|| {
218+
for ($($arg),*) in benchvec.iter().copied() {
219+
black_box(sys_fn( $(black_box($arg)),* ));
220+
}
221+
}));
225222

226223
#[cfg(any( $($asm_meta),* ))]
227-
c.bench_function(&format!(
228-
"{test_name} assembly ({} {})", std::env::consts::ARCH, std::env::consts::FAMILY
229-
), |b| {
230-
b.iter(|| {
231-
for ($($arg),*) in benchvec.iter().copied() {
232-
black_box(asm_fn( $(black_box($arg)),* ));
233-
}
234-
})
235-
});
224+
group.bench_function(&format!(
225+
"assembly ({} {})", std::env::consts::ARCH, std::env::consts::FAMILY
226+
), |b| b.iter(|| {
227+
for ($($arg),*) in benchvec.iter().copied() {
228+
black_box(asm_fn( $(black_box($arg)),* ));
229+
}
230+
}));
231+
232+
group.finish();
236233
}
237234
}};
238235

0 commit comments

Comments
 (0)