From patchwork Mon Apr 8 17:49:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 786954 Delivered-To: patch@linaro.org Received: by 2002:adf:fb4d:0:b0:346:15ad:a2a with SMTP id c13csp2606wrs; Mon, 8 Apr 2024 10:58:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXDc1AlI0JhVKp6RwlzgPR1Cah0WwkKwQyYAuK2M53xYWWkh96YaMsO1ZdR/QzgFUnK6lJE+4Xuj4PrPgDkgfx2 X-Google-Smtp-Source: AGHT+IEkVqo1ADt1IUsn/qz8FoaNr+o893ke9bInMYlePoxdUC1xHsnH8ITtGm2YxJ0q/zkT7S6D X-Received: by 2002:a05:6808:189e:b0:3c5:e91e:2a62 with SMTP id bi30-20020a056808189e00b003c5e91e2a62mr8116181oib.23.1712599088953; Mon, 08 Apr 2024 10:58:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712599088; cv=none; d=google.com; s=arc-20160816; b=RM3guOR4TRRD/NvVu24cW10zgeHNzRin13HvNcf9N7uxMWaKIF+9AxR3OscZVBMIDb 2El/79r4ViEiLw+uzM5B1nM6H9SsGBgso9w9EWCDOnbByH6zaJqxnLKdQ/b5CW3fMLkw dbfqjSAO8iMdLbG11ZPKSUYoA4AtGSZLHMOXkXDeZjK1d0vJQdlj0dv/1JjTQI9ZDXor YeZJz7Ru85kIaG0POjWCCvYlt37uUNL1jQhSH9p8HTIvrrc5kb4oigJqLXf6mIGl5kh7 36ZkYmHCwpI0xysn93SBE3pxLUlWtaMr0ipkc4kKGlv2f4nPqUdf9f0UefgpGmuToPR4 0eTA== 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:cc:to :from:dkim-signature; bh=Sc6Au+pExfgVbkEVt3xBcrgjk6DJCZWLxXzjjgNJTcI=; fh=IOfZmL/4G2LGBtSV+LzySu7eotL7HJ1AQcRx3etIBXU=; b=S9gVwsaudwABwRts2USPV4VHtysebWGXVaXh4Bd054iGCcEZmLbVSxdf23kQaykUwJ fahlmbC6ae92rErj6w98eWIYyIhQYZLS4/qR35owipGj5Tau8HPkETHq7Xo2OvVkawEq gKMVg/4ssAboKH4rIzKccn5ZJTRSQmMVolXP1esodaFFTjscW4ebtmTzXjp02f+awBdS decywDHcwZpNv9sPfEqxUXD3BC7FsMA1B+0FPsRX2nQl7Bs6WgTNYhvOYRl0WsdvcGbi 6a8W7alLulQfRMtydL+ajb9vAFyyqSPvExHieszcZRuv+W30z9W28Okx5q+iJ20vxagK JSBA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O7hoOfOH; 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 pa2-20020a05620a830200b0078bcce4fd7bsi8429907qkn.349.2024.04.08.10.58.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Apr 2024 10:58:08 -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=O7hoOfOH; 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 1rtt8O-00028z-RH; Mon, 08 Apr 2024 13:50:20 -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 1rtt8N-00027f-A1 for qemu-devel@nongnu.org; Mon, 08 Apr 2024 13:50:19 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rtt8K-0003kP-Ey for qemu-devel@nongnu.org; Mon, 08 Apr 2024 13:50:19 -0400 Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-5dbcfa0eb5dso3423963a12.3 for ; Mon, 08 Apr 2024 10:50:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712598615; x=1713203415; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Sc6Au+pExfgVbkEVt3xBcrgjk6DJCZWLxXzjjgNJTcI=; b=O7hoOfOHJzJ5w+NZJNE4a0zu1/UrchsYwKQwKvRqlPq7XfKEssfOwEYfbCMAzaqxxZ y8iLiCXSr4Owdzr89LIYfoCp3phhzH7VZM1Hzg3U/3pke0/18xm2ArepAWY+lytW/bqB eHNLzaArlFYl2zdMTcAo5xtJcBYfanLt41UwAM5fWtpFtHjSBOz6ibQB6nfHRFOvuYsL lUhakiS+JhPDyeX/hr3+lge7fgHwNk48+YqCG6gvuNZt0DkOelILuicu8lF/ZKzE8Ekq fW1KGSElI5XOWFSR9VBsnHysa41BhIwPRParpqUQP2TfH0mPqtKO+N8dSWbYIcFDpeGp Sxmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712598615; x=1713203415; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Sc6Au+pExfgVbkEVt3xBcrgjk6DJCZWLxXzjjgNJTcI=; b=wEEEBNIGVB9JsUs1EYrckd8C5LuWQDRKKfy5GktrZoAraK1xx1Sd/aFXKzD16onw+p 5jRVMfACgeN5y2GD3Yaqjnf8MKMVxHfhm7CqvHEzujyG7ar1JYM548IFF7T/+60uumh8 GDeoX7QItOazazX6bydjFXgsCBzCLzLcaQDfbq0BeAbE4pPxSuZMm3Lo0wR9SliEl9/F mnoVXcrtxjLjHU1xkNfxJWVlFjLgl9sJhMDx8W9s0Q9oVIhFrYIqbBeauWewKsinB7sU rGQTEPUzLyOpMfetzmhfbz+Zvi9IWQ8kMR23k2IFgB1MwFzueSeQH4O1XsYX9ZEsz9RP VDog== X-Gm-Message-State: AOJu0Yx7JtOLBL0VPXQBt2jBaI3/cXqS9NJmMKIDP6hu2su2fPBNqfq0 wx7WtdtP3a5jNGqUQspuCSMt5ZIkn3uaftbOhe3e9uJNjzbKKz0BiwtYXEl0QsomrzbsbauwY3a p X-Received: by 2002:a17:90a:de89:b0:2a2:c2c4:9d28 with SMTP id n9-20020a17090ade8900b002a2c2c49d28mr7184354pjv.8.1712598615073; Mon, 08 Apr 2024 10:50:15 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id ga15-20020a17090b038f00b0029c3bac0aa8sm8658432pjb.4.2024.04.08.10.50.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 10:50:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Alexander Monakov , Mikhail Romanov Subject: [PULL 29/35] util/bufferiszero: Remove AVX512 variant Date: Mon, 8 Apr 2024 07:49:23 -1000 Message-Id: <20240408174929.862917-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240408174929.862917-1-richard.henderson@linaro.org> References: <20240408174929.862917-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x535.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 From: Alexander Monakov Thanks to early checks in the inline buffer_is_zero wrapper, the SIMD routines are invoked much more rarely in normal use when most buffers are non-zero. This makes use of AVX512 unprofitable, as it incurs extra frequency and voltage transition periods during which the CPU operates at reduced performance, as described in https://travisdowns.github.io/blog/2020/01/17/avxfreq1.html Signed-off-by: Mikhail Romanov Signed-off-by: Alexander Monakov Reviewed-by: Richard Henderson Message-Id: <20240206204809.9859-4-amonakov@ispras.ru> Signed-off-by: Richard Henderson --- util/bufferiszero.c | 38 +++----------------------------------- 1 file changed, 3 insertions(+), 35 deletions(-) diff --git a/util/bufferiszero.c b/util/bufferiszero.c index f5a3634f9a..641d5f9b9e 100644 --- a/util/bufferiszero.c +++ b/util/bufferiszero.c @@ -64,7 +64,7 @@ buffer_zero_int(const void *buf, size_t len) } } -#if defined(CONFIG_AVX512F_OPT) || defined(CONFIG_AVX2_OPT) || defined(__SSE2__) +#if defined(CONFIG_AVX2_OPT) || defined(__SSE2__) #include /* Note that each of these vectorized functions require len >= 64. */ @@ -128,41 +128,12 @@ buffer_zero_avx2(const void *buf, size_t len) } #endif /* CONFIG_AVX2_OPT */ -#ifdef CONFIG_AVX512F_OPT -static bool __attribute__((target("avx512f"))) -buffer_zero_avx512(const void *buf, size_t len) -{ - /* Begin with an unaligned head of 64 bytes. */ - __m512i t = _mm512_loadu_si512(buf); - __m512i *p = (__m512i *)(((uintptr_t)buf + 5 * 64) & -64); - __m512i *e = (__m512i *)(((uintptr_t)buf + len) & -64); - - /* Loop over 64-byte aligned blocks of 256. */ - while (p <= e) { - __builtin_prefetch(p); - if (unlikely(_mm512_test_epi64_mask(t, t))) { - return false; - } - t = p[-4] | p[-3] | p[-2] | p[-1]; - p += 4; - } - - t |= _mm512_loadu_si512(buf + len - 4 * 64); - t |= _mm512_loadu_si512(buf + len - 3 * 64); - t |= _mm512_loadu_si512(buf + len - 2 * 64); - t |= _mm512_loadu_si512(buf + len - 1 * 64); - - return !_mm512_test_epi64_mask(t, t); - -} -#endif /* CONFIG_AVX512F_OPT */ - /* * Make sure that these variables are appropriately initialized when * SSE2 is enabled on the compiler command-line, but the compiler is * too old to support CONFIG_AVX2_OPT. */ -#if defined(CONFIG_AVX512F_OPT) || defined(CONFIG_AVX2_OPT) +#if defined(CONFIG_AVX2_OPT) # define INIT_USED 0 # define INIT_LENGTH 0 # define INIT_ACCEL buffer_zero_int @@ -188,9 +159,6 @@ select_accel_cpuinfo(unsigned info) unsigned len; bool (*fn)(const void *, size_t); } all[] = { -#ifdef CONFIG_AVX512F_OPT - { CPUINFO_AVX512F, 256, buffer_zero_avx512 }, -#endif #ifdef CONFIG_AVX2_OPT { CPUINFO_AVX2, 128, buffer_zero_avx2 }, #endif @@ -208,7 +176,7 @@ select_accel_cpuinfo(unsigned info) return 0; } -#if defined(CONFIG_AVX512F_OPT) || defined(CONFIG_AVX2_OPT) +#if defined(CONFIG_AVX2_OPT) static void __attribute__((constructor)) init_accel(void) { used_accel = select_accel_cpuinfo(cpuinfo_init());