Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: Ezra.Sitorus@arm.com, gdb-patches@sourceware.org
Cc: eliz@gnu.org, luis.machado.foss@gmail.com
Subject: Re: [PATCH 0/4] gdb: Display fp8 format for AArch64 registers
Date: Mon, 29 Sep 2025 18:55:35 +0100	[thread overview]
Message-ID: <5ec9ce76-d614-405f-96e8-f490e035aefb@palves.net> (raw)
In-Reply-To: <20250925211804.21967-1-Ezra.Sitorus@arm.com>

Hi!

On 2025-09-25 22:18, Ezra.Sitorus@arm.com wrote:
> From: Ezra Sitorus <ezra.sitorus@arm.com>
> 
> FP8 introduces 2 new formats: E4M3 and E5M2. This patch aims to add
> support for these types in gdb, and then display them in AArch64
> registers.
> 
> So far, this patch series only adds support for these in register printing.
> I've picked this, as opposed to printing fp8 variables because (as far
> as I'm aware) there is not enough DWARF information to help out with this.
> The __mfp8 type has the encoding type 7/unsigned. I'd like to hear any
> comments about this approach.

Is __mfp8 a real floating type supported by the compiler, or an opaque typedef?  

Some AMDGPUs have FP8 support, and there, Clang does not expose a real floating point
type for this.  Instead, we have __amd_fp8_storage_t type that is just a typedef to uint8_t.

From <https://gcc.gnu.org/pipermail/gcc-patches/2024-August/659261.html> I understand
that Aarch64's __mfp8 (and mfloat8_t) is the same.  Has that changed since?

Assuming it's still the same, since these types are really integers, making variables of
such types behave like real floating point variables would be incorrect, in the sense
that expressions involving them would behave differently in the actual source code compared
to typing them in GDB, like "print a + b" or "print c = 3.3", for example.

Since the "floatness" ends up being a presentation issue, for AMDGPU, we added support for
these types as gdb Python pretty printers instead.  We also added some gdb python functions
to manipulate them.  See:
  https://github.com/ROCm/ROCgdb/commit/ad1525387e2ae0a7e46d5b828967ab092c63ecfd

> 3/4: adds support for displaying these formats in certain AArch64 registers.

Is it really just display?  Doesn't the series allow writing to registers with "p \$v0.b.e4m3 = 3.3"
(where 3.3 is parsed as a double) or some such?  I suppose that might be OK if the type of the
register is a built-in GDB type with its own name that is not the same name as of the type the
compiler would use for a variable (__mfp8 / mfloat8_t).

What about expressions involving FP8 types, like addition, etc.  Doesn't that start working with
your series as well, if you start from one of those registers (or cast a number to the built-in
gdb type)?  Like "p \$v0.b.e4m3 + 3.3".

> 4/4: adds test cases for these register displays.

If it is possible to write to the register, and do arithmetic with it, I think we should have tests
for it.  Well, even if it isn't possible it would be good to test that too (to make sure it fails instead
of doing something bogus).

Another (related) detail that I think we should consider when it comes to expressions involving fp8 floats,
is that while the interchange format is the same between vendors, thanks to joint multi-vendor work
that lead to the OCP spec (https://www.opencompute.org/documents/ocp-8-bit-floating-point-specification-ofp8-revision-1-0-2023-12-01-pdf-1),
I believe ARM/Nvidia/AMD FP8 formats behave a bit differently from each other in terms of infinity/saturation/rounding
handling, things like that.  AMDGPUs even support two FP8 representations FP8-OCP and FP8-FNUZ, see:
  https://rocm.docs.amd.com/projects/HIP/en/latest/reference/low_fp_types.html

Are the AArch64 FP8s added here OCP?  I think it we are likely to end up with different versions
of these types in libiberty / gdb, so it'd be good to consider making that explicit in the names of
the floatformat types in libiberty as well as in the name of the gdb built-in types.

Thanks,
Pedro Alves


      parent reply	other threads:[~2025-09-29 17:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-25 21:18 Ezra.Sitorus
2025-09-25 21:18 ` [PATCH 1/4] libiberty: Add fp8 float formats Ezra.Sitorus
2025-09-25 21:18 ` [PATCH] gdb: Add support for fp8 formats Ezra.Sitorus
2025-09-25 21:18 ` [PATCH 3/4] gdb/aarch64: Display fp8 formats in registers Ezra.Sitorus
2025-10-11 13:10   ` Luis
2025-10-14  0:56     ` Ezra Sitorus
2025-10-17 10:20       ` Luis
2025-09-25 21:18 ` [PATCH 4/4] gdb/aarch64: Tests for verifying fp8 register formats Ezra.Sitorus
2025-09-29 17:55 ` Pedro Alves [this message]

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=5ec9ce76-d614-405f-96e8-f490e035aefb@palves.net \
    --to=pedro@palves.net \
    --cc=Ezra.Sitorus@arm.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=luis.machado.foss@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