public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Hongtao Liu <crazylht@gmail.com>
Cc: x86-64-abi@googlegroups.com, llvm-dev <llvm-dev@lists.llvm.org>,
	 GNU C Library <libc-alpha@sourceware.org>,
	GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Add optional __Bfloat16 support
Date: Fri, 10 Jun 2022 15:50:19 +0800	[thread overview]
Message-ID: <CAMZc-bzS_cmJCBrveDqduRJuxr5XxVN=+34yFOoc2XtDqph3_A@mail.gmail.com> (raw)
In-Reply-To: <20220610074704.7673-1-hongtao.liu@intel.com>

On Fri, Jun 10, 2022 at 3:47 PM liuhongt via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> Pass and return __Bfloat16 values in XMM registers.
>
> Background:
> __Bfloat16 (BF16) is a new floating-point format that can accelerate machine learning (deep learning training, in particular) algorithms.
> It's first introduced by Intel AVX-512 extension called AVX-512_BF16. __Bfloat16 has 8 bits of exponent and 7 bits of mantissa and it's different from _Float16.
>
> Movivation:
> Currently __bfloat16 is a typedef of short, which creates a problem where the compiler does not raise any alarms if it is used to add, subtract, multiply or divide, but the result of the calculation is actually meaningless.
> To solve this problem, a real scalar type __Bfloat16 needs to be introduced. It is mainly used for intrinsics, not available for C standard operators. __Bfloat16 will also be used for movement like passing parameter, load and store, vector initialization, vector shuffle, and .etc. It creates a need for a corresponding psABI.
>
> ---
>  x86-64-ABI/low-level-sys-info.tex | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/x86-64-ABI/low-level-sys-info.tex b/x86-64-ABI/low-level-sys-info.tex
> index a8b69db..ba8db0d 100644
> --- a/x86-64-ABI/low-level-sys-info.tex
> +++ b/x86-64-ABI/low-level-sys-info.tex
> @@ -302,6 +302,12 @@ be used to represent the type, is a family of integer types.
>  This permits the use of these types in allocated arrays using the common
>  sizeof(Array)/sizeof(ElementType) pattern.
>
> +\subsubsection{Special Types}
> +
> +The \code{__Bfloat16} type uses a 8-bit exponent and 7-bit mantissa.
> +It is used for \code{BF16} related intrinsics, it cannot be
> +used with standard C operators.
> +
>  \subsubsection{Aggregates and Unions}
>
>  Structures and unions assume the alignment of their most strictly
> @@ -563,8 +569,8 @@ The basic types are assigned their natural classes:
>  \item Arguments of types (signed and unsigned) \code{_Bool}, \code{char},
>    \code{short}, \code{int}, \code{long}, \code{long long}, and
>    pointers are in the INTEGER class.
> -\item Arguments of types \code{_Float16}, \code{float}, \code{double},
> -  \code{_Decimal32},
> +\item Arguments of types \code{_Float16}, \code{__Bfloat16}, \code{float},
> +  \code{double}, \code{_Decimal32},
>    \code{_Decimal64} and \code{__m64} are in class SSE.
>  \item Arguments of types \code{__float128}, \code{_Decimal128}
>    and \code{__m128} are split into two halves.  The least significant
> --
> 2.18.1
>


-- 
BR,
Hongtao

  reply	other threads:[~2022-06-10  7:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-10  7:47 liuhongt
2022-06-10  7:50 ` Hongtao Liu [this message]
2022-06-10  9:38 ` Florian Weimer
2022-06-10 14:44   ` H.J. Lu
2022-06-10 17:45     ` H.J. Lu
2022-06-13  6:29       ` Hongtao Liu

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='CAMZc-bzS_cmJCBrveDqduRJuxr5XxVN=+34yFOoc2XtDqph3_A@mail.gmail.com' \
    --to=crazylht@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libc-alpha@sourceware.org \
    --cc=llvm-dev@lists.llvm.org \
    --cc=x86-64-abi@googlegroups.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).