qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/13] target/riscv: add 'cpu->cfg.vlenb', remove 'cpu->cfg.vlen'
@ 2024-01-12 21:37 Daniel Henrique Barboza
  2024-01-12 21:38 ` [PATCH 01/13] target/riscv: add 'vlenb' field in cpu->cfg Daniel Henrique Barboza
                   ` (12 more replies)
  0 siblings, 13 replies; 21+ messages in thread
From: Daniel Henrique Barboza @ 2024-01-12 21:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-riscv, alistair.francis, bmeng, liwei1518, zhiwei_liu,
	palmer, richard.henderson, max.chou, Daniel Henrique Barboza

Hi,

When working in the KVM Vector support, adding support for the 'vlenb'
register, I noticed that we have a *LOT* of code that uses 'vlenb', in a
far greater amount than 'vlen', and we resort to do 'vlen >> 3' every
time we need 'vlenb'. The conclusion is that we're storing the wrong
state - we should store 'vlenb' instead. 

We can't just get rid of the 'vlen' property since it has been exposed
to users already, but what we can do is to change our internal
representation. Users will keep setting 'vlen' but we'll store it as
'vlenb' internally. 

To fully remove 'vlen' we need to either use 'vlenb' to retrieve it
(i.e. vlen = vlenb << 3), if we can't help but use 'vlenb', or try to
rework the logic to avoid using vlenb. This was the case of patch 12,
where we avoid using 'vlen' to calculate 'vlmax' in a condition where
vl_eq_vlmax is true.

There was a minor performance gain after these changes, in particular
after patch 07. Performance gain isn't our goal here, but at least we
have evidence that we're not making the emulation slower with these
changes.

Patches based on Alistair's riscv-to-apply.next.

Daniel Henrique Barboza (13):
  target/riscv: add 'vlenb' field in cpu->cfg
  target/riscv/csr.c: use 'vlenb' instead of 'vlen'
  target/riscv/gdbstub.c: use 'vlenb' instead of shifting 'vlen'
  target/riscv/insn_trans/trans_rvbf16.c.inc: use cpu->cfg.vlenb
  target/riscv/insn_trans/trans_rvv.c.inc: use 'vlenb'
  target/riscv/insn_trans/trans_rvvk.c.inc: use 'vlenb'
  target/riscv/vector_helper.c: use 'vlenb'
  target/riscv/vector_helper.c: use vlenb in HELPER(vsetvl)
  target/riscv/cpu.h: use 'vlenb' in vext_get_vlmax()
  target/riscv/insn_trans/trans_rvv.c.inc: use 'vlenb' in MAXSZ()
  trans_rvv.c.inc: remove vlmax arg from vec_element_loadx()
  trans_rvv.c.inc: use cpu_vl in trans_vrgather_vi()
  target/riscv/cpu.c: remove cpu->cfg.vlen

 target/riscv/cpu.c                         |  12 +-
 target/riscv/cpu.h                         |   3 +-
 target/riscv/cpu_cfg.h                     |   2 +-
 target/riscv/csr.c                         |   4 +-
 target/riscv/gdbstub.c                     |   6 +-
 target/riscv/insn_trans/trans_rvbf16.c.inc |  12 +-
 target/riscv/insn_trans/trans_rvv.c.inc    | 200 +++++++++++----------
 target/riscv/insn_trans/trans_rvvk.c.inc   |  16 +-
 target/riscv/tcg/tcg-cpu.c                 |   4 +-
 target/riscv/vector_helper.c               |  27 +--
 10 files changed, 155 insertions(+), 131 deletions(-)

-- 
2.43.0



^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2024-01-15 20:18 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-12 21:37 [PATCH 00/13] target/riscv: add 'cpu->cfg.vlenb', remove 'cpu->cfg.vlen' Daniel Henrique Barboza
2024-01-12 21:38 ` [PATCH 01/13] target/riscv: add 'vlenb' field in cpu->cfg Daniel Henrique Barboza
2024-01-12 21:38 ` [PATCH 02/13] target/riscv/csr.c: use 'vlenb' instead of 'vlen' Daniel Henrique Barboza
2024-01-12 21:38 ` [PATCH 03/13] target/riscv/gdbstub.c: use 'vlenb' instead of shifting 'vlen' Daniel Henrique Barboza
2024-01-12 21:38 ` [PATCH 04/13] target/riscv/insn_trans/trans_rvbf16.c.inc: use cpu->cfg.vlenb Daniel Henrique Barboza
2024-01-12 21:38 ` [PATCH 05/13] target/riscv/insn_trans/trans_rvv.c.inc: use 'vlenb' Daniel Henrique Barboza
2024-01-12 21:38 ` [PATCH 06/13] target/riscv/insn_trans/trans_rvvk.c.inc: " Daniel Henrique Barboza
2024-01-12 21:38 ` [PATCH 07/13] target/riscv/vector_helper.c: " Daniel Henrique Barboza
2024-01-12 21:38 ` [PATCH 08/13] target/riscv/vector_helper.c: use vlenb in HELPER(vsetvl) Daniel Henrique Barboza
2024-01-12 22:40   ` Richard Henderson
2024-01-12 21:38 ` [PATCH 09/13] target/riscv/cpu.h: use 'vlenb' in vext_get_vlmax() Daniel Henrique Barboza
2024-01-12 22:42   ` Richard Henderson
2024-01-12 21:38 ` [PATCH 10/13] target/riscv/insn_trans/trans_rvv.c.inc: use 'vlenb' in MAXSZ() Daniel Henrique Barboza
2024-01-12 22:45   ` Richard Henderson
2024-01-15 13:51     ` Daniel Henrique Barboza
2024-01-12 21:38 ` [PATCH 11/13] trans_rvv.c.inc: remove vlmax arg from vec_element_loadx() Daniel Henrique Barboza
2024-01-12 22:51   ` Richard Henderson
2024-01-15 17:57     ` Daniel Henrique Barboza
2024-01-15 20:16       ` Richard Henderson
2024-01-12 21:38 ` [PATCH 12/13] trans_rvv.c.inc: use cpu_vl in trans_vrgather_vi() Daniel Henrique Barboza
2024-01-12 21:38 ` [PATCH 13/13] target/riscv/cpu.c: remove cpu->cfg.vlen Daniel Henrique Barboza

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).