From: Hans-Peter Nilsson <hp@bitrange.com>
To: gcc-patches@gcc.gnu.org
Subject: Ping [PATCH] testsuite: Reduce gcc.dg/torture/inline-mem-cpy-1.c by 11 for simulators
Date: Fri, 12 Jan 2024 05:52:12 -0500 (EST) [thread overview]
Message-ID: <alpine.BSF.2.20.16.2401120550410.56116@arjuna.pair.com> (raw)
In-Reply-To: <alpine.BSF.2.20.16.2401012219490.56278@arjuna.pair.com>
Ping. (Don't miss the gcc.dg/torture/inline-mem-cpy-1.c part.)
On Mon, 1 Jan 2024, Hans-Peter Nilsson wrote:
> Tested mmix-knuth-mmixware (where all torture-variants of
> gcc.dg/torture/inline-mem-cpy-1.c now pass) and native
> x86_64-pc-linux-gnu. Also stepped through the test for native,
> w/wo. RUN_FRACTION defined to see that it worked as intended.
>
> You may wonder what about the "sibling" tests inline-mem-cmp-1.c and
> inline-mem-cpy-cmp-1.c. Well, they FAIL, but not because of
> timeouts(!) To be continued....
>
> Ok to commit?
>
> Or, other suggestions?
>
> -- >8 --
> The test inline-mem-cpy-1.c takes 16 minutes at -O0 for the mmix
> simulator on a 3.5 year old laptop and thus always times out, despite
> the x 2 timeout (i.e. 10 minutes), and times out at all optimization
> levels. For the included file (when run as gcc.dg/memcmp-1.c), the
> execution time on the same host is 9 minutes 54 seconds, so just
> within 10 minutes timeout limit. Seems pragmatically best to reduce
> the torture-test by a factor of about 10, but there's no obvious small
> set of entities to scale down to get the intended effect, and
> splitting up the test into several tests seem a bit too intrusive.
>
> Instead, introduce pseudo-random machinery to skip all but each
> RUN_FRACTION:th iteration, defaulting to no change when RUN_FRACTION
> isn't defined. Use 11 for RUN_FRACTION, assuming this prime will lead
> to even distribution within nested iterations with loops looking like
> (0, 1) : (0, 1). Do this only for the main loop in
> test_driver_memcmp; the "outermost" two levels of iterations.
>
> With this, execution time for -O0 as above is down to 1 minute 32
> seconds.
>
> * gcc.dg/torture/inline-mem-cpy-1.c: Pass -DRUN_FRACTION=11
> when testing in a simulator.
> * gcc.dg/memcmp-1.c [RUN_FRACTION]: Add machinery to run only
> for each RUN_FRACTION:th iteration.
> (main): Call initialize_skip_iteration_count.
> (test_driver_memcmp): Check SKIP_ITERATION for each iteration.
> ---
> gcc/testsuite/gcc.dg/memcmp-1.c | 35 +++++++++++++++++++
> .../gcc.dg/torture/inline-mem-cpy-1.c | 1 +
> 2 files changed, 36 insertions(+)
>
> diff --git a/gcc/testsuite/gcc.dg/memcmp-1.c b/gcc/testsuite/gcc.dg/memcmp-1.c
> index ea837ca0f577..13ef5b3380d0 100644
> --- a/gcc/testsuite/gcc.dg/memcmp-1.c
> +++ b/gcc/testsuite/gcc.dg/memcmp-1.c
> @@ -34,6 +34,36 @@ int lib_strncmp(const char *a, const char *b, size_t n)
>
> #define MAX_SZ 600
>
> +/* A means to run only a fraction of the tests, beginning at a random
> + count. */
> +#ifdef RUN_FRACTION
> +
> +#define SKIP_ITERATION skip_iteration ()
> +static unsigned int iteration_count;
> +
> +static _Bool
> +skip_iteration (void)
> +{
> + _Bool run = ++iteration_count == RUN_FRACTION;
> +
> + if (run)
> + iteration_count = 0;
> +
> + return !run;
> +}
> +
> +static void
> +initialize_skip_iteration_count ()
> +{
> + srand (2024);
> + iteration_count = (unsigned int) (rand ()) % RUN_FRACTION;
> +}
> +
> +#else
> +#define SKIP_ITERATION 0
> +#define initialize_skip_iteration_count()
> +#endif
> +
> #define DEF_RS(ALIGN) \
> static void test_memcmp_runtime_size_ ## ALIGN (const char *str1, \
> const char *str2, \
> @@ -110,6 +140,8 @@ static void test_driver_memcmp (void (test_memcmp)(const char *, const char *, i
> int i,j,l;
> for(l=0;l<sz;l++) {
> for(i=0;i<NRAND/sz;i++) {
> + if (SKIP_ITERATION)
> + continue;
> for(j=0;j<l;j++) {
> buf1[j] = rand() & 0xff;
> buf2[j] = buf1[j];
> @@ -128,6 +160,8 @@ static void test_driver_memcmp (void (test_memcmp)(const char *, const char *, i
> for(diff_pos = ((test_sz>TZONE)?(test_sz-TZONE):0); diff_pos < test_sz+TZONE; diff_pos++)
> for(zero_pos = ((test_sz>TZONE)?(test_sz-TZONE):0); zero_pos < test_sz+TZONE; zero_pos++)
> {
> + if (SKIP_ITERATION)
> + continue;
> memset(buf1, 'A', 2*test_sz);
> memset(buf2, 'A', 2*test_sz);
> buf2[diff_pos] = 'B';
> @@ -490,6 +524,7 @@ DEF_TEST(49,1)
> int
> main(int argc, char **argv)
> {
> + initialize_skip_iteration_count ();
> #ifdef TEST_ALL
> RUN_TEST(1,1)
> RUN_TEST(1,2)
> diff --git a/gcc/testsuite/gcc.dg/torture/inline-mem-cpy-1.c b/gcc/testsuite/gcc.dg/torture/inline-mem-cpy-1.c
> index f4952554dd01..f0752349571b 100644
> --- a/gcc/testsuite/gcc.dg/torture/inline-mem-cpy-1.c
> +++ b/gcc/testsuite/gcc.dg/torture/inline-mem-cpy-1.c
> @@ -1,5 +1,6 @@
> /* { dg-do run } */
> /* { dg-options "-finline-stringops=memcpy -save-temps -g0 -fno-lto" } */
> +/* { dg-additional-options "-DRUN_FRACTION=11" { target simulator } } */
> /* { dg-timeout-factor 2 } */
>
> #include "../memcmp-1.c"
> --
> 2.30.2
>
>
next prev parent reply other threads:[~2024-01-12 10:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-02 3:22 Hans-Peter Nilsson
2024-01-02 17:38 ` Jeff Law
2024-01-02 21:07 ` Hans-Peter Nilsson
2024-01-16 14:09 ` Jeff Law
2024-01-12 10:52 ` Hans-Peter Nilsson [this message]
2024-01-12 17:57 ` Ping " Mike Stump
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=alpine.BSF.2.20.16.2401120550410.56116@arjuna.pair.com \
--to=hp@bitrange.com \
--cc=gcc-patches@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: link
Be 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).