public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Jiang, Haochen" <haochen.jiang@intel.com>
To: Uros Bizjak <ubizjak@gmail.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	"Liu, Hongtao" <hongtao.liu@intel.com>
Subject: RE: [PATCH] i386: Add syscall to enable AMX for latest kernels
Date: Thu, 22 Sep 2022 06:23:05 +0000	[thread overview]
Message-ID: <SA1PR11MB5946DE82229621E438AC7A38EC4E9@SA1PR11MB5946.namprd11.prod.outlook.com> (raw)
In-Reply-To: <CAFULd4ZvSU4ARtbce_je6bU5ZUXp1iCaNiV10aJim4oH4Bt8Ww@mail.gmail.com>

Hi all,

I would like to backport this patch to GCC 12 release branch as machines with the version of default GCC
is 12.x (which is always using newer kernels), if the patch is not backported, the amx tests will always fail.

Ok for backport?

BRs,
Haochen

> -----Original Message-----
> From: Uros Bizjak <ubizjak@gmail.com>
> Sent: Tuesday, June 21, 2022 10:53 PM
> To: Jiang, Haochen <haochen.jiang@intel.com>
> Cc: gcc-patches@gcc.gnu.org; Liu, Hongtao <hongtao.liu@intel.com>
> Subject: Re: [PATCH] i386: Add syscall to enable AMX for latest kernels
> 
> On Tue, Jun 21, 2022 at 9:41 AM Jiang, Haochen <haochen.jiang@intel.com>
> wrote:
> >
> > > -----Original Message-----
> > > From: Uros Bizjak <ubizjak@gmail.com>
> > > Sent: Tuesday, June 21, 2022 3:06 PM
> > > To: Jiang, Haochen <haochen.jiang@intel.com>
> > > Cc: gcc-patches@gcc.gnu.org; Liu, Hongtao <hongtao.liu@intel.com>
> > > Subject: Re: [PATCH] i386: Add syscall to enable AMX for latest
> > > kernels
> > >
> > > On Tue, Jun 21, 2022 at 4:23 AM Jiang, Haochen
> > > <haochen.jiang@intel.com>
> > > wrote:
> > > >
> > > > > -----Original Message-----
> > > > > From: Uros Bizjak <ubizjak@gmail.com>
> > > > > Sent: Monday, June 20, 2022 10:54 PM
> > > > > To: Jiang, Haochen <haochen.jiang@intel.com>
> > > > > Cc: gcc-patches@gcc.gnu.org; Liu, Hongtao
> > > > > <hongtao.liu@intel.com>
> > > > > Subject: Re: [PATCH] i386: Add syscall to enable AMX for latest
> > > > > kernels
> > > > >
> > > > > On Mon, Jun 20, 2022 at 10:04 AM Haochen Jiang
> > > > > <haochen.jiang@intel.com>
> > > > > wrote:
> > > > > >
> > > > > > From: "Jiang, Haochen" <haochen.jiang@intel.com>
> > > > > >
> > > > > > Hi all,
> > > > > >
> > > > > > We need syscall to enable AMX for kernels>=5.4. It is missing
> > > > > > in current amx tests, which will cause test fail.
> > > > >
> > > > > So this new code is only valid for linux & co?
> > > >
> > > > Thanks for reminding me for that, I only test on linux since the
> > > > header file is
> > > only in linux.
> > > >
> > > > Just updated a patch wrapping with a macro not to change the
> > > > behavior on
> > > windows.
> > >
> > > I think you want __linux__ there, not __unix__.
> >
> > Fixed with __linux__.
> 
> OK.
> 
> Thanks,
> Uros.
> 
> >
> > Thx,
> > Haochen
> >
> > >
> > > Uros.
> > >
> > > >
> > > > Regtested on x86_64-pc-linux-gnu.
> > > >
> > > > Thx,
> > > > Haochen
> > > > >
> > > > > Uros.
> > > > >
> > > > > >
> > > > > > This patch aims to add them to fix this bug.
> > > > > >
> > > > > > BRs,
> > > > > > Haochen
> > > > > >
> > > > > > gcc/testsuite/ChangeLog:
> > > > > >
> > > > > >         * gcc.target/i386/amx-check.h (request_perm_xtile_data):
> > > > > >         New function to check if AMX is usable and enable AMX.
> > > > > >         (main): Run test if AMX is usable.
> > > > > > ---
> > > > > >  gcc/testsuite/gcc.target/i386/amx-check.h | 24
> > > > > > +++++++++++++++++++++++
> > > > > >  1 file changed, 24 insertions(+)
> > > > > >
> > > > > > diff --git a/gcc/testsuite/gcc.target/i386/amx-check.h
> > > > > > b/gcc/testsuite/gcc.target/i386/amx-check.h
> > > > > > index 434b0e59703..92ed8669304 100644
> > > > > > --- a/gcc/testsuite/gcc.target/i386/amx-check.h
> > > > > > +++ b/gcc/testsuite/gcc.target/i386/amx-check.h
> > > > > > @@ -4,11 +4,22 @@
> > > > > >  #include <stdlib.h>
> > > > > >  #include <string.h>
> > > > > >  #include <stdint.h>
> > > > > > +#include <unistd.h>
> > > > > > +#include <sys/syscall.h>
> > > > > >  #ifdef DEBUG
> > > > > >  #include <stdio.h>
> > > > > >  #endif
> > > > > >  #include "cpuid.h"
> > > > > >
> > > > > > +#define XFEATURE_XTILECFG      17
> > > > > > +#define XFEATURE_XTILEDATA     18
> > > > > > +#define XFEATURE_MASK_XTILECFG (1 << XFEATURE_XTILECFG)
> > > > > > +#define XFEATURE_MASK_XTILEDATA        (1 << XFEATURE_XTILEDATA)
> > > > > > +#define XFEATURE_MASK_XTILE    (XFEATURE_MASK_XTILECFG |
> > > > > XFEATURE_MASK_XTILEDATA)
> > > > > > +
> > > > > > +#define ARCH_GET_XCOMP_PERM    0x1022
> > > > > > +#define ARCH_REQ_XCOMP_PERM    0x1023
> > > > > > +
> > > > > >  /* TODO: The tmm emulation is temporary for current
> > > > > >     AMX implementation with no tmm regclass, should
> > > > > >     be changed in the future. */ @@ -44,6 +55,18 @@ typedef
> > > > > > struct __tile
> > > > > >  /* Stride (colum width in byte) used for tileload/store */
> > > > > > #define _STRIDE 64
> > > > > >
> > > > > > +/* We need syscall to use amx functions */ int
> > > > > > +request_perm_xtile_data() {
> > > > > > +  unsigned long bitmask;
> > > > > > +
> > > > > > +  if (syscall (SYS_arch_prctl, ARCH_REQ_XCOMP_PERM,
> > > > > XFEATURE_XTILEDATA) ||
> > > > > > +      syscall (SYS_arch_prctl, ARCH_GET_XCOMP_PERM, &bitmask))
> > > > > > +    return 0;
> > > > > > +
> > > > > > +  return (bitmask & XFEATURE_MASK_XTILE) != 0; }
> > > > > > +
> > > > > >  /* Initialize tile config by setting all tmm size to 16x64 */
> > > > > > void init_tile_config (__tilecfg_u *dst)  { @@ -186,6 +209,7
> > > > > > @@ main () #ifdef AMX_BF16
> > > > > >        && __builtin_cpu_supports ("amx-bf16")  #endif
> > > > > > +      && request_perm_xtile_data ()
> > > > > >        )
> > > > > >      {
> > > > > >        DO_TEST ();
> > > > > > --
> > > > > > 2.18.2
> > > > > >

  reply	other threads:[~2022-09-22  6:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-20  8:04 Haochen Jiang
2022-06-20 14:53 ` Uros Bizjak
2022-06-21  2:23   ` Jiang, Haochen
2022-06-21  7:06     ` Uros Bizjak
2022-06-21  7:41       ` Jiang, Haochen
2022-06-21 14:52         ` Uros Bizjak
2022-09-22  6:23           ` Jiang, Haochen [this message]
2022-09-22  6:23             ` Liu, Hongtao

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=SA1PR11MB5946DE82229621E438AC7A38EC4E9@SA1PR11MB5946.namprd11.prod.outlook.com \
    --to=haochen.jiang@intel.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hongtao.liu@intel.com \
    --cc=ubizjak@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).