From: Richard Henderson <richard.henderson@linaro.org>
To: maobibo <maobibo@loongson.cn>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Daniel P . Berrangé" <berrange@redhat.com>,
"Thomas Huth" <thuth@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
qemu-devel@nongnu.org
Subject: Re: [PATCH 2/2] util/bufferiszero: Add simd acceleration for loongarch64
Date: Wed, 5 Jun 2024 20:42:21 -0700 [thread overview]
Message-ID: <5dc13c38-353b-4f17-97f3-fefd7f188570@linaro.org> (raw)
In-Reply-To: <da613eb1-65f8-b690-4517-04640581261b@loongson.cn>
On 6/5/24 20:36, maobibo wrote:
>>> static biz_accel_fn const accel_table[] = {
>>> buffer_is_zero_int_ge256,
>>> #ifdef __loongarch_sx
>>> buffer_is_zero_lsx,
>>> #endif
>>> #ifdef __loongarch_asx
>>> buffer_is_zero_lasx,
>>> #endif
>>> };
>>>
>>> static unsigned best_accel(void)
>>> {
>>> #ifdef __loongarch_asx
>>> /* lasx may be index 1 or 2, but always last */
>>> return ARRAY_SIZE(accel_table) - 1;
>>> #else
>>> /* lsx is always index 1 */
>>> return 1;
>>> #endif
>>> }
> size of accel_table is decided at compile-time, will it be better if runtime checking is
> added also? something like this:
>
> unsigned info = cpuinfo_init();
>
> #ifdef __loongarch_asx
> if (info & CPUINFO_LASX) {
> /* lasx may be index 1 or 2, but always last */
> return ARRAY_SIZE(accel_table) - 1;
> }
> #endif
No, because the ifdef checks that the *compiler* is prepared to use LASX/LSX instructions
itself without further checks. There's no point in qemu checking further.
r~
next prev parent reply other threads:[~2024-06-06 3:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-05 9:32 [PATCH 0/2] Add simd optimization with function buffer_is_zero Bibo Mao
2024-06-05 9:32 ` [PATCH 1/2] util: Add lasx cpuinfo for loongarch64 Bibo Mao
2024-06-05 11:53 ` Philippe Mathieu-Daudé
2024-06-06 2:17 ` maobibo
2024-06-05 9:32 ` [PATCH 2/2] util/bufferiszero: Add simd acceleration " Bibo Mao
2024-06-05 23:51 ` Richard Henderson
2024-06-06 2:30 ` maobibo
2024-06-06 3:18 ` Richard Henderson
2024-06-06 3:27 ` Richard Henderson
2024-06-06 3:36 ` maobibo
2024-06-06 3:42 ` Richard Henderson [this message]
2024-06-06 4:00 ` maobibo
2024-06-07 0:25 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5dc13c38-353b-4f17-97f3-fefd7f188570@linaro.org \
--to=richard.henderson@linaro.org \
--cc=berrange@redhat.com \
--cc=maobibo@loongson.cn \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).