@@ -22,13 +22,38 @@ static EXTENSIVE_ITER_OVERRIDE: LazyLock<Option<u64>> = LazyLock::new(|| {
2222
2323/// Specific tests that need to have a reduced amount of iterations to complete in a reasonable
2424/// amount of time.
25- ///
26- /// Contains the itentifier+generator combo to match on, plus the factor to reduce by.
27- const EXTEMELY_SLOW_TESTS : & [ ( Identifier , GeneratorKind , u64 ) ] = & [
28- ( Identifier :: Fmodf128 , GeneratorKind :: QuickSpaced , 50 ) ,
29- ( Identifier :: Fmodf128 , GeneratorKind :: Extensive , 50 ) ,
25+ const EXTREMELY_SLOW_TESTS : & [ SlowTest ] = & [
26+ SlowTest {
27+ ident : Identifier :: Fmodf128 ,
28+ gen_kind : GeneratorKind :: Spaced ,
29+ extensive : false ,
30+ reduce_factor : 50 ,
31+ } ,
32+ SlowTest {
33+ ident : Identifier :: Fmodf128 ,
34+ gen_kind : GeneratorKind :: Spaced ,
35+ extensive : true ,
36+ reduce_factor : 50 ,
37+ } ,
3038] ;
3139
40+ /// A pattern to match a `CheckCtx`, plus a factor to reduce by.
41+ struct SlowTest {
42+ ident : Identifier ,
43+ gen_kind : GeneratorKind ,
44+ extensive : bool ,
45+ reduce_factor : u64 ,
46+ }
47+
48+ impl SlowTest {
49+ /// True if the test in `CheckCtx` should be reduced by `reduce_factor`.
50+ fn matches_ctx ( & self , ctx : & CheckCtx ) -> bool {
51+ self . ident == ctx. fn_ident
52+ && self . gen_kind == ctx. gen_kind
53+ && self . extensive == ctx. extensive
54+ }
55+ }
56+
3257/// Maximum number of iterations to run for a single routine.
3358///
3459/// The default value of one greater than `u32::MAX` allows testing single-argument `f32` routines
@@ -54,6 +79,7 @@ pub struct CheckCtx {
5479 /// Source of truth for tests.
5580 pub basis : CheckBasis ,
5681 pub gen_kind : GeneratorKind ,
82+ pub extensive : bool ,
5783 /// If specified, this value will override the value returned by [`iteration_count`].
5884 pub override_iterations : Option < u64 > ,
5985}
@@ -69,12 +95,19 @@ impl CheckCtx {
6995 base_name_str : fn_ident. base_name ( ) . as_str ( ) ,
7096 basis,
7197 gen_kind,
98+ extensive : false ,
7299 override_iterations : None ,
73100 } ;
74101 ret. ulp = crate :: default_ulp ( & ret) ;
75102 ret
76103 }
77104
105+ /// Configure that this is an extensive test.
106+ pub fn extensive ( mut self , extensive : bool ) -> Self {
107+ self . extensive = extensive;
108+ self
109+ }
110+
78111 /// The number of input arguments for this function.
79112 pub fn input_count ( & self ) -> usize {
80113 self . fn_ident . math_op ( ) . rust_sig . args . len ( )
@@ -100,14 +133,17 @@ pub enum CheckBasis {
100133/// and quantity.
101134#[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
102135pub enum GeneratorKind {
136+ /// Extremes, zeros, nonstandard numbers, etc.
103137 EdgeCases ,
104- Extensive ,
105- QuickSpaced ,
138+ /// Spaced by logarithm (floats) or linear (integers).
139+ Spaced ,
140+ /// Test inputs from an RNG.
106141 Random ,
142+ /// A provided test case list.
107143 List ,
108144}
109145
110- /// A list of all functions that should get extensive tests.
146+ /// A list of all functions that should get extensive tests, as configured by environment variable .
111147///
112148/// This also supports the special test name `all` to run all tests, as well as `all_f16`,
113149/// `all_f32`, `all_f64`, and `all_f128` to run all tests for a specific float type.
@@ -216,17 +252,17 @@ pub fn iteration_count(ctx: &CheckCtx, argnum: usize) -> u64 {
216252 let random_iter_count = domain_iter_count / 100 ;
217253
218254 let mut total_iterations = match ctx. gen_kind {
219- GeneratorKind :: QuickSpaced => domain_iter_count,
255+ GeneratorKind :: Spaced if ctx. extensive => extensive_max_iterations ( ) ,
256+ GeneratorKind :: Spaced => domain_iter_count,
220257 GeneratorKind :: Random => random_iter_count,
221- GeneratorKind :: Extensive => extensive_max_iterations ( ) ,
222258 GeneratorKind :: EdgeCases | GeneratorKind :: List => {
223259 unimplemented ! ( "shoudn't need `iteration_count` for {:?}" , ctx. gen_kind)
224260 }
225261 } ;
226262
227263 // Larger float types get more iterations.
228- if t_env. large_float_ty && ctx . gen_kind != GeneratorKind :: Extensive {
229- if ctx. gen_kind == GeneratorKind :: Extensive {
264+ if t_env. large_float_ty {
265+ if ctx. extensive {
230266 // Extensive already has a pretty high test count.
231267 total_iterations *= 2 ;
232268 } else {
@@ -244,13 +280,13 @@ pub fn iteration_count(ctx: &CheckCtx, argnum: usize) -> u64 {
244280 }
245281
246282 // Some tests are significantly slower than others and need to be further reduced.
247- if let Some ( ( _id , _gen , scale ) ) = EXTEMELY_SLOW_TESTS
283+ if let Some ( slow ) = EXTREMELY_SLOW_TESTS
248284 . iter ( )
249- . find ( |( id , generator , _scale ) | * id == ctx . fn_ident && * generator == ctx. gen_kind )
285+ . find ( |slow| slow . matches_ctx ( ctx) )
250286 {
251287 // However, do not override if the extensive iteration count has been manually set.
252- if !( ctx. gen_kind == GeneratorKind :: Extensive && EXTENSIVE_ITER_OVERRIDE . is_some ( ) ) {
253- total_iterations /= scale ;
288+ if !( ctx. extensive && EXTENSIVE_ITER_OVERRIDE . is_some ( ) ) {
289+ total_iterations /= slow . reduce_factor ;
254290 }
255291 }
256292
@@ -279,7 +315,7 @@ pub fn iteration_count(ctx: &CheckCtx, argnum: usize) -> u64 {
279315 let total = ntests. pow ( t_env. input_count . try_into ( ) . unwrap ( ) ) ;
280316
281317 let seed_msg = match ctx. gen_kind {
282- GeneratorKind :: QuickSpaced | GeneratorKind :: Extensive => String :: new ( ) ,
318+ GeneratorKind :: Spaced => String :: new ( ) ,
283319 GeneratorKind :: Random => {
284320 format ! (
285321 " using `{SEED_ENV}={}`" ,
@@ -327,8 +363,8 @@ pub fn int_range(ctx: &CheckCtx, argnum: usize) -> RangeInclusive<i32> {
327363 let extensive_range = ( -0xfff ) ..=0xfffff ;
328364
329365 match ctx. gen_kind {
330- GeneratorKind :: Extensive => extensive_range,
331- GeneratorKind :: QuickSpaced | GeneratorKind :: Random => non_extensive_range,
366+ _ if ctx . extensive => extensive_range,
367+ GeneratorKind :: Spaced | GeneratorKind :: Random => non_extensive_range,
332368 GeneratorKind :: EdgeCases => extensive_range,
333369 GeneratorKind :: List => unimplemented ! ( "shoudn't need range for {:?}" , ctx. gen_kind) ,
334370 }
0 commit comments