From 43963820a926af3d3fb0327260b7621fec31c04a Mon Sep 17 00:00:00 2001 From: Matt Keeter Date: Wed, 20 Mar 2024 08:49:10 -0400 Subject: [PATCH 1/2] Do interval tests in parallel --- fidget/src/core/eval/test/interval.rs | 82 +++++++++++++++++---------- fidget/src/core/eval/test/mod.rs | 2 +- 2 files changed, 52 insertions(+), 32 deletions(-) diff --git a/fidget/src/core/eval/test/interval.rs b/fidget/src/core/eval/test/interval.rs index c5e5003f..2e56cda2 100644 --- a/fidget/src/core/eval/test/interval.rs +++ b/fidget/src/core/eval/test/interval.rs @@ -889,40 +889,11 @@ where } } - pub fn test_i_unary_ops() { - use super::canonical::*; - - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - } - pub fn test_binary() { Self::test_binary_reg_reg::(); Self::test_binary_reg_imm::(); Self::test_binary_imm_reg::(); } - - pub fn test_i_binary_ops() { - use super::canonical::*; - - Self::test_binary::(); - Self::test_binary::(); - Self::test_binary::(); - Self::test_binary::
(); - Self::test_binary::(); - Self::test_binary::(); - } } #[macro_export] @@ -935,6 +906,30 @@ macro_rules! interval_test { }; } +#[macro_export] +macro_rules! interval_unary_test { + ($i:ident, $t:ty) => { + #[test] + fn $i() { + $crate::eval::test::interval::TestInterval::<$t>::test_unary::< + $crate::eval::test::canonical::$i, + >() + } + }; +} + +#[macro_export] +macro_rules! interval_binary_test { + ($i:ident, $t:ty) => { + #[test] + fn $i() { + $crate::eval::test::interval::TestInterval::<$t>::test_binary::< + $crate::eval::test::canonical::$i, + >() + } + }; +} + #[macro_export] macro_rules! interval_tests { ($t:ty) => { @@ -957,7 +952,32 @@ macro_rules! interval_tests { $crate::interval_test!(test_i_simplify, $t); $crate::interval_test!(test_i_var, $t); $crate::interval_test!(test_i_stress, $t); - $crate::interval_test!(test_i_unary_ops, $t); - $crate::interval_test!(test_i_binary_ops, $t); + + mod i_unary { + use super::*; + $crate::interval_unary_test!(neg, $t); + $crate::interval_unary_test!(recip, $t); + $crate::interval_unary_test!(abs, $t); + $crate::interval_unary_test!(sin, $t); + $crate::interval_unary_test!(cos, $t); + $crate::interval_unary_test!(tan, $t); + $crate::interval_unary_test!(asin, $t); + $crate::interval_unary_test!(acos, $t); + $crate::interval_unary_test!(atan, $t); + $crate::interval_unary_test!(exp, $t); + $crate::interval_unary_test!(ln, $t); + $crate::interval_unary_test!(square, $t); + $crate::interval_unary_test!(sqrt, $t); + } + + mod i_binary { + use super::*; + $crate::interval_binary_test!(add, $t); + $crate::interval_binary_test!(sub, $t); + $crate::interval_binary_test!(mul, $t); + $crate::interval_binary_test!(div, $t); + $crate::interval_binary_test!(min, $t); + $crate::interval_binary_test!(max, $t); + } }; } diff --git a/fidget/src/core/eval/test/mod.rs b/fidget/src/core/eval/test/mod.rs index 4eda05e0..e738617d 100644 --- a/fidget/src/core/eval/test/mod.rs +++ b/fidget/src/core/eval/test/mod.rs @@ -157,7 +157,7 @@ macro_rules! declare_canonical_binary_full { } #[allow(non_camel_case_types)] -mod canonical { +pub mod canonical { use super::*; declare_canonical_unary!(Context::neg, |a| -a); From e2bb86c31b49198a9c3b9ad2c2149553950bd237 Mon Sep 17 00:00:00 2001 From: Matt Keeter Date: Wed, 20 Mar 2024 09:19:30 -0400 Subject: [PATCH 2/2] Do all other bulk tests in parallel too --- fidget/src/core/eval/test/float_slice.rs | 45 +++++++-------------- fidget/src/core/eval/test/grad_slice.rs | 45 +++++++-------------- fidget/src/core/eval/test/interval.rs | 49 +++-------------------- fidget/src/core/eval/test/mod.rs | 51 ++++++++++++++++++++++++ fidget/src/core/eval/test/point.rs | 45 +++++++-------------- 5 files changed, 99 insertions(+), 136 deletions(-) diff --git a/fidget/src/core/eval/test/float_slice.rs b/fidget/src/core/eval/test/float_slice.rs index 64928d72..b450ac85 100644 --- a/fidget/src/core/eval/test/float_slice.rs +++ b/fidget/src/core/eval/test/float_slice.rs @@ -439,40 +439,11 @@ where } } - pub fn test_f_unary_ops() { - use super::canonical::*; - - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - } - pub fn test_binary() { Self::test_binary_reg_reg::(); Self::test_binary_reg_imm::(); Self::test_binary_imm_reg::(); } - - pub fn test_f_binary_ops() { - use super::canonical::*; - - Self::test_binary::(); - Self::test_binary::(); - Self::test_binary::(); - Self::test_binary::
(); - Self::test_binary::(); - Self::test_binary::(); - } } #[macro_export] @@ -493,7 +464,19 @@ macro_rules! float_slice_tests { $crate::float_slice_test!(test_f_var, $t); $crate::float_slice_test!(test_f_sin, $t); $crate::float_slice_test!(test_f_stress, $t); - $crate::float_slice_test!(test_f_unary_ops, $t); - $crate::float_slice_test!(test_f_binary_ops, $t); + + mod f_unary { + use super::*; + $crate::all_unary_tests!( + $crate::eval::test::float_slice::TestFloatSlice::<$t> + ); + } + + mod f_binary { + use super::*; + $crate::all_binary_tests!( + $crate::eval::test::float_slice::TestFloatSlice::<$t> + ); + } }; } diff --git a/fidget/src/core/eval/test/grad_slice.rs b/fidget/src/core/eval/test/grad_slice.rs index 242a00a3..2969fcdb 100644 --- a/fidget/src/core/eval/test/grad_slice.rs +++ b/fidget/src/core/eval/test/grad_slice.rs @@ -699,40 +699,11 @@ where } } - pub fn test_g_unary_ops() { - use super::canonical::*; - - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - } - pub fn test_binary() { Self::test_binary_reg_reg::(); Self::test_binary_reg_imm::(); Self::test_binary_imm_reg::(); } - - pub fn test_g_binary_ops() { - use super::canonical::*; - - Self::test_binary::(); - Self::test_binary::(); - Self::test_binary::(); - Self::test_binary::
(); - Self::test_binary::(); - Self::test_binary::(); - } } #[macro_export] @@ -764,7 +735,19 @@ macro_rules! grad_slice_tests { $crate::grad_test!(test_g_recip, $t); $crate::grad_test!(test_g_var, $t); $crate::grad_test!(test_g_stress, $t); - $crate::grad_test!(test_g_unary_ops, $t); - $crate::grad_test!(test_g_binary_ops, $t); + + mod g_unary { + use super::*; + $crate::all_unary_tests!( + $crate::eval::test::grad_slice::TestGradSlice::<$t> + ); + } + + mod g_binary { + use super::*; + $crate::all_binary_tests!( + $crate::eval::test::grad_slice::TestGradSlice::<$t> + ); + } }; } diff --git a/fidget/src/core/eval/test/interval.rs b/fidget/src/core/eval/test/interval.rs index 2e56cda2..349fe6c3 100644 --- a/fidget/src/core/eval/test/interval.rs +++ b/fidget/src/core/eval/test/interval.rs @@ -906,30 +906,6 @@ macro_rules! interval_test { }; } -#[macro_export] -macro_rules! interval_unary_test { - ($i:ident, $t:ty) => { - #[test] - fn $i() { - $crate::eval::test::interval::TestInterval::<$t>::test_unary::< - $crate::eval::test::canonical::$i, - >() - } - }; -} - -#[macro_export] -macro_rules! interval_binary_test { - ($i:ident, $t:ty) => { - #[test] - fn $i() { - $crate::eval::test::interval::TestInterval::<$t>::test_binary::< - $crate::eval::test::canonical::$i, - >() - } - }; -} - #[macro_export] macro_rules! interval_tests { ($t:ty) => { @@ -955,29 +931,16 @@ macro_rules! interval_tests { mod i_unary { use super::*; - $crate::interval_unary_test!(neg, $t); - $crate::interval_unary_test!(recip, $t); - $crate::interval_unary_test!(abs, $t); - $crate::interval_unary_test!(sin, $t); - $crate::interval_unary_test!(cos, $t); - $crate::interval_unary_test!(tan, $t); - $crate::interval_unary_test!(asin, $t); - $crate::interval_unary_test!(acos, $t); - $crate::interval_unary_test!(atan, $t); - $crate::interval_unary_test!(exp, $t); - $crate::interval_unary_test!(ln, $t); - $crate::interval_unary_test!(square, $t); - $crate::interval_unary_test!(sqrt, $t); + $crate::all_unary_tests!( + $crate::eval::test::interval::TestInterval::<$t> + ); } mod i_binary { use super::*; - $crate::interval_binary_test!(add, $t); - $crate::interval_binary_test!(sub, $t); - $crate::interval_binary_test!(mul, $t); - $crate::interval_binary_test!(div, $t); - $crate::interval_binary_test!(min, $t); - $crate::interval_binary_test!(max, $t); + $crate::all_binary_tests!( + $crate::eval::test::interval::TestInterval::<$t> + ); } }; } diff --git a/fidget/src/core/eval/test/mod.rs b/fidget/src/core/eval/test/mod.rs index e738617d..7609bba2 100644 --- a/fidget/src/core/eval/test/mod.rs +++ b/fidget/src/core/eval/test/mod.rs @@ -205,3 +205,54 @@ pub mod canonical { } ); } + +#[macro_export] +macro_rules! one_unary_test { + ($tester:ty, $i:ident) => { + #[test] + fn $i() { + <$tester>::test_unary::<$crate::eval::test::canonical::$i>() + } + }; +} + +#[macro_export] +macro_rules! one_binary_test { + ($tester:ty, $i:ident) => { + #[test] + fn $i() { + <$tester>::test_binary::<$crate::eval::test::canonical::$i>() + } + }; +} + +#[macro_export] +macro_rules! all_unary_tests { + ($tester:ty) => { + $crate::one_unary_test!($tester, neg); + $crate::one_unary_test!($tester, recip); + $crate::one_unary_test!($tester, abs); + $crate::one_unary_test!($tester, sin); + $crate::one_unary_test!($tester, cos); + $crate::one_unary_test!($tester, tan); + $crate::one_unary_test!($tester, asin); + $crate::one_unary_test!($tester, acos); + $crate::one_unary_test!($tester, atan); + $crate::one_unary_test!($tester, exp); + $crate::one_unary_test!($tester, ln); + $crate::one_unary_test!($tester, square); + $crate::one_unary_test!($tester, sqrt); + }; +} + +#[macro_export] +macro_rules! all_binary_tests { + ($tester:ty) => { + $crate::one_binary_test!($tester, add); + $crate::one_binary_test!($tester, sub); + $crate::one_binary_test!($tester, mul); + $crate::one_binary_test!($tester, div); + $crate::one_binary_test!($tester, min); + $crate::one_binary_test!($tester, max); + }; +} diff --git a/fidget/src/core/eval/test/point.rs b/fidget/src/core/eval/test/point.rs index 9a9cb454..dc2ca221 100644 --- a/fidget/src/core/eval/test/point.rs +++ b/fidget/src/core/eval/test/point.rs @@ -556,35 +556,6 @@ where Self::test_binary_reg_imm::(); Self::test_binary_imm_reg::(); } - - pub fn test_p_binary_ops() { - use super::canonical::*; - - Self::test_binary::(); - Self::test_binary::(); - Self::test_binary::(); - Self::test_binary::
(); - Self::test_binary::(); - Self::test_binary::(); - } - - pub fn test_p_unary_ops() { - use super::canonical::*; - - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - Self::test_unary::(); - } } #[macro_export] @@ -611,7 +582,19 @@ macro_rules! point_tests { $crate::point_test!(test_var, $t); $crate::point_test!(test_basic, $t); $crate::point_test!(test_p_stress, $t); - $crate::point_test!(test_p_unary_ops, $t); - $crate::point_test!(test_p_binary_ops, $t); + + mod p_unary { + use super::*; + $crate::all_unary_tests!( + $crate::eval::test::point::TestPoint::<$t> + ); + } + + mod p_binary { + use super::*; + $crate::all_binary_tests!( + $crate::eval::test::point::TestPoint::<$t> + ); + } }; }