Received: by 2002:a05:7412:8d11:b0:fa:4934:9f with SMTP id bj17csp433238rdb; Mon, 15 Jan 2024 01:55:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IF+WiufJmUqFbZ6QOA72BoSW8CvhAL/HCGPjrFokQl8Y+2zWb22xWw4G4OkPk3ufJ8lpIRZ X-Received: by 2002:a17:90a:c7:b0:28e:29a9:ef67 with SMTP id v7-20020a17090a00c700b0028e29a9ef67mr614595pjd.40.1705312509899; Mon, 15 Jan 2024 01:55:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705312509; cv=none; d=google.com; s=arc-20160816; b=wFV2zuC9taykkc4b08/o5Zq7ski/aSjukNpxgnNNORIotw4b3uPSck9EWudLfll84O LE1I7e9cyGpH2+T7fG1czx7waBFtZ/Sze0cBFXBEDkuCBxR1jCdZT8ACWc71cijZRoTY tGJXeP3OMzSCT4R/ys+1lPXZD/AKG5kZnRdu60lkF9L7KycrfjnKoyaOHdTjVWIwoFme 14rhaAyl7XvggcVqX1C7164xvmWxcGlrjihtlcZLvUcEP48YmbQHsivBEx2oP0qy+jcX WlM93vhtxO2/ig1++LiZzuHFj5yIHtxYolhax0gNpf2fVmqO4csGZUjJ/GtLmtNGZVFk zIFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=4qCIXc2dOAP16BXJM6Rdvx9FHTNiEI7xCxw0XsJ8rI0=; fh=UEHKareU1wFr9K3t2Bq3G8hwQd1cAmWmLulsJYIpEss=; b=j3+kZhAVk5nv+s/Xf6tyBEjCd41FLVV+DyjqyDxahFsFofC67mlvW1jwlzyuMmZsMI g4GNDEgINrqoNnY84+5SKRe3bZhVtEVJiBm2ic3THySvUEONJ22cpsi9Dl9by5jmSdhg IS6VqWEQhcAqWIXFMaYswcKU8pXICew3W/Z0sUPXhe79D/kR7HKcn3fua2h8tAepEkXS AieLgIBi1/QpwgG4Xan8L0HZyxOR0jCeyGMn7J9BrhMTIxlWUnZjKpcn0c8axHjEAJVU r1ZKhpV4AHT6NUqgnOhepktDKQw3X8S1DFP5mjNpTjgz2MeP8DWSiaACeWmPVJic5Yqg y2XA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-25828-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25828-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id x6-20020a170902a38600b001d002eeb4a1si8485961pla.15.2024.01.15.01.55.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 01:55:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25828-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-25828-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25828-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id EAA2AB20C8D for ; Mon, 15 Jan 2024 09:55:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 16A3FE575; Mon, 15 Jan 2024 09:55:00 +0000 (UTC) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2874DE541 for ; Mon, 15 Jan 2024 09:54:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ghiti.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ghiti.fr Received: by mail.gandi.net (Postfix) with ESMTPSA id 91F922000F; Mon, 15 Jan 2024 09:54:51 +0000 (UTC) Message-ID: Date: Mon, 15 Jan 2024 10:54:48 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] riscv: select ARCH_HAS_FAST_MULTIPLIER Content-Language: en-US To: Jisheng Zhang , Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Samuel Holland References: <20231202135202.4071-1-jszhang@kernel.org> From: Alexandre Ghiti In-Reply-To: <20231202135202.4071-1-jszhang@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-GND-Sasl: alex@ghiti.fr Hi Jisheng, On 02/12/2023 14:52, Jisheng Zhang wrote: > Currently, riscv linux requires at least IMA, so all platforms have a > multiplier. And I assume the 'mul' efficiency is comparable or better > than a sequence of five or so register-dependent arithmetic > instructions. Select ARCH_HAS_FAST_MULTIPLIER to get slightly nicer > codegen. Refer to commit f9b4192923fa ("[PATCH] bitops: hweight() > speedup") for more details. > > In a simple benchmark test calling hweight64() in a loop, it got: > about 14% performance improvement on JH7110, tested on Milkv Mars. > > about 23% performance improvement on TH1520 and SG2042, tested on > Sipeed LPI4A and SG2042 platform. > > a slight performance drop on CV1800B, tested on milkv duo. Among all > riscv platforms in my hands, this is the only one which sees a slight > performance drop. It means the 'mul' isn't quick enough. However, the > situation exists on x86 too, for example, P4 doesn't have fast > integer multiplies as said in the above commit, x86 also selects > ARCH_HAS_FAST_MULTIPLIER. So let's select ARCH_HAS_FAST_MULTIPLIER > which can benefit almost riscv platforms. > > Samuel also provided some performance numbers: > On Unmatched: 20% speedup for __sw_hweight32 and 30% speedup for > __sw_hweight64. > On D1: 8% speedup for __sw_hweight32 and 8% slowdown for > __sw_hweight64. > > Signed-off-by: Jisheng Zhang > Reviewed-by: Samuel Holland > Tested-by: Samuel Holland > --- > > since v1: > - fix typo in commit msg > - add some performance numbers provided by Samuel > - collect Reviewed-by and Tested-by tag > > arch/riscv/Kconfig | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > index 95a2a06acc6a..e4834fa76417 100644 > --- a/arch/riscv/Kconfig > +++ b/arch/riscv/Kconfig > @@ -23,6 +23,7 @@ config RISCV > select ARCH_HAS_DEBUG_VIRTUAL if MMU > select ARCH_HAS_DEBUG_VM_PGTABLE > select ARCH_HAS_DEBUG_WX > + select ARCH_HAS_FAST_MULTIPLIER > select ARCH_HAS_FORTIFY_SOURCE > select ARCH_HAS_GCOV_PROFILE_ALL > select ARCH_HAS_GIGANTIC_PAGE You can add: Reviewed-by: Alexandre Ghiti Thanks, Alex