Created attachment 14717 [details] A simple dot product program that uses float and _Float16 'p'rint will successfully print the value of fp16 variables x/hf or x/f will not, it will print decimal instead (gdb) p x32[0] $1 = (__gnu_cxx::__alloc_traits<std::allocator<float>, float>::value_type &) @0x155554eed010: 0.100000001 (gdb) x/wf 0x155554eed010 0x155554eed010: 0.100000001 (gdb) p x16[0] $2 = (__gnu_cxx::__alloc_traits<std::allocator<_Float16>, _Float16>::value_type &) @0x1555552c6010: 0.099976 (gdb) x/hf 0x1555552c6010 0x1555552c6010: 11878 This is relevant to debugging rocm programs (AMD GPUs) as the "print" command under rocgdb does not not show __shared__ memory elements, and we must use 'x' to view the values of __half variables because we only have their addresses. (But that bug is AMD's.)
I have a fix.
https://sourceware.org/pipermail/gdb-patches/2023-February/197367.html
Works perfectly! Thanks for the quick action. (gdb) p x32[0] $1 = (__gnu_cxx::__alloc_traits<std::allocator<float>, float>::value_type &) @0x155554eed010: 0.100000001 (gdb) x/wf 0x155554eed010 0x155554eed010: 0.100000001 (gdb) p x16[0] $2 = (__gnu_cxx::__alloc_traits<std::allocator<_Float16>, _Float16>::value_type &) @0x1555552c6010: 0.099976 (gdb) x/hf 0x1555552c6010 0x1555552c6010: 0.099976 Is there anything else I can do to help this get into the next release so everyone can enjoy it?
It'll land relatively soon and then show up in 14.1. We probably won't put in on the gdb-13 branch, normally we don't do a lot in the point releases
The master branch has been updated by Tom Tromey <tromey@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=70728e1d396475e8e630bfdd3fb8e8c8211bdbbd commit 70728e1d396475e8e630bfdd3fb8e8c8211bdbbd Author: Tom Tromey <tromey@adacore.com> Date: Fri Feb 24 09:19:32 2023 -0700 Handle half-float in 'x' command Using 'x/hf' should print bytes as float16, but instead it currently prints as an integer. I tracked this down to a missing case in float_type_from_length. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30161 Approved-By: Simon Marchi <simon.marchi@efficios.com>
Fixed.