public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alexander Monakov <amonakov@ispras.ru>
To: "Joshi, Tejas Sanjay" <TejasSanjay.Joshi@amd.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	 "honza.hubicka@gmail.com" <honza.hubicka@gmail.com>,
	 "Kumar, Venkataramanan" <Venkataramanan.Kumar@amd.com>
Subject: RE: [PATCH][X86_64] Separate znver4 insn reservations from older znvers
Date: Tue, 15 Nov 2022 15:51:04 +0300 (MSK)	[thread overview]
Message-ID: <8e489785-b181-fbcf-e029-cd75796a6f28@ispras.ru> (raw)
In-Reply-To: <DM6PR12MB47950F0182CF1C2E1E88B719E3049@DM6PR12MB4795.namprd12.prod.outlook.com>


On Tue, 15 Nov 2022, Joshi, Tejas Sanjay wrote:

> > > +;; AVX instructions
> > > +(define_insn_reservation "znver4_sse_log" 1
> > > +                      (and (eq_attr "cpu" "znver4")
> > > +                           (and (eq_attr "type" "sselog,sselog1")
> > > +                                (and (eq_attr "mode" "V4SF,V8SF,V2DF,V4DF")
> > > +                                 (eq_attr "memory" "none"))))
> > > +                      "znver4-direct,znver4-fpu")
> > > +
> > > +(define_insn_reservation "znver4_sse_log_evex" 1
> > > +                      (and (eq_attr "cpu" "znver4")
> > > +                           (and (eq_attr "type" "sselog,sselog1")
> > > +                                (and (eq_attr "mode" "V16SF,V8DF")
> > > +                                 (eq_attr "memory" "none"))))
> > > +
> > > +"znver4-direct,znver4-fpu0+znver4-fpu1|znver4-fpu2+znver4-fpu3")
> > > +
> > 
> > This is an AVX512 instruction, and you're modeling that it occupies two ports
> > at once and thus has half throughput, but later in the AVX512 section:
> > 
> > > +;; AVX512 instructions
> > > +(define_insn_reservation "znver4_sse_mul_evex" 3
> > > +                      (and (eq_attr "cpu" "znver4")
> > > +                           (and (eq_attr "type" "ssemul")
> > > +                                (and (eq_attr "mode" "V16SF,V8DF")
> > > +                                 (eq_attr "memory" "none"))))
> > > +                      "znver4-double,znver4-fpu0|znver4-fpu3")
> > 
> > none of the instructions are modeled this way. If that's on purpose, can you
> > add a comment? It's surprising, since generally AVX512 has half throughput
> > compared to AVX256 on Zen 4, but the model doesn't seem to reflect that.
> 
> > > +"znver4-direct,znver4-fpu0+znver4-fpu1|znver4-fpu2+znver4-fpu3")
> 
> AVX512 instructions (512-bitwide) occupy 2 consecutive cycles in the pipes
> they execute. So, it should be modelled as shown below:
> 
> (define_insn_reservation "znver4_sse_log_evex" 1
> 			 (and (eq_attr "cpu" "znver4")
> 			      (and (eq_attr "type" "sselog")
> 				   (and (eq_attr "mode" "V16SF,V8DF,XI")
> 				    (eq_attr "memory" "none"))))
> 			 "znver4-double,(znver4-fpu)*2")

I think instead of (znver4-fpu)*2 there should be

  znver4-fpu0*2|znver4-fpu1*2|znver4-fpu2*2|znver4-fpu3*2

assuming the instruction occupies the same pipe on both cycles (your
variant models as if it can move from one pipe to another).

> (define_insn_reservation "znver4_sse_mul_evex" 3
> 			 (and (eq_attr "cpu" "znver4")
> 			      (and (eq_attr "type" "ssemul")
> 				   (and (eq_attr "mode" "V16SF,V8DF")
> 				    (eq_attr "memory" "none"))))
> 			 "znver4-double,(znver4-fpu0|znver4-fpu1)*2")

Likewise here, znver4-fpu0*2|znver4-fpu1*2.

> Doing this way increased the insn-automata.cc size from 201402 lines to 212189.

Please reevaluate on top of my patches, the impact will be different.

> Hope it is a tolerable increase or do you have any suggestions?

Please take the corrections above into account.

Also I think it's better to use znver4-direct rather than znver4-double for
AVX512 instructions, because they are decoded as one uop, not two (it won't
make a practical difference due to a "Fix me", but it's a simple improvement).

Thanks.

Alexander

  reply	other threads:[~2022-11-15 12:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-14 16:18 Joshi, Tejas Sanjay
2022-11-14 18:51 ` Alexander Monakov
2022-11-15 12:08   ` Joshi, Tejas Sanjay
2022-11-15 12:51     ` Alexander Monakov [this message]
2022-11-21 11:40       ` Joshi, Tejas Sanjay
2022-11-21 15:30         ` Alexander Monakov
2022-12-01 11:28           ` Joshi, Tejas Sanjay
2022-12-01 19:01             ` Alexander Monakov
2022-12-12 21:41             ` Jan Hubička
2022-12-22 17:34               ` Joshi, Tejas Sanjay
2023-01-03 14:36                 ` Jan Hubicka
2023-01-03 14:52                   ` Alexander Monakov
2023-01-03 18:28                     ` Jan Hubicka
2023-01-05  5:52                   ` Joshi, Tejas Sanjay

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=8e489785-b181-fbcf-e029-cd75796a6f28@ispras.ru \
    --to=amonakov@ispras.ru \
    --cc=TejasSanjay.Joshi@amd.com \
    --cc=Venkataramanan.Kumar@amd.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=honza.hubicka@gmail.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 read-only IMAP folder(s) and NNTP newsgroup(s).