fmtlib / fmt

A modern formatting library
https://fmt.dev
Other
20.74k stars 2.49k forks source link

Long double errors: Clang, libc++, CUDA #3106

Closed j8asic closed 2 years ago

j8asic commented 2 years ago

Seems like libc++ implementations of device functions do not support long double (i.e. CUDA doesnt have long double), so I am getting errors in visit_format_arg The treatment for me was to use long doubles as regular double here: https://github.com/fmtlib/fmt/blob/a48e3355a682b7e76d672c4dbd64aad2aad2ec6e/include/fmt/core.h#L1662

vitaut commented 2 years ago

{fmt} requires basic C++ support including long double. You might want to report an issue to NVIDIA asking them to at least make a sensible fallback.

j8asic commented 2 years ago

@vitaut so the libc++ guys say they are right to disable long double math functions on the device https://godbolt.org/z/9Th19nWqP. So this bug I rewrite as: “fmt tries to call device math functions for long double, instead of appropriate host functions”

vitaut commented 2 years ago

No idea what this means but a PR with a workaround for CUDA will be welcome provided that it's not too intrusive.

j8asic commented 1 year ago

The visit_format_arg function in core.h always tries to format long_double_type, which creates compile errors when long double math is disabled (sometimes we have FMT_USE_FLOAT128=0 because there are no implementations of those math functions e.g. for CUDA under libc++). So this case should be treated similar like for int128_type case is treated using FMT_USE_INT128. I.e. FMT_USE_FLOAT128 should be checked and taken into account.