From: jiawei@iscas.ac.cn
To: "Jeff Law" <jlaw@ventanamicro.com>
Cc: gcc-patches@gcc.gnu.org, kito.cheng@sifive.com,
palmer@dabbelt.com, christoph.muellner@vrull.eu,
wuwei2016@iscas.ac.cn, shihua@iscas.ac.cn,
shiyulong@iscas.ac.cn, chenyixuan@iscas.ac.cn
Subject: Re: Re: [PATCH] RISC-V: Add XiangShan Nanhu microarchitecture.
Date: Tue, 19 Mar 2024 20:43:17 +0800 (GMT+08:00) [thread overview]
Message-ID: <58c1d26d.4f3e6.18e56bccd86.Coremail.jiawei@iscas.ac.cn> (raw)
In-Reply-To: <35aff817-bcea-4e5f-9a23-9928e0f65043@ventanamicro.com>
> -----原始邮件-----
> 发件人: "Jeff Law" <jlaw@ventanamicro.com>
> 发送时间: 2024-03-19 10:54:09 (星期二)
> 收件人: Jiawei <jiawei@iscas.ac.cn>, gcc-patches@gcc.gnu.org
> 抄送: kito.cheng@sifive.com, palmer@dabbelt.com, christoph.muellner@vrull.eu, wuwei2016@iscas.ac.cn, shihua@iscas.ac.cn, shiyulong@iscas.ac.cn, chenyixuan@iscas.ac.cn
> 主题: Re: [PATCH] RISC-V: Add XiangShan Nanhu microarchitecture.
>
>
>
> On 2/27/24 1:52 AM, Jiawei wrote:
> > From: Chen Jiawei <jiawei@iscas.ac.cn>
> >
> > Co-Authored by: Lin Jiawei <jiawei.lin@epfl.ch>
> >
> > This patch add XiangShan Nanhu cpu microarchitecture,
> > Nanhu is a 6-issue, superscalar, out-of-order processor.
> > More details see: https://xiangshan-doc.readthedocs.io/zh-cn/latest/arch
> >
> > gcc/ChangeLog:
> >
> > * config/riscv/riscv-cores.def (RISCV_TUNE): New def.
> > (RISCV_CORE): Ditto.
> > * config/riscv/riscv-opts.h (enum
> > * riscv_microarchitecture_type): New option.
> > * config/riscv/riscv.cc: New def.
> > * config/riscv/riscv.md: New include.
> > * config/riscv/xiangshan.md: New file.
> >
> > gcc/testsuite/ChangeLog:
> >
> > * gcc.target/riscv/mcpu-xiangshan-nanhu.c: New test.
> As was discussed last Tuesday, this should be safe, even at this late
> stage in the gcc-14 cycle.
>
> >
> > +/* Costs to use when optimizing for xiangshan nanhu. */
> > +static const struct riscv_tune_param xiangshan_nanhu_tune_info = {
> > + {COSTS_N_INSNS (3), COSTS_N_INSNS (3)}, /* fp_add */
> > + {COSTS_N_INSNS (3), COSTS_N_INSNS (3)}, /* fp_mul */
> > + {COSTS_N_INSNS (10), COSTS_N_INSNS (20)}, /* fp_div */
> > + {COSTS_N_INSNS (3), COSTS_N_INSNS (3)}, /* int_mul */
> > + {COSTS_N_INSNS (6), COSTS_N_INSNS (6)}, /* int_div */
> > + 6, /* issue_rate */
> > + 3, /* branch_cost */
> > + 3, /* memory_cost */
> > + 3, /* fmv_cost */
> > + true, /* slow_unaligned_access */
> > + false, /* use_divmod_expansion */
> > + RISCV_FUSE_ZEXTW | RISCV_FUSE_ZEXTH, /* fusible_ops */
> > + NULL, /* vector cost */
> Is your integer division really that fast? The table above essentially
> says that your cpu can do integer division in 6 cycles.
>
> > +
> > +(define_insn_reservation "xiangshan_mul" 3
> > + (and (eq_attr "tune" "xiangshan")
> > + (eq_attr "type" "imul"))
> > + "xs_mdu_rs")
> > +
> > +(define_insn_reservation "xiangshan_div" 21
> > + (and (eq_attr "tune" "xiangshan")
> > + (eq_attr "type" "idiv"))
> > + "xs_mdu_rs")
> Whereas your pipeline description says it's 21c.
>
> I strongly suspect you want to increase the cost of the int_div in the
> tuning table. And with a the higher cost you probably want to turn on
> use_divmod_expansion.
>
> I'll also note that your scheduler description also indicates your
> division is fully pipelined. Is that correct? if not, you'll want to
> adjust that reservation.
>
>
>
> > +
> > +(define_insn_reservation "xiangshan_sfdiv" 11
> > + (and (eq_attr "tune" "xiangshan")
> > + (eq_attr "type" "fdiv")
> > + (eq_attr "mode" "SF"))
> > + "xs_fmisc_rs")
> > +
> > +(define_insn_reservation "xiangshan_sfsqrt" 17
> > + (and (eq_attr "tune" "xiangshan")
> > + (eq_attr "type" "fsqrt")
> > + (eq_attr "mode" "SF"))
> > + "xs_fmisc_rs")
> > +
> > +(define_insn_reservation "xiangshan_dfdiv" 21
> > + (and (eq_attr "tune" "xiangshan")
> > + (eq_attr "type" "fdiv")
> > + (eq_attr "mode" "DF"))
> > + "xs_fmisc_rs")
> > +
> > +(define_insn_reservation "xiangshan_dfsqrt" 37
> > + (and (eq_attr "tune" "xiangshan")
> > + (eq_attr "type" "fsqrt")
> > + (eq_attr "mode" "DF"))
> > + "xs_fmisc_rs")
> Similarly these say your fpdiv and fpsqrt are fully pipelined. It's
> certainly possible, but I suspect it's really just an oversight. Given
> these values you may also want to adjust the cost of an fp division in
> the cost table.
>
>
> Finally with such high values for for the div/sqrt units, we find that
> the DFA "blows up" causing genattrtab to run for a very long time. We'll
> have to keep an eye on that.
>
> And just to be clear, I think these can be done as a followup patch. I'm
> going to push this patch as-is rather than make any adjustments -- you
> almost certainly know the processor's capabilities better than myself or
> anyone else on this list :-)
>
>
> Jeff
Thank you for the comment, some pipeline processing costs may still need to
be confirmed, and I will correct them in next patch.
BR,
Jiawei</jiawei.lin@epfl.ch></jiawei@iscas.ac.cn></jiawei@iscas.ac.cn></jlaw@ventanamicro.com>
next prev parent reply other threads:[~2024-03-19 12:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-27 8:52 Jiawei
2024-03-19 2:54 ` Jeff Law
2024-03-19 12:43 ` jiawei [this message]
2024-03-25 19:48 ` TARGET_RTX_COSTS and pipeline latency vs. variable-latency instructions (was Re: [PATCH] RISC-V: Add XiangShan Nanhu microarchitecture.) Xi Ruoyao
2024-03-25 19:59 ` Jeff Law
2024-03-25 20:13 ` Palmer Dabbelt
2024-03-25 20:27 ` Jeff Law
2024-03-25 20:31 ` Palmer Dabbelt
2024-03-25 20:49 ` Jeff Law
2024-03-25 20:57 ` Palmer Dabbelt
2024-03-25 21:41 ` Jeff Law
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=58c1d26d.4f3e6.18e56bccd86.Coremail.jiawei@iscas.ac.cn \
--to=jiawei@iscas.ac.cn \
--cc=chenyixuan@iscas.ac.cn \
--cc=christoph.muellner@vrull.eu \
--cc=gcc-patches@gcc.gnu.org \
--cc=jlaw@ventanamicro.com \
--cc=kito.cheng@sifive.com \
--cc=palmer@dabbelt.com \
--cc=shihua@iscas.ac.cn \
--cc=shiyulong@iscas.ac.cn \
--cc=wuwei2016@iscas.ac.cn \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).