Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
11c1522
Enable `__powitf2` on MSVC
beetrees May 21, 2025
7966f1b
fixed typo in readme
Lorl0rd May 10, 2025
db21837
libm: Clean up unused files
tgross35 Apr 22, 2025
4c264c9
Update `CmpResult` to use a pointer-sized return type
tgross35 May 23, 2025
c04f133
Typo in README.md
D-Dario0 May 28, 2025
5978b8b
aarch64: Add a note saying why we use `frintx` rather than `frintn`
tgross35 May 28, 2025
2c9fb22
jsondoclint: Extract `Command`/`CommandKind` into its own file
aDotInTheVoid May 28, 2025
851aa05
cleanup: Reuse `MinInt` and `Int` from `libm` in `compiler-builtins`
tgross35 Apr 21, 2025
877feef
Reuse `libm`'s `Caat` and `CastFrom` in `compiler-builtins`
tgross35 May 29, 2025
97c0beb
Remove unneeded C symbols
tgross35 May 28, 2025
a63f482
Replace the `nm` symbol check with a Rust implementation
tgross35 Apr 19, 2025
8db9bd6
Remove the now-unneeded llvm-tools-preview
tgross35 May 28, 2025
151b1cb
Change `compiler-builtins` to edition 2024
tgross35 May 29, 2025
af16553
symcheck: Print the command to make reproducing errors easier
tgross35 May 29, 2025
7db8cf1
Add benchmarks for float parsing and printing
tgross35 May 29, 2025
c136fb7
Run `builtins-test-intrinsics` when possible
tgross35 Mar 19, 2025
3464b4b
ci: Allow concurrency outside of pull requests
tgross35 May 29, 2025
9f84e99
Increase the benchmark rustc version to 2025-05-28
tgross35 May 29, 2025
8edaa6e
libm-test: Make `extensive` an attribute rather than a test type
tgross35 May 29, 2025
4d325e8
ci: Allow for multiple icount benchmarks in the same run
tgross35 May 29, 2025
14db1b5
jsondocck: command -> directive
aDotInTheVoid May 28, 2025
3c35505
chore: release
github-actions[bot] May 29, 2025
c6df6a7
Fix new `dead_code` warnings from recent nightlies
tgross35 Jun 1, 2025
0a7e592
Upgrade all dependencies to the latest available version
tgross35 Jun 1, 2025
e83ca86
cleanup: Use `x.biteq(y)` rather than `x.to_bits() == y.to_bits()`
tgross35 Jun 2, 2025
ba7cdb6
ci: Refactor benchmark regression checks
tgross35 Jun 1, 2025
5778643
libm-test: Fix unintentional skips in `binop_common`
tgross35 Jun 2, 2025
763663a
rustdoc-json-type: Depend on `serde` and `serde_derive` seperately
aDotInTheVoid Jun 3, 2025
28231d9
Replace some `Option<Span>` with `Span` and use DUMMY_SP instead of None
oli-obk Jun 4, 2025
9091a94
bootstrap: Fix file permissions when dereferencing symlinks
smpdt Jun 4, 2025
06ab34e
cleaned up some tests
Kivooeo Jun 3, 2025
6417248
Report the actual item that evaluation failed for
oli-obk Jun 4, 2025
55f59fb
Fix parsing of frontmatters with inner hyphens
matthewjasper Jun 4, 2025
e1e3cc2
Replace the musl submodule with a download script
tgross35 Jun 4, 2025
f67ca0f
Add an empty rust-version file
tgross35 May 28, 2025
3353a89
Add tooling for `josh` syncs
tgross35 May 18, 2025
eb45e57
Update the upstream Rust version
tgross35 Jun 4, 2025
1599091
Merge ref 'df8102fe5f24:/library/compiler-builtins' from https://gith…
tgross35 Jun 4, 2025
ab453db
`panic-handler`: Remove the `no_core` feature
tgross35 Jun 4, 2025
91ad4bf
jsondocck: Explain what `KNOWN_DIRECTIVE_NAMES` is doing
aDotInTheVoid Jun 5, 2025
bee6dc4
Rollup merge of #141709 - aDotInTheVoid:split-for-docs, r=GuillaumeGomez
matthiaskrgr Jun 5, 2025
5a4abf0
Rollup merge of #141974 - Kivooeo:tf4, r=jieyouxu
matthiaskrgr Jun 5, 2025
1dcd4a7
Rollup merge of #141989 - aDotInTheVoid:sin-sooner, r=GuillaumeGomez
matthiaskrgr Jun 5, 2025
276506e
Rollup merge of #142012 - oli-obk:no-optional-spans, r=fee1-dead
matthiaskrgr Jun 5, 2025
8689de4
Rollup merge of #142015 - oli-obk:wrong-instance, r=RalfJung
matthiaskrgr Jun 5, 2025
64f4bd5
Rollup merge of #142026 - smpdt:master, r=Kobzol
matthiaskrgr Jun 5, 2025
5604376
Rollup merge of #142032 - matthewjasper:frontmatter-lexing, r=fee1-dead
matthiaskrgr Jun 5, 2025
eef9831
Rollup merge of #142036 - tgross35:update-builtins, r=tgross35
matthiaskrgr Jun 5, 2025
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
Prev Previous commit
Next Next commit
libm-test: Make extensive an attribute rather than a test type
Currently we run logspace tests for extensive tests, but there isn't any
reason we couldn't also run more kinds of tests more extensively (e.g.
more edge cases, combine edge cases with logspace for multi-input
functions, etc). As a first step toward making this possible, make
`extensive` a new field in `CheckCtx`, and rename `QuickSpaced` to
`Spaced`.
  • Loading branch information
