From patchwork Wed May 19 02:24:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noah Goldstein X-Patchwork-Id: 1480638 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=Ke0Uawyl; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FlGsv5ZSCz9sTD for ; Wed, 19 May 2021 12:24:51 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 97AC6384F03C; Wed, 19 May 2021 02:24:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 97AC6384F03C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1621391088; bh=N0NRxAmhXnit5eF3bJXlxMN7GF2z2pB8pFKqaTAn6oQ=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Ke0UawylluBxXzJi8QyzpUzzDItCBE+Y/LfGk/t3r+E7qoaPPrP00J+HCOIsY/OeZ DWsi3Zv3g+vRnLFlfTwOZttG3niK7f7IuvJBWYojHw3Ws+oHgYlTAGREOhYHPAS/uj rBWEYrcIqnDe1ZokInlWnyc6D5arJ1BNSCW1kFF0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) by sourceware.org (Postfix) with ESMTPS id 66DFF38618F9 for ; Wed, 19 May 2021 02:24:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 66DFF38618F9 Received: by mail-qv1-xf31.google.com with SMTP id 5so6096663qvk.0 for ; Tue, 18 May 2021 19:24:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N0NRxAmhXnit5eF3bJXlxMN7GF2z2pB8pFKqaTAn6oQ=; b=uWVAX3VhKuRBMeIgDCoMXahv4xtM1fN4jECbeDP9p2Xe8KK2jnP5boMoRlllc9ab0d cOyKU5DIJ+INsM2f12oYBy7su4l8WLmSelhsZhjGlhuJtIWdUD4DY6o1uSP7Utyr7Lng Geagl1Gxez8vNQA391OU/rEeuVTo40PC2bcUiwF69hjx4fQgNjlTPgcNvMKB/8fqE0Ti P6ePTgnCbPMMUNW9JUDjDKUar6qhR0lvbTlCNEa2pkQIcb0BIkZYX4PNa4oaVbDOmHa5 Ilxvk3dd5EJ1RnPXkWRoY6ZnD9DgWdGlEgc+B9l1+YvLjklp5HoZz+4OJ2APmxJctPKS qK8A== X-Gm-Message-State: AOAM533BK/kBh9t632QYOJ70qomKLUfDkiDtKkyhPmKTeD9CApfLLCA0 a325oboJTMGjgA53H8ffEIGGl2aHqYUXUQ== X-Google-Smtp-Source: ABdhPJz5JOk+wvx0/8szdoYRW7fKcmi+baHk+/HufQBcVgKlbY5Lt0+E1DBc9piHpu/+uLwPTqxlEg== X-Received: by 2002:a0c:eed4:: with SMTP id h20mr9776342qvs.40.1621391085701; Tue, 18 May 2021 19:24:45 -0700 (PDT) Received: from localhost.localdomain (pool-71-245-178-39.pitbpa.fios.verizon.net. [71.245.178.39]) by smtp.googlemail.com with ESMTPSA id u126sm14695896qkd.80.2021.05.18.19.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 19:24:45 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v2 1/3] x86: Expand bench-memcmp.c and test-memcmp.c Date: Tue, 18 May 2021 22:24:36 -0400 Message-Id: <20210519022438.2986411-1-goldstein.w.n@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210517184406.2609574-1-goldstein.w.n@gmail.com> References: <20210517184406.2609574-1-goldstein.w.n@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SCC_5_SHORT_WORD_LINES, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Noah Goldstein via Libc-alpha From: Noah Goldstein Reply-To: Noah Goldstein Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" No bug. This commit adds some additional performance test cases to bench-memcmp.c and test-memcmp.c. The new benchtests include some medium range sizes, as well as small sizes near page cross. The new correctness tests correspond with the new benchtests though add some additional cases for checking the page cross logic. Signed-off-by: Noah Goldstein Reviewed-by: H.J. Lu --- benchtests/bench-memcmp.c | 32 +++++++++++++++++++++++++------ string/test-memcmp.c | 40 +++++++++++++++++++++++++++++++++------ 2 files changed, 60 insertions(+), 12 deletions(-) diff --git a/benchtests/bench-memcmp.c b/benchtests/bench-memcmp.c index eb0f94a0f1..744c7ec5ba 100644 --- a/benchtests/bench-memcmp.c +++ b/benchtests/bench-memcmp.c @@ -88,11 +88,11 @@ do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len, if (len == 0) return; - align1 &= 63; + align1 &= (4096 - CHARBYTES); if (align1 + (len + 1) * CHARBYTES >= page_size) return; - align2 &= 63; + align2 &= (4096 - CHARBYTES); if (align2 + (len + 1) * CHARBYTES >= page_size) return; @@ -100,6 +100,7 @@ do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len, json_attr_uint (json_ctx, "length", (double) len); json_attr_uint (json_ctx, "align1", (double) align1); json_attr_uint (json_ctx, "align2", (double) align2); + json_attr_uint (json_ctx, "result", (double) exp_result); json_array_begin (json_ctx, "timings"); FOR_EACH_IMPL (impl, 0) @@ -145,18 +146,31 @@ test_main (void) json_array_end (&json_ctx); json_array_begin (&json_ctx, "results"); - for (i = 1; i < 16; ++i) + for (i = 1; i < 32; ++i) { do_test (&json_ctx, i * CHARBYTES, i * CHARBYTES, i, 0); do_test (&json_ctx, i * CHARBYTES, i * CHARBYTES, i, 1); do_test (&json_ctx, i * CHARBYTES, i * CHARBYTES, i, -1); } - for (i = 0; i < 16; ++i) + for (i = 0; i < 32; ++i) { do_test (&json_ctx, 0, 0, i, 0); do_test (&json_ctx, 0, 0, i, 1); do_test (&json_ctx, 0, 0, i, -1); + do_test (&json_ctx, 4096 - i, 0, i, 0); + do_test (&json_ctx, 4096 - i, 0, i, 1); + do_test (&json_ctx, 4096 - i, 0, i, -1); + } + + for (i = 33; i < 385; i += 32) + { + do_test (&json_ctx, 0, 0, i, 0); + do_test (&json_ctx, 0, 0, i, 1); + do_test (&json_ctx, 0, 0, i, -1); + do_test (&json_ctx, i, 0, i, 0); + do_test (&json_ctx, 0, i, i, 1); + do_test (&json_ctx, i, i, i, -1); } for (i = 1; i < 10; ++i) @@ -164,13 +178,19 @@ test_main (void) do_test (&json_ctx, 0, 0, 2 << i, 0); do_test (&json_ctx, 0, 0, 2 << i, 1); do_test (&json_ctx, 0, 0, 2 << i, -1); - do_test (&json_ctx, 0, 0, 16 << i, 0); do_test (&json_ctx, (8 - i) * CHARBYTES, (2 * i) * CHARBYTES, 16 << i, 0); + do_test (&json_ctx, 0, 0, 16 << i, 0); do_test (&json_ctx, 0, 0, 16 << i, 1); do_test (&json_ctx, 0, 0, 16 << i, -1); + do_test (&json_ctx, i, 0, 2 << i, 0); + do_test (&json_ctx, 0, i, 2 << i, 1); + do_test (&json_ctx, i, i, 2 << i, -1); + do_test (&json_ctx, i, 0, 16 << i, 0); + do_test (&json_ctx, 0, i, 16 << i, 1); + do_test (&json_ctx, i, i, 16 << i, -1); } - for (i = 1; i < 8; ++i) + for (i = 1; i < 10; ++i) { do_test (&json_ctx, i * CHARBYTES, 2 * (i * CHARBYTES), 8 << i, 0); do_test (&json_ctx, i * CHARBYTES, 2 * (i * CHARBYTES), 8 << i, 1); diff --git a/string/test-memcmp.c b/string/test-memcmp.c index 02ea9b782d..fbda26a41e 100644 --- a/string/test-memcmp.c +++ b/string/test-memcmp.c @@ -111,11 +111,11 @@ do_test (size_t align1, size_t align2, size_t len, int exp_result) if (len == 0) return; - align1 &= 63; + align1 &= (4096 - CHARBYTES); if (align1 + (len + 1) * CHARBYTES >= page_size) return; - align2 &= 63; + align2 &= (4096 - CHARBYTES); if (align2 + (len + 1) * CHARBYTES >= page_size) return; @@ -487,18 +487,40 @@ test_main (void) printf ("\t%s", impl->name); putchar ('\n'); - for (i = 1; i < 16; ++i) + for (i = 1; i < 32; ++i) { do_test (i * CHARBYTES, i * CHARBYTES, i, 0); do_test (i * CHARBYTES, i * CHARBYTES, i, 1); do_test (i * CHARBYTES, i * CHARBYTES, i, -1); } - for (i = 0; i < 16; ++i) + for (i = 0; i < 32; ++i) { do_test (0, 0, i, 0); do_test (0, 0, i, 1); do_test (0, 0, i, -1); + do_test (4096 - i, 0, i, 0); + do_test (4096 - i, 0, i, 1); + do_test (4096 - i, 0, i, -1); + do_test (4095, 0, i, 0); + do_test (4095, 0, i, 1); + do_test (4095, 0, i, -1); + do_test (4095, 4095, i, 0); + do_test (4095, 4095, i, 1); + do_test (4095, 4095, i, -1); + do_test (4000, 95, i, 0); + do_test (4000, 95, i, 1); + do_test (4000, 95, i, -1); + } + + for (i = 33; i < 385; i += 32) + { + do_test (0, 0, i, 0); + do_test (0, 0, i, 1); + do_test (0, 0, i, -1); + do_test (i, 0, i, 0); + do_test (0, i, i, 1); + do_test (i, i, i, -1); } for (i = 1; i < 10; ++i) @@ -506,13 +528,19 @@ test_main (void) do_test (0, 0, 2 << i, 0); do_test (0, 0, 2 << i, 1); do_test (0, 0, 2 << i, -1); - do_test (0, 0, 16 << i, 0); do_test ((8 - i) * CHARBYTES, (2 * i) * CHARBYTES, 16 << i, 0); + do_test (0, 0, 16 << i, 0); do_test (0, 0, 16 << i, 1); do_test (0, 0, 16 << i, -1); + do_test (i, 0, 2 << i, 0); + do_test (0, i, 2 << i, 1); + do_test (i, i, 2 << i, -1); + do_test (i, 0, 16 << i, 0); + do_test (0, i, 16 << i, 1); + do_test (i, i, 16 << i, -1); } - for (i = 1; i < 8; ++i) + for (i = 1; i < 10; ++i) { do_test (i * CHARBYTES, 2 * (i * CHARBYTES), 8 << i, 0); do_test (i * CHARBYTES, 2 * (i * CHARBYTES), 8 << i, 1);