From patchwork Wed Apr 24 22:57:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791546 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1093273wrq; Wed, 24 Apr 2024 15:58:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV526dMcEF4A1QqiVP15BaubvxDvl1eirCAjdIGJLIRqzAMS8OpRZGpCij1ILHpsW2SfcFs4Yw0cC9yB7I+iOKZ X-Google-Smtp-Source: AGHT+IE1D5l5rUBMbm2j0B988Z1ua6SNP6ViD/8YCBOvrD9ZZGwEczp4uX7caeVqOhK73Lk2mxDS X-Received: by 2002:a05:6214:11ad:b0:6a0:82ae:f0b with SMTP id u13-20020a05621411ad00b006a082ae0f0bmr4430833qvv.33.1713999517282; Wed, 24 Apr 2024 15:58:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999517; cv=none; d=google.com; s=arc-20160816; b=Rv+YpOSQCxgwnz1mm0ouKZKME2DzTSFUejuEqS/ybpXqoytQ/YzOIHbG0k+V/Yrhbv Gm4bMNWkdMR8POfycipCdZJC3Peg4ZJhNn6EJh3Dp+M1M3n+a1FXfH6aYGnH1uWY+0FC s0TA1BUb2b1KHAB1XI4uCfZsyrahSqtLe2n8dEMyvKb+Ys/fX2lFfC/uIK/7EfOEyKQ2 Jv61Aix3ZBOwFgs1v44MT20JuKUH1ktZlQNYLR8CN8MNIVF4kX3E574/g2omMTwLPPpx hG3OGwdVfWOHBPW9WXNzyp5LlHXcEXuhyQi6sbuh9zdRDh8/HhVJJFzlB2jEZsYA0NsD 2GUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=uDnD2JhudGEyHc/H+ZZoiEcnN6tpSM/3wit8Um6ah6g=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=UrrEsomLgHo4kBSC9GCiqoyr3u0dfOyIo2HvsqzPe728zP6aYhup4JohfBHjZuCToy Z55xvXfhnWgEMDMOjq7VXvyYK/3ZGPXQK/8tc4VEJoq7hVfg4mWtqCRBtkvUuY02emj2 kOBQHSwhn9jzLVfbqg63W6rxMA71t9d6JlBDVpvWk6hJBacyPGgkTjyGPgOVQPKN3eBH i9pPIygsYIEBcmfR1bgNLtGqKyTzIzwQtKED3Y1aDHBVYKBmO8WKNcr5NPLb+lVOYrsf JERBczHNray4l4MTMhUwd5v6KIK0253wFlJ5M6rHRyUcdYcGa49ar3KC/5ZRrv/kXpFO kAww==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mG+rKjic; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id gw3-20020a0562140f0300b006a03ff213dbsi16680653qvb.68.2024.04.24.15.58.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 15:58:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mG+rKjic; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzlYS-0005Y3-6S; Wed, 24 Apr 2024 18:57:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzlYM-0005QJ-LS for qemu-devel@nongnu.org; Wed, 24 Apr 2024 18:57:27 -0400 Received: from mail-oo1-xc2f.google.com ([2607:f8b0:4864:20::c2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzlYL-0001pT-6O for qemu-devel@nongnu.org; Wed, 24 Apr 2024 18:57:26 -0400 Received: by mail-oo1-xc2f.google.com with SMTP id 006d021491bc7-5aa2a74c238so281508eaf.3 for ; Wed, 24 Apr 2024 15:57:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999444; x=1714604244; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=uDnD2JhudGEyHc/H+ZZoiEcnN6tpSM/3wit8Um6ah6g=; b=mG+rKjic6fGDOeNcPoWewMQB9wlHzaoVWPFgKzb4qzDWBFMe7HvJxL/PAYJa2FH1Kw a/lqLwbEVtA7fz5EOZnLbkiud5jRMWv6TrOXEuauR/3aXt9g45/o8x4sQiMziOuNI5BV FRmgDPqDQFw6V5ghxvGIDbMfvlXwVcF4eWiy2DNUyzkIXgpVkFvbYoI4mHGxaxe+XhIc G/cm4gI0lKmy8ObgyH3qDOboFoOBR7PYR/TODRjBUkiQq32HWt/NrAGTcwPHCaqXcRF/ 9gSb65BYIWIXumGRFmKWTFcvQum9Uld8XiEdv963uT23soDgFNEhPEaXnF+cZB1JiJL2 9+UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999444; x=1714604244; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uDnD2JhudGEyHc/H+ZZoiEcnN6tpSM/3wit8Um6ah6g=; b=r2AHREOJYN0EnauQxG38EsUzsGxfk3ewZ5Z1ojb8ZfuBX4mZ+pIvyFqCfXbdKCJXcw p8f2AP39BdpLCXVlYO5WQg1+WIb+WN6DwrgomJ7JnMIUwnsddhD93RTiCPmHe++xKy5v VDExOEiPIyrYODiVyt9HgJruvYBfOvT2njQgwCihJ49CbCdN7Z52m5VqxSnwvA/zESP0 uPDvx6YWYWdXe3KnNL64BT+NGskhqv+Ghyvwr33gevZmZCCmZx9OqHB/BmVUR8LmDFJZ uMYd3r0ubcauq58YNUC3N2rpQvvoVwV13kv7SAulLtbXXYZENXgRS4U/Qz6MnKl1x5Gy /4vQ== X-Gm-Message-State: AOJu0Yz/WE/VuaTXJWBLiaHILkxDgf2J+E7oLxpa43460isNvGBKP1wN QMqq1RqDNr4z/HZeozJlLD9VblVKuDP4u0qEnvlhPdh8msxUrMl78v7yGe9wBwMvgUJnsyNx2j0 u X-Received: by 2002:a05:6870:3101:b0:22e:8ed:9f7a with SMTP id v1-20020a056870310100b0022e08ed9f7amr4331016oaa.4.1713999443927; Wed, 24 Apr 2024 15:57:23 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id gu26-20020a056a004e5a00b006ed9760b815sm11947413pfb.211.2024.04.24.15.57.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 15:57:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v6 10/10] tests/bench: Add bufferiszero-bench Date: Wed, 24 Apr 2024 15:57:05 -0700 Message-Id: <20240424225705.929812-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424225705.929812-1-richard.henderson@linaro.org> References: <20240424225705.929812-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::c2f; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc2f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Benchmark each acceleration function vs an aligned buffer of zeros. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- tests/bench/bufferiszero-bench.c | 47 ++++++++++++++++++++++++++++++++ tests/bench/meson.build | 1 + 2 files changed, 48 insertions(+) create mode 100644 tests/bench/bufferiszero-bench.c diff --git a/tests/bench/bufferiszero-bench.c b/tests/bench/bufferiszero-bench.c new file mode 100644 index 0000000000..222695c1fa --- /dev/null +++ b/tests/bench/bufferiszero-bench.c @@ -0,0 +1,47 @@ +/* + * QEMU buffer_is_zero speed benchmark + * + * This work is licensed under the terms of the GNU GPL, version 2 or + * (at your option) any later version. See the COPYING file in the + * top-level directory. + */ +#include "qemu/osdep.h" +#include "qemu/cutils.h" +#include "qemu/units.h" + +static void test(const void *opaque) +{ + size_t max = 64 * KiB; + void *buf = g_malloc0(max); + int accel_index = 0; + + do { + if (accel_index != 0) { + g_test_message("%s", ""); /* gnu_printf Werror for simple "" */ + } + for (size_t len = 1 * KiB; len <= max; len *= 4) { + double total = 0.0; + + g_test_timer_start(); + do { + buffer_is_zero_ge256(buf, len); + total += len; + } while (g_test_timer_elapsed() < 0.5); + + total /= MiB; + g_test_message("buffer_is_zero #%d: %2zuKB %8.0f MB/sec", + accel_index, len / (size_t)KiB, + total / g_test_timer_last()); + } + accel_index++; + } while (test_buffer_is_zero_next_accel()); + + g_free(buf); +} + +int main(int argc, char **argv) +{ + g_test_init(&argc, &argv, NULL); + g_test_add_data_func("/cutils/bufferiszero/speed", NULL, test); + return g_test_run(); +} diff --git a/tests/bench/meson.build b/tests/bench/meson.build index 7e76338a52..4cd7a2f6b5 100644 --- a/tests/bench/meson.build +++ b/tests/bench/meson.build @@ -21,6 +21,7 @@ benchs = {} if have_block benchs += { + 'bufferiszero-bench': [], 'benchmark-crypto-hash': [crypto], 'benchmark-crypto-hmac': [crypto], 'benchmark-crypto-cipher': [crypto],