tgross35 committed May 29, 2025
commit 8edaa6e5c88e14df20b095016514d381c697e49a
2 changes: 1 addition & 1 deletion library/compiler-builtins/libm-test/benches/icount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ macro_rules! icount_benches {
let mut ctx = CheckCtx::new(
Op::IDENTIFIER,
CheckBasis::None,
GeneratorKind::QuickSpaced
GeneratorKind::Spaced
);
ctx.override_iterations(BENCH_ITER_ITEMS);
let ret = spaced::get_test_cases::<Op>(&ctx).0.collect::<Vec<_>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ where
Op: MathOp<FTy = f32, RustArgs = (f32,)>,
Op::RustArgs: SpacedInput<Op>,
{
let mut ctx = CheckCtx::new(Op::IDENTIFIER, CheckBasis::Mpfr, GeneratorKind::QuickSpaced);
let mut ctx = CheckCtx::new(Op::IDENTIFIER, CheckBasis::Mpfr, GeneratorKind::Spaced);
plot_one_generator(
out_dir,
&ctx,
Expand Down
74 changes: 55 additions & 19 deletions library/compiler-builtins/libm-test/src/run_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,38 @@ static EXTENSIVE_ITER_OVERRIDE: LazyLock<Option<u64>> = LazyLock::new(|| {

/// Specific tests that need to have a reduced amount of iterations to complete in a reasonable
/// amount of time.
///
/// Contains the itentifier+generator combo to match on, plus the factor to reduce by.
const EXTEMELY_SLOW_TESTS: &[(Identifier, GeneratorKind, u64)] = &[
(Identifier::Fmodf128, GeneratorKind::QuickSpaced, 50),
(Identifier::Fmodf128, GeneratorKind::Extensive, 50),
const EXTREMELY_SLOW_TESTS: &[SlowTest] = &[
SlowTest {
ident: Identifier::Fmodf128,
gen_kind: GeneratorKind::Spaced,
extensive: false,
reduce_factor: 50,
},
SlowTest {
ident: Identifier::Fmodf128,
gen_kind: GeneratorKind::Spaced,
extensive: true,
reduce_factor: 50,
},
];

/// A pattern to match a `CheckCtx`, plus a factor to reduce by.
struct SlowTest {
ident: Identifier,
gen_kind: GeneratorKind,
extensive: bool,
reduce_factor: u64,
}

impl SlowTest {
/// True if the test in `CheckCtx` should be reduced by `reduce_factor`.
fn matches_ctx(&self, ctx: &CheckCtx) -> bool {
self.ident == ctx.fn_ident
&& self.gen_kind == ctx.gen_kind
&& self.extensive == ctx.extensive
}
}

/// Maximum number of iterations to run for a single routine.
///
/// The default value of one greater than `u32::MAX` allows testing single-argument `f32` routines
Expand All @@ -54,6 +79,7 @@ pub struct CheckCtx {
/// Source of truth for tests.
pub basis: CheckBasis,
pub gen_kind: GeneratorKind,
pub extensive: bool,
/// If specified, this value will override the value returned by [`iteration_count`].
pub override_iterations: Option<u64>,
}
Expand All @@ -69,12 +95,19 @@ impl CheckCtx {
base_name_str: fn_ident.base_name().as_str(),
basis,
gen_kind,
extensive: false,
override_iterations: None,
};
ret.ulp = crate::default_ulp(&ret);
ret
}

/// Configure that this is an extensive test.
pub fn extensive(mut self, extensive: bool) -> Self {
self.extensive = extensive;
self
}

/// The number of input arguments for this function.
pub fn input_count(&self) -> usize {
self.fn_ident.math_op().rust_sig.args.len()
Expand All @@ -100,14 +133,17 @@ pub enum CheckBasis {
/// and quantity.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum GeneratorKind {
/// Extremes, zeros, nonstandard numbers, etc.
EdgeCases,
Extensive,
QuickSpaced,
/// Spaced by logarithm (floats) or linear (integers).
Spaced,
/// Test inputs from an RNG.
Random,
/// A provided test case list.
List,
}

/// A list of all functions that should get extensive tests.
/// A list of all functions that should get extensive tests, as configured by environment variable.
///
/// This also supports the special test name `all` to run all tests, as well as `all_f16`,
/// `all_f32`, `all_f64`, and `all_f128` to run all tests for a specific float type.
Expand Down Expand Up @@ -216,17 +252,17 @@ pub fn iteration_count(ctx: &CheckCtx, argnum: usize) -> u64 {
let random_iter_count = domain_iter_count / 100;

let mut total_iterations = match ctx.gen_kind {
GeneratorKind::QuickSpaced => domain_iter_count,
GeneratorKind::Spaced if ctx.extensive => extensive_max_iterations(),
GeneratorKind::Spaced => domain_iter_count,
GeneratorKind::Random => random_iter_count,
GeneratorKind::Extensive => extensive_max_iterations(),
GeneratorKind::EdgeCases | GeneratorKind::List => {
unimplemented!("shoudn't need `iteration_count` for {:?}", ctx.gen_kind)
}
};

// Larger float types get more iterations.
if t_env.large_float_ty && ctx.gen_kind != GeneratorKind::Extensive {
if ctx.gen_kind == GeneratorKind::Extensive {
if t_env.large_float_ty {
if ctx.extensive {
// Extensive already has a pretty high test count.
total_iterations *= 2;
} else {
Expand All @@ -244,13 +280,13 @@ pub fn iteration_count(ctx: &CheckCtx, argnum: usize) -> u64 {
}

// Some tests are significantly slower than others and need to be further reduced.
if let Some((_id, _gen, scale)) = EXTEMELY_SLOW_TESTS
if let Some(slow) = EXTREMELY_SLOW_TESTS
.iter()
.find(|(id, generator, _scale)| *id == ctx.fn_ident && *generator == ctx.gen_kind)
.find(|slow| slow.matches_ctx(ctx))
{
// However, do not override if the extensive iteration count has been manually set.
if !(ctx.gen_kind == GeneratorKind::Extensive && EXTENSIVE_ITER_OVERRIDE.is_some()) {
total_iterations /= scale;
if !(ctx.extensive && EXTENSIVE_ITER_OVERRIDE.is_some()) {
total_iterations /= slow.reduce_factor;
}
}

Expand Down Expand Up @@ -279,7 +315,7 @@ pub fn iteration_count(ctx: &CheckCtx, argnum: usize) -> u64 {
let total = ntests.pow(t_env.input_count.try_into().unwrap());

let seed_msg = match ctx.gen_kind {
GeneratorKind::QuickSpaced | GeneratorKind::Extensive => String::new(),
GeneratorKind::Spaced => String::new(),
GeneratorKind::Random => {
format!(
" using `{SEED_ENV}={}`",
Expand Down Expand Up @@ -327,8 +363,8 @@ pub fn int_range(ctx: &CheckCtx, argnum: usize) -> RangeInclusive<i32> {
let extensive_range = (-0xfff)..=0xfffff;

match ctx.gen_kind {
GeneratorKind::Extensive => extensive_range,
GeneratorKind::QuickSpaced | GeneratorKind::Random => non_extensive_range,
_ if ctx.extensive => extensive_range,
GeneratorKind::Spaced | GeneratorKind::Random => non_extensive_range,
GeneratorKind::EdgeCases => extensive_range,
GeneratorKind::List => unimplemented!("shoudn't need range for {:?}", ctx.gen_kind),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ macro_rules! musl_tests {
$(#[$attr])*
fn [< musl_quickspace_ $fn_name >]() {
type Op = libm_test::op::$fn_name::Routine;
let ctx = CheckCtx::new(Op::IDENTIFIER, BASIS, GeneratorKind::QuickSpaced);
let ctx = CheckCtx::new(Op::IDENTIFIER, BASIS, GeneratorKind::Spaced);
let cases = spaced::get_test_cases::<Op>(&ctx).0;
musl_runner::<Op>(&ctx, cases, musl_math_sys::$fn_name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ macro_rules! mp_tests {
$(#[$attr])*
fn [< mp_quickspace_ $fn_name >]() {
type Op = libm_test::op::$fn_name::Routine;
let ctx = CheckCtx::new(Op::IDENTIFIER, BASIS, GeneratorKind::QuickSpaced);
let ctx = CheckCtx::new(Op::IDENTIFIER, BASIS, GeneratorKind::Spaced);
let cases = spaced::get_test_cases::<Op>(&ctx).0;
mp_runner::<Op>(&ctx, cases);
}
Expand Down
3 changes: 1 addition & 2 deletions library/compiler-builtins/libm-test/tests/z_extensive/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use rayon::prelude::*;
use spaced::SpacedInput;

const BASIS: CheckBasis = CheckBasis::Mpfr;
const GEN_KIND: GeneratorKind = GeneratorKind::Extensive;

/// Run the extensive test suite.
pub fn run() {
Expand Down Expand Up @@ -77,7 +76,7 @@ where
Op::RustArgs: SpacedInput<Op> + Send,
{
let test_name = format!("mp_extensive_{}", Op::NAME);
let ctx = CheckCtx::new(Op::IDENTIFIER, BASIS, GEN_KIND);
let ctx = CheckCtx::new(Op::IDENTIFIER, BASIS, GeneratorKind::Spaced).extensive(true);
let skip = skip_extensive_test(&ctx);

let runner = move || {
Expand Down