From patchwork Tue Jan 2 03:22:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Peter Nilsson X-Patchwork-Id: 184207 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4250921dyb; Mon, 1 Jan 2024 19:24:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IEay/beurHIAOB5pLm6zn1px0fhXWxtQ0wEVUTsV6cpfQJIFTTSbNzRXsnSyKHBG/GKxMIQ X-Received: by 2002:a05:622a:130c:b0:427:ea02:45e2 with SMTP id v12-20020a05622a130c00b00427ea0245e2mr9374706qtk.57.1704165839833; Mon, 01 Jan 2024 19:23:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704165839; cv=pass; d=google.com; s=arc-20160816; b=j9lWvn21zX7Xz7ycohBRO4ycNCOuTVntqMEmQcQIjqP1Hn2qQhVxKvtxPTIo1E1exi 96J7sRj+VTMN/0777tnttg0Eye6QBebHk/D4x//C5NVqht9tSKxZs4JVxPIYGm2i792l BNDwer76cAxiA+nkjckI4zxq3yBcS9aCOxe1MEetN0cRlKmkXrplpfpEME8LBxkoUEyU byh0sIwBaFpP1ZROtdQ37NDI5cuRVslr9kmgSOqAJdbP2hHaQj6kR2Rc4pTcLLt2e1RZ fK+u0l/FPgEgQSpWnXC64nfPOQ/klgQvaoD9XRy3OoR8AJP7ZwpvxwIs4uEazdsvzkVN 4D8A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:user-agent :message-id:subject:to:from:date:arc-filter:dmarc-filter :delivered-to; bh=IQxpTlUpsxaMtn2fODg5vHaulgKGasA/whlpI3c1V/Q=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=Fb1eHSvulCNZeQk3sEVCrPencwzCGwtEVByWfB/o0149rU1Bcuoj3y14tXIVAvD394 yWP3Av1lhWIl9SikEDoz8doLsmdU5/f+APSKT3kvHu8vla9lgtBWxWfznJakwL4BWRy2 5R9w4DO9PHc7wk5fluI/KHa4I57VqreqVCpvSIWET89OjjFSSQVe8JniET3wclgOjWda 7z7TQZXnkUQPdxyKw7Cf7criNvmrtPtK0/jpTA6G88e92wm7/GK+RMbBiB9aAtWGM7Ud wlgGuW4TBAvb8uewTDdKMif5FWBYnYmeGQjpXGAJfN+y4Dg5u6g4FomfjDVcw2EgP1Yb joiA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id b9-20020ac85bc9000000b00428142be417si5957161qtb.420.2024.01.01.19.23.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 19:23:59 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7942D3858415 for ; Tue, 2 Jan 2024 03:23:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from arjuna.pair.com (arjuna.pair.com [209.68.5.131]) by sourceware.org (Postfix) with ESMTPS id CA0843858D1E for ; Tue, 2 Jan 2024 03:22:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CA0843858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=bitrange.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bitrange.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CA0843858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.68.5.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704165777; cv=none; b=W1fMIhuqqwjaMOOzpLpS1EHnx1bRoF5XY33pyTqEacqZU4NkKzvdjXgV1uFTRdV5T8IOXnrzlc07rne2QrBAjf060z0I/oEeBHY3hJZSEyVnXFVkRRtYck+1hTcRkvkCpS5GOaomo/9L2lkjHMjkc5PFckemeUn8Sd9vzGdxTlE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704165777; c=relaxed/simple; bh=zdqdv6gmXrMb/wxbSts8rS1qGrlhkTtZd481B7A5XYw=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=MegJT8Nxcm0mPeVcfFboo+dB1VsGf147smKgAxBzmu6PC/MAHg/RF4/MwhjrwgaR1fEP8FHJgABWY/Bv7EPMLG+E4Pyy33PWDQ56xf8CxxrfRWB8Eka3Z71oPikB6WmQHuJr75YdvpcKVM3zYMOJtTF3a6H2HqF9lDQgbDH6LVM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by arjuna.pair.com (Postfix, from userid 3006) id 2D0F18A64F; Mon, 1 Jan 2024 22:22:53 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by arjuna.pair.com (Postfix) with ESMTP id 2B1298A637 for ; Mon, 1 Jan 2024 22:22:53 -0500 (EST) Date: Mon, 1 Jan 2024 22:22:53 -0500 (EST) From: Hans-Peter Nilsson X-X-Sender: hp@arjuna.pair.com To: gcc-patches@gcc.gnu.org Subject: [PATCH] testsuite: Reduce gcc.dg/torture/inline-mem-cpy-1.c by 11 for simulators Message-ID: User-Agent: Alpine 2.20.16 (BSF 172 2016-09-29) MIME-Version: 1.0 X-Scanned-By: mailmunge 3.11 on 209.68.5.131 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786947399641883077 X-GMAIL-MSGID: 1786947399641883077 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;lTZONE)?(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"