qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Chou <max.chou@sifive.com>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-devel@nongnu.org, qemu-riscv@nongnu.org,
	 Palmer Dabbelt <palmer@dabbelt.com>,
	Alistair Francis <alistair.francis@wdc.com>,
	 Weiwei Li <liwei1518@gmail.com>,
	Daniel Henrique Barboza <dbarboza@ventanamicro.com>,
	 Liu Zhiwei <zhiwei_liu@linux.alibaba.com>
Subject: Re: [RFC PATCH 2/3] target/riscv: rvv: Add Zvqdotq support
Date: Wed, 3 Sep 2025 09:26:19 +0900	[thread overview]
Message-ID: <CANiaA1sP1KvhFhOOZRYJPzb=cf1DwTJNMTgEx5j2oppFNj6mdA@mail.gmail.com> (raw)
In-Reply-To: <5d0fe741-9063-441d-8abc-3bb0662c1fbe@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 1469 bytes --]

On Tue, Sep 2, 2025 at 22:38 Richard Henderson <richard.henderson@linaro.org>
wrote:

> On 9/1/25 23:38, Max Chou wrote:
> > +#define OPMVV_VQDOTQ(NAME, TD, T1, T2, TX1, TX2, HD, HS1, HS2)
> \
> > +static void do_##NAME(void *vd, void *vs1, void *vs2, int i)
> \
> > +{
>  \
> > +    int idx;
> \
> > +    T1 r1;
> \
> > +    T2 r2;
> \
> > +    TX1 *r1_buf = (TX1 *)vs1 + HD(i);
>  \
> > +    TX2 *r2_buf = (TX2 *)vs2 + HD(i);
>  \
> > +    TD acc = *((TD *)vd + HD(i));
>  \
> > +    int64_t partial_sum = 0;
> \
>
> I think it's clear partial_sum should be the 32-bit type TD.
> Indeed, I'm not sure why you don't just have
>
>         TD acc = ((TD *)vd)[HD(i)];

Thanks for the suggestion. I’ll update version 2 for this part.


>
> > +
> \
> > +    for (idx = 0; idx < 4; ++idx) {
>  \
> > +        r1 = *((T1 *)r1_buf + HS1(idx));
> \
> > +        r2 = *((T2 *)r2_buf + HS2(idx));
> \
> > +        partial_sum += (r1 * r2);
>  \
>
>         acc += r1 * r2;
>
> > +    }
>  \
> > +    *((TD *)vd + HD(i)) = (acc + partial_sum) & MAKE_64BIT_MASK(0, 32);
> \
>
>         ((TD *)vd)[HD(i)] = acc;
>
> because that final mask is bogus.
>

The partial_sum and the final mask are created to ensure the behavior
described in the Zvqdotq isa spec section 3 as follows:

“Finally, the four products are accumulated into the corresponding element
of vd, wrapping around signed overflow.”

Thanks,
Max.

[-- Attachment #2: Type: text/html, Size: 3380 bytes --]

  reply	other threads:[~2025-09-03  0:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-01 13:38 [RFC PATCH 0/3] Support RISC-V Zvqdotq vector dot-product extension Max Chou
2025-09-01 13:38 ` [RFC PATCH 1/3] target/riscv: Add Zvqdotq cfg property Max Chou
2025-09-01 13:38 ` [RFC PATCH 2/3] target/riscv: rvv: Add Zvqdotq support Max Chou
2025-09-02 13:38   ` Richard Henderson
2025-09-03  0:26     ` Max Chou [this message]
2025-09-03  3:43       ` Richard Henderson
2025-09-03 12:43         ` Max Chou
2025-09-01 13:38 ` [RFC PATCH 3/3] target/riscv: Expose Zvqdotq extension as a cpu property Max Chou

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='CANiaA1sP1KvhFhOOZRYJPzb=cf1DwTJNMTgEx5j2oppFNj6mdA@mail.gmail.com' \
    --to=max.chou@sifive.com \
    --cc=alistair.francis@wdc.com \
    --cc=dbarboza@ventanamicro.com \
    --cc=liwei1518@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=zhiwei_liu@linux.alibaba.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).