public inbox for libstdc++-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-8423] libstdc++: Reduce <random> test iterations for simulators Date: Fri, 27 May 2022 17:33:50 +0000 (GMT) [thread overview] Message-ID: <20220527173350.A51E938293C1@sourceware.org> (raw) https://gcc.gnu.org/g:871aa113666dc787bcc70c94b183e3e420c09e6d commit r12-8423-g871aa113666dc787bcc70c94b183e3e420c09e6d Author: Jonathan Wakely <jwakely@redhat.com> Date: Fri May 20 15:44:25 2022 +0100 libstdc++: Reduce <random> test iterations for simulators Some of these tests take several minutes on a simulator like cris-elf, so we can conditionally run fewer iterations. The testDiscreteDist helper already supports custom sizes so we just need to make use of that when { target simulator } matches. The relevant code is sufficiently tested on other targets, so we're not losing anything by only running a small number of iterators for sims. libstdc++-v3/ChangeLog: * testsuite/26_numerics/random/bernoulli_distribution/operators/values.cc: Run fewer iterations for simulator targets. * testsuite/26_numerics/random/binomial_distribution/operators/values.cc: Likewise. * testsuite/26_numerics/random/discrete_distribution/operators/values.cc: Likewise. * testsuite/26_numerics/random/geometric_distribution/operators/values.cc: Likewise. * testsuite/26_numerics/random/negative_binomial_distribution/operators/values.cc: Likewise. * testsuite/26_numerics/random/poisson_distribution/operators/values.cc: Likewise. * testsuite/26_numerics/random/uniform_int_distribution/operators/values.cc: Likewise. (cherry picked from commit e3b8b4f7814c54543d9b7ea3ee8cf2cb9cff351d) Diff: --- .../bernoulli_distribution/operators/values.cc | 14 +++++++++++--- .../random/binomial_distribution/operators/values.cc | 12 ++++++++++-- .../random/discrete_distribution/operators/values.cc | 8 ++++++++ .../geometric_distribution/operators/values.cc | 14 +++++++++++--- .../operators/values.cc | 20 ++++++++++++++------ .../random/poisson_distribution/operators/values.cc | 15 +++++++++++---- .../uniform_int_distribution/operators/values.cc | 14 +++++++++++--- 7 files changed, 76 insertions(+), 21 deletions(-) diff --git a/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/operators/values.cc b/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/operators/values.cc index 4100692981c..b2cb86f976b 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/operators/values.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/operators/values.cc @@ -24,6 +24,14 @@ #include <functional> #include <testsuite_random.h> +// { dg-additional-options "-DSIMULATOR_TEST" { target simulator } } + +#ifdef SIMULATOR_TEST +# define ARGS 100, 1000 +#else +# define ARGS +#endif + void test01() { using namespace __gnu_test; @@ -32,15 +40,15 @@ void test01() std::bernoulli_distribution bd1(0.25); auto bbd1 = std::bind(bd1, eng); - testDiscreteDist(bbd1, [](int n) { return bernoulli_pdf(n, 0.25); } ); + testDiscreteDist<ARGS>(bbd1, [](int n) { return bernoulli_pdf(n, 0.25); } ); std::bernoulli_distribution bd2(0.5); auto bbd2 = std::bind(bd2, eng); - testDiscreteDist(bbd2, [](int n) { return bernoulli_pdf(n, 0.5); } ); + testDiscreteDist<ARGS>(bbd2, [](int n) { return bernoulli_pdf(n, 0.5); } ); std::bernoulli_distribution bd3(0.75); auto bbd3 = std::bind(bd3, eng); - testDiscreteDist(bbd3, [](int n) { return bernoulli_pdf(n, 0.75); } ); + testDiscreteDist<ARGS>(bbd3, [](int n) { return bernoulli_pdf(n, 0.75); } ); } int main() diff --git a/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/operators/values.cc b/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/operators/values.cc index 96570d59fb3..efa259b7e03 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/operators/values.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/operators/values.cc @@ -25,6 +25,14 @@ #include <functional> #include <testsuite_random.h> +// { dg-additional-options "-DSIMULATOR_TEST" { target simulator } } + +#ifdef SIMULATOR_TEST +# define ARGS 100, 1000 +#else +# define ARGS +#endif + void test01() { using namespace __gnu_test; @@ -33,9 +41,9 @@ void test01() std::binomial_distribution<> bd1(5, 0.3); auto bbd1 = std::bind(bd1, eng); - testDiscreteDist(bbd1, [](int n) { return binomial_pdf(n, 5, 0.3); } ); + testDiscreteDist<ARGS>(bbd1, [](int n) { return binomial_pdf(n, 5, 0.3); } ); - // These tests take a relatively long time on soft-float simulated + // These tests take a relatively long time on soft-float simulated targets. // targets, so please don't add new tests here, instead add a new file. } diff --git a/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/operators/values.cc b/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/operators/values.cc index 1cedd6434ca..8bacb86e173 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/operators/values.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/operators/values.cc @@ -24,6 +24,14 @@ #include <functional> #include <testsuite_random.h> +// { dg-additional-options "-DSIMULATOR_TEST" { target simulator } } + +#ifdef SIMULATOR_TEST +# define ARGS 100, 1000 +#else +# define ARGS +#endif + void test01() { using namespace __gnu_test; diff --git a/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/operators/values.cc b/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/operators/values.cc index 65e0e79217b..41a83b1377b 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/operators/values.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/operators/values.cc @@ -24,6 +24,14 @@ #include <functional> #include <testsuite_random.h> +// { dg-additional-options "-DSIMULATOR_TEST" { target simulator } } + +#ifdef SIMULATOR_TEST +# define ARGS 100, 1000 +#else +# define ARGS +#endif + void test01() { using namespace __gnu_test; @@ -32,16 +40,16 @@ void test01() std::geometric_distribution<> gd1(0.5); auto bgd1 = std::bind(gd1, eng); - testDiscreteDist(bgd1, [](int n) { return geometric_pdf(n, 0.5); } ); + testDiscreteDist<ARGS>(bgd1, [](int n) { return geometric_pdf(n, 0.5); } ); std::geometric_distribution<> gd2(0.75); auto bgd2 = std::bind(gd2, eng); - testDiscreteDist(bgd2, [](int n) { return geometric_pdf(n, 0.75); } ); + testDiscreteDist<ARGS>(bgd2, [](int n) { return geometric_pdf(n, 0.75); } ); // libstdc++/48114 std::geometric_distribution<> gd3(0.25); auto bgd3 = std::bind(gd3, eng); - testDiscreteDist(bgd3, [](int n) { return geometric_pdf(n, 0.25); } ); + testDiscreteDist<ARGS>(bgd3, [](int n) { return geometric_pdf(n, 0.25); } ); } int main() diff --git a/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/operators/values.cc b/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/operators/values.cc index dda6f43b254..9856b888577 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/operators/values.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/operators/values.cc @@ -26,6 +26,14 @@ #include <functional> #include <testsuite_random.h> +// { dg-additional-options "-DSIMULATOR_TEST" { target simulator } } + +#ifdef SIMULATOR_TEST +# define ARGS 100, 1000 +#else +# define ARGS +#endif + void test01() { using namespace __gnu_test; @@ -34,18 +42,18 @@ void test01() std::negative_binomial_distribution<> nbd1(5, 0.3); auto bnbd1 = std::bind(nbd1, eng); - testDiscreteDist(bnbd1, [](int n) - { return negative_binomial_pdf(n, 5, 0.3); } ); + testDiscreteDist<ARGS>(bnbd1, [](int n) + { return negative_binomial_pdf(n, 5, 0.3); } ); std::negative_binomial_distribution<> nbd2(55, 0.3); auto bnbd2 = std::bind(nbd2, eng); - testDiscreteDist(bnbd2, [](int n) - { return negative_binomial_pdf(n, 55, 0.3); } ); + testDiscreteDist<ARGS>(bnbd2, [](int n) + { return negative_binomial_pdf(n, 55, 0.3); } ); std::negative_binomial_distribution<> nbd3(10, 0.75); auto bnbd3 = std::bind(nbd3, eng); - testDiscreteDist(bnbd3, [](int n) - { return negative_binomial_pdf(n, 10, 0.75); } ); + testDiscreteDist<ARGS>(bnbd3, [](int n) + { return negative_binomial_pdf(n, 10, 0.75); } ); } int main() diff --git a/libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/operators/values.cc b/libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/operators/values.cc index 169d720d596..05e8c9f9eb1 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/operators/values.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/operators/values.cc @@ -1,4 +1,3 @@ -// { dg-options "-DSIMULATOR_TEST" { target simulator } } // { dg-do run { target c++11 } } // { dg-require-cstdint "" } // { dg-require-cmath "" } @@ -26,6 +25,14 @@ #include <functional> #include <testsuite_random.h> +// { dg-additional-options "-DSIMULATOR_TEST" { target simulator } } + +#ifdef SIMULATOR_TEST +# define ARGS 100, 1000 +#else +# define ARGS +#endif + void test01() { using namespace __gnu_test; @@ -34,15 +41,15 @@ void test01() std::poisson_distribution<> pd1(3.0); auto bpd1 = std::bind(pd1, eng); - testDiscreteDist(bpd1, [](int n) { return poisson_pdf(n, 3.0); } ); + testDiscreteDist<ARGS>(bpd1, [](int n) { return poisson_pdf(n, 3.0); } ); std::poisson_distribution<> pd2(15.0); auto bpd2 = std::bind(pd2, eng); - testDiscreteDist(bpd2, [](int n) { return poisson_pdf(n, 15.0); } ); + testDiscreteDist<ARGS>(bpd2, [](int n) { return poisson_pdf(n, 15.0); } ); std::poisson_distribution<> pd3(30.0); auto bpd3 = std::bind(pd3, eng); - testDiscreteDist(bpd3, [](int n) { return poisson_pdf(n, 30.0); } ); + testDiscreteDist<ARGS>(bpd3, [](int n) { return poisson_pdf(n, 30.0); } ); // This can take extremely long on simulators, timing out the test. #ifndef SIMULATOR_TEST diff --git a/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/operators/values.cc b/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/operators/values.cc index c1e4b4944cc..ee1ea7ebe5f 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/operators/values.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/operators/values.cc @@ -24,6 +24,14 @@ #include <functional> #include <testsuite_random.h> +// { dg-additional-options "-DSIMULATOR_TEST" { target simulator } } + +#ifdef SIMULATOR_TEST +# define ARGS 100, 1000 +#else +# define ARGS +#endif + void test01() { using namespace __gnu_test; @@ -32,15 +40,15 @@ void test01() std::uniform_int_distribution<> uid1(0, 2); auto buid1 = std::bind(uid1, eng); - testDiscreteDist(buid1, [](int n) { return uniform_int_pdf(n, 0, 2); } ); + testDiscreteDist<ARGS>(buid1, [](int n) { return uniform_int_pdf(n, 0, 2); } ); std::uniform_int_distribution<> uid2(3, 7); auto buid2 = std::bind(uid2, eng); - testDiscreteDist(buid2, [](int n) { return uniform_int_pdf(n, 3, 7); } ); + testDiscreteDist<ARGS>(buid2, [](int n) { return uniform_int_pdf(n, 3, 7); } ); std::uniform_int_distribution<> uid3(1, 20); auto buid3 = std::bind(uid3, eng); - testDiscreteDist(buid3, [](int n) { return uniform_int_pdf(n, 1, 20); } ); + testDiscreteDist<ARGS>(buid3, [](int n) { return uniform_int_pdf(n, 1, 20); } ); } int main()
reply other threads:[~2022-05-27 17:33 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220527173350.A51E938293C1@sourceware.org \ --to=redi@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).