https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71064

Thomas Schwinge <tschwinge at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|nvptx offloading: "long     |Offloading vs. 'long
                   |double" data type           |double' data type
           Keywords|                            |openmp
             Target|nvptx                       |nvptx, GCN
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2025-08-07
     Ever confirmed|0                           |1
                 CC|                            |burnus at gcc dot gnu.org,
                   |                            |kcy at codesourcery dot com

--- Comment #2 from Thomas Schwinge <tschwinge at gcc dot gnu.org> ---
Kwok Cheung Yeung, May 21, 2025 at 7:06 PM:
> [...] testcases for the <complex>, <numbers> and <cmath> headers running on 
> the offload target.
> 
> One problem I have noticed is with the std::nexttoward() function in cmath, 
> which triggers the following error on NVPTX:
> 
>     lto1: fatal error: nvptx-none - 80-bit-precision floating-point numbers 
> unsupported (mode 'XF')
> 
> Looking at the definition in c_global:
> 
>       constexpr float
>       nexttoward(float __x, long double __y)
>       { return __builtin_nexttowardf(__x, __y); }
>     
>       constexpr long double
>       nexttoward(long double __x, long double __y)
>       { return __builtin_nexttowardl(__x, __y); }
> 
> There is always at least one long double in the arguments, so this function 
> cannot work on an architecture that doesn’t support XF mode. I have #ifdef’ed 
> out the test for this function.


Tobias Burnus, May 21, 2025 at 7:45 PM:
>> There is always at least one long double in the arguments, so this function 
>> cannot work on an architecture that doesn’t support XF mode
> 
> … and likewise on systems where the host’s ‘long double' is TF (like on 
> PowerPC, which has multiple types of 128bit floating-point numbers).
> 
> On the other hand, it works on systems where the host’s ‘long double’ is the 
> same as ‘double’ (= DF) (like on Arm → Grace[-Hopper])
> 
> Workaround: use nextafter — which has the same type for ‘y' as for 'x’/return 
> type, contrary to nexttoward.


For that, we've put into 'libgomp.c++/target-std__cmath.C':

    #if 0
      /* TODO Due to 'std::nexttoward' using 'long double to', this triggers a
         '80-bit-precision floating-point numbers unsupported (mode ‘XF’)'
error
         with x86_64 host and nvptx, GCN offload compilers, or
         '128-bit-precision floating-point numbers unsupported (mode ‘TF’)'
error
         with powerpc64le host and nvptx offload compiler, for example;
         PR71064 'nvptx offloading: "long double" data type'.
         It ought to work on systems where the host's 'long double' is the same
as
         'double' ('DF'): aarch64, for example?  */
      next = std::nexttoward (x, y);
      if (!(next > x && next < y))
        return false;
    #endif

Reply via email to