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

Full no_std and miri support #18

Merged
merged 15 commits into from
Jan 28, 2023
Merged

Full no_std and miri support #18

merged 15 commits into from
Jan 28, 2023

Conversation

robamler
Copy link
Collaborator

@robamler robamler commented Nov 6, 2022

Update dependency on probability from version 0.18 to version 0.19.1 make it non-optional. This is a breaking change since constriction's public API exposes traits from probability.

Starting from version 0.19, crate probability is now supposed to
both support no_std mode and remove all external syscalls for
mathematical special functions. We therefore no longer need to make the
crate probability an optional dependency.

The updated probability should allow users to use constriction in
no_std mode in more contexts, and to run more tests in miri. Tests on this PR will show whether this is indeed the case.

@robamler robamler force-pushed the new-probability branch 8 times, most recently from 772ebe8 to 5994eec Compare November 6, 2022 23:10
@robamler robamler force-pushed the new-probability branch 2 times, most recently from 7dd84f0 to 4f85172 Compare November 7, 2022 01:25
@robamler
Copy link
Collaborator Author

robamler commented Nov 7, 2022

It might be worth waiting for rust-lang/rust#103765 to be stabilized, as that would probably allow us to be no_std compatible by default (without a feature gate).

@robamler robamler force-pushed the new-probability branch 2 times, most recently from 01a5259 to 3648102 Compare December 18, 2022 20:44
This changes some type signatures, which is technically a breaking
change (although the previous implementations were essentially unusable
anyway).
This requires upgrading the dependency on `probability` from 0.17
to 0.18, which is technically a breaking change since `constriction`
re-exports `probability::distribution::Distribution` and
`probability::distribution::Inverse` unless compiled without the default
feature "std".
Starting from version 0.19, crate `probability` is now supposed to
both support `no_std` mode and remove all external syscalls for
mathematical special functions. We therefore no longer need to make the
crate `probability` an optional dependency.

The updated `probability` *should* allow users to use `constriction` in
`no_std` mode in more contexts, and to run more tests in `miri`. Whether
this is actually the case will be tested in the next few commits.
The new version of the `probability` crate no longer uses system calls
for special mathematical functions, so we can now run (almost) all tests
in miri.

The only tests that are still disabled in miri are the benchmarks in
directory `benches`. These cannot be enabled at this point since
`criterion` seems to be incompatible with `miri`.
First step towards `no_std` compatibility.
For `no_std` compatibility, we can use `log2` only if either feature
"std" or feature "libm" is active.
This one is `no_std` compatible
The only missing piece was to replace `f64::ln_1p` with `libm::log1p`.
@robamler robamler merged commit 8b473f7 into main Jan 28, 2023
@robamler robamler deleted the new-probability branch January 28, 2023 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant