qemu-riscv.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Weiwei Li <liweiwei@iscas.ac.cn>
To: Rob Bradford <rbradford@rivosinc.com>, qemu-devel@nongnu.org
Cc: liweiwei@iscas.ac.cn, qemu-riscv@nongnu.org,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Alistair Francis <alistair.francis@wdc.com>,
	Bin Meng <bin.meng@windriver.com>,
	Daniel Henrique Barboza <dbarboza@ventanamicro.com>,
	Liu Zhiwei <zhiwei_liu@linux.alibaba.com>
Subject: Re: [PATCH] target/riscv: Fix LMUL check to use minimum SEW
Date: Thu, 6 Jul 2023 21:22:25 +0800	[thread overview]
Message-ID: <dfc75d1f-f28d-7d2c-26f9-72086ffb54ca@iscas.ac.cn> (raw)
In-Reply-To: <20230706104433.16264-1-rbradford@rivosinc.com>


On 2023/7/6 18:44, Rob Bradford wrote:
> The previous check was failing with:
>
> ELEN = 64 SEW = 16 and LMUL = 1/8 (encoded as 5) which is a valid
> combination.
>
> Fix the check to correctly match the specification by using minimum SEW
> rather than the active SEW.
>
>  From the specification:
>
> "In general, the requirement is to support LMUL ≥ SEWMIN/ELEN, where
> SEWMIN is the narrowest supported SEW value and ELEN is the widest
> supported SEW value. In the standard extensions, SEWMIN=8. For standard
> vector extensions with ELEN=32, fractional LMULs of 1/2 and 1/4 must be
> supported. For standard vector extensions with ELEN=64, fractional LMULs
> of 1/2, 1/4, and 1/8 must be supported."
>
>  From inspection this new check allows:
>
> ELEN=64 1/2, 1/4, 1/8 (encoded as 7, 6, 5 respectfully)
> ELEN=32 1/2, 1/4 (encoded as 7 and 6 respectfully)

This is a little confusing.  there is  note in spec to explain why  LMUL 
≥ SEW MIN /ELEN:

"When LMUL < SEW MIN /ELEN, there is no guarantee an implementation 
would have enough bits in the fractional vector register to store

Note at least one element, as VLEN=ELEN is a valid implementation 
choice. For example, with VLEN=ELEN=32, and SEW MIN =8, an LMUL of

1/8 would only provide four bits of storage in a vector register."

In this way, when VLEN=ELEN=64,  an LMUL of 1/8 would only provide 8 
bits of storage in a vector register, so it's also not suitable for sew 
= 16.

Maybe we can explain the above description of the spec in another way: 
we must support lmul=1/8 when ELEN=64, but it's only available when sew = 8.

Regards,

Weiwei Li

`

Regards,

Weiwei Li

>
> Fixes: d9b7609a1fb2 ("target/riscv: rvv-1.0: configure instructions")
>
> Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
> ---
>   target/riscv/vector_helper.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
> index 1e06e7447c..8dfd8fe484 100644
> --- a/target/riscv/vector_helper.c
> +++ b/target/riscv/vector_helper.c
> @@ -43,9 +43,9 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1,
>                                               xlen - 1 - R_VTYPE_RESERVED_SHIFT);
>   
>       if (lmul & 4) {
> -        /* Fractional LMUL. */
> +        /* Fractional LMUL - check LMUL >= ELEN/SEW_MIN (8) */
>           if (lmul == 4 ||
> -            cpu->cfg.elen >> (8 - lmul) < sew) {
> +            cpu->cfg.elen >> (8 - lmul) < 8) {
>               vill = true;
>           }
>       }



  parent reply	other threads:[~2023-07-06 13:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-06 10:44 [PATCH] target/riscv: Fix LMUL check to use minimum SEW Rob Bradford
2023-07-06 11:50 ` Daniel Henrique Barboza
2023-07-06 13:22 ` Weiwei Li [this message]
2023-07-17 15:13   ` Rob Bradford
2023-07-18  0:43     ` Weiwei Li
2023-07-18  2:16       ` LIU Zhiwei

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=dfc75d1f-f28d-7d2c-26f9-72086ffb54ca@iscas.ac.cn \
    --to=liweiwei@iscas.ac.cn \
    --cc=alistair.francis@wdc.com \
    --cc=bin.meng@windriver.com \
    --cc=dbarboza@ventanamicro.com \
    --cc=palmer@dabbelt.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=rbradford@rivosinc.com \
    --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).