Skip to content
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
8 changes: 7 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
args: --release

miri-test:
name: no_std and miri
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -101,9 +102,14 @@ jobs:
with:
toolchain: ${{ steps.versions.outputs.rustc }}
profile: minimal
components: miri
components: miri, rust-src
override: true

- name: Test `no_std` compatibility
shell: bash
working-directory: ensure_no_std
run: cargo +${{ steps.versions.outputs.rustc }} build

- name: Run tests in miri
env:
RUSTFLAGS: "-Zrandomize-layout"
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ jobs:
args: --release

miri-test:
name: no_std and miri
runs-on: ${{ matrix.os }}
needs: rust-test
strategy:
Expand Down Expand Up @@ -131,9 +132,14 @@ jobs:
with:
toolchain: ${{ steps.versions.outputs.rustc }}
profile: minimal
components: miri
components: miri, rust-src
override: true

- name: Test `no_std` compatibility
shell: bash
working-directory: ensure_no_std
run: cargo +${{ steps.versions.outputs.rustc }} build

- name: Run tests in miri
env:
RUSTFLAGS: "-Zrandomize-layout"
Expand Down
72 changes: 16 additions & 56 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ name = "constriction"

[features]
default = ["std"]
std = ["probability"]
std = []

# Use feature `pybindings` to compile the python extension module that provides
# access to this library from python. This feature is turned off by default
Expand All @@ -30,10 +30,11 @@ pybindings = ["ndarray", "numpy", "pyo3"]

[dependencies]
hashbrown = "0.12.3"
num = "0.4"
num-traits = {version = "0.2.15", default-features = false, features = ["libm"]}
smallvec = "1.6.1"

probability = {version = "0.18", optional = true}
libm = "0.2.6"
probability = {version = "0.20"}

ndarray = {version = "0.15", optional = true}
numpy = {version = "0.17.1", optional = true}
Expand Down
14 changes: 7 additions & 7 deletions benches/lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use constriction::{
BitArray, Pos, Seek,
};
use criterion::{black_box, criterion_group, Criterion};
use num::cast::AsPrimitive;
use num_traits::AsPrimitive;
use rand::{RngCore, SeedableRng};
use rand_xoshiro::Xoshiro256StarStar;

Expand All @@ -26,7 +26,7 @@ criterion_group!(
#[cfg(not(miri))]
criterion::criterion_main!(benches);
#[cfg(miri)]
fn main() {} // All benchmarks currently use FFI and therefore can't be tested in miri.
fn main() {} // miri currently doesn't seem to be able to run criterion benchmarks as tests.

fn round_trip_u32_u64_u16_12(c: &mut Criterion) {
round_trip::<u32, u64, u16, 12>(c);
Expand Down Expand Up @@ -87,7 +87,7 @@ where
type_name::<Probability>(),
PRECISION
);
c.bench_function(&format!("ans_encoding_{}", label_suffix), |b| {
c.bench_function(&format!("ans_encoding_{label_suffix}"), |b| {
b.iter(|| {
encoder.clear();
encoder
Expand All @@ -109,7 +109,7 @@ where
let mut backward_decoder = encoder.into_seekable_decoder();
let reset_snapshot = backward_decoder.pos();

c.bench_function(&format!("ans_backward_decoding_{}", label_suffix), |b| {
c.bench_function(&format!("ans_backward_decoding_{label_suffix}"), |b| {
b.iter(|| {
backward_decoder.seek(black_box(reset_snapshot)).unwrap();
let mut checksum = 1234u16;
Expand All @@ -132,7 +132,7 @@ where
let mut forward_decoder = backward_decoder.into_reversed();
let reset_snapshot = forward_decoder.pos();

c.bench_function(&format!("ans_forward_decoding_{}", label_suffix), |b| {
c.bench_function(&format!("ans_forward_decoding_{label_suffix}"), |b| {
b.iter(|| {
forward_decoder.seek(black_box(reset_snapshot)).unwrap();
let mut checksum = 1234u16;
Expand Down Expand Up @@ -179,7 +179,7 @@ where
type_name::<Probability>(),
PRECISION
);
c.bench_function(&format!("range_encoding_{}", label_suffix), |b| {
c.bench_function(&format!("range_encoding_{label_suffix}"), |b| {
b.iter(|| {
encoder.clear();
encoder
Expand All @@ -200,7 +200,7 @@ where

let mut decoder = encoder.into_decoder().unwrap();

c.bench_function(&format!("range_decoding_{}", label_suffix), |b| {
c.bench_function(&format!("range_decoding_{label_suffix}"), |b| {
b.iter(|| {
decoder.seek(black_box(reset_snapshot)).unwrap();
let mut checksum = 1234u16;
Expand Down
21 changes: 21 additions & 0 deletions ensure_no_std/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# We need to cross-compile the core library.
[unstable]
build-std = [
"alloc",
"compiler_builtins",
"core",
]
build-std-features = ["compiler-builtins-mem"]

[build]
rustflags = [
# See https://doc.rust-lang.org/rustc/codegen-options/index.html for possible rustflags
# use custom linker script
"-C",
"link-args=-n -T src/link.ld", # The default of the x86_64-unknown-none built-in Rust compiler target is "pic".
# See: https://github.com/rust-lang/rust/blob/1.62.1/compiler/rustc_target/src/spec/x86_64_unknown_none.rs
# This is not supported by Hedron.
"-C",
"relocation-model=static",
]
target = "x86_64-unknown-none"
1 change: 1 addition & 0 deletions ensure_no_std/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
Loading