Repository navigation
Closed
Description
Is this a duplicate?
- I confirmed there appear to be no duplicate issues for this bug and that I agree to the Code of Conduct
Type of Bug
Compile-time Error
Component
libcu++
Describe the bug
Attempt to perform division on cuda::std::complex<__half> or __nv_bfloat16 fails to compile, because there's no specialized logb() function, which results in ambiguous overload resolution between logb(float) and logb(double).
In file included from /opt/compiler-explorer/cuda/12.6.1//include/cuda/std/cmath:25:
/opt/compiler-explorer/cuda/12.6.1//include/cuda/std/detail/libcxx/include/cmath:835:10: error: call to 'logb' is ambiguous
835 | return ::logb(__x);
| ^~~~~~
/opt/compiler-explorer/cuda/12.6.1//include/cuda/std/detail/libcxx/include/complex:639:30: note: in instantiation of function template specialization 'cuda::std::__constexpr_logb<__half>' requested here
639 | _Tp __logbw = _CUDA_VSTD::__constexpr_logb(
| ^
/opt/compiler-explorer/cuda/12.6.1//include/cuda/std/detail/libcxx/include/complex:436:17: note: in instantiation of function template specialization 'cuda::std::operator/<__half>' requested here
436 | __lhs = __lhs / complex<_Tp>(__rhs.real(), __rhs.imag());
| ^
/opt/compiler-explorer/cuda/12.6.1//include/cuda/std/detail/libcxx/include/complex:746:7: note: in instantiation of function template specialization 'cuda::std::operator/=<__half, __half>' requested here
746 | __t /= __y;
| ^
<source>:19:3: note: in instantiation of function template specialization 'test<__half>' requested here
19 | test<__half>();
| ^
/opt/compiler-explorer/clang-trunk-20241107/lib/clang/20/include/cuda_wrappers/cmath:35:37: note: candidate function
35 | __attribute__((device)) long double logb(long double);
| ^
/opt/compiler-explorer/cuda/12.6.1//include/crt/math_functions.hpp:587:31: note: candidate function
587 | __MATH_FUNCTIONS_DECL__ float logb(const float a)
| ^
/opt/compiler-explorer/clang-trunk-20241107/lib/clang/20/include/__clang_cuda_math.h:184:19: note: candidate function
184 | __DEVICE__ double logb(double __a) { return __nv_logb(__a); }
| ^
How to Reproduce
See https://godbolt.org/z/zcKdxvsvx
Expected behavior
Division on cuda::std::complex<half> and cuda::std::complex<__nv_bfloat16> compiles and works.
Reproduction link
https://godbolt.org/z/zcKdxvsvx
Operating System
No response
nvidia-smi output
No response
NVCC version
No response
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
- StatusShow more project fieldsDone
Activity
Move definition of logarithms into their own file and implement them …
Move definition of logarithms into their own file and implement them …
miscco commentedon Nov 8, 2024
I found that a ton of our cmath implementation has issues.
I started with
logandfminMove definition of logarithms into their own file and implement them …
Move definition of logarithms into their own file and implement them …
Move definition of logarithms into their own file and implement them …
Move definition of logarithms into their own file and implement them …
Move definition of logarithms into their own file and implement them …
Move definition of logarithms into their own file and implement them …
Move definition of logarithms into their own file and implement them …
Move definition of logarithms into their own file and implement them …
Move definition of logarithms into their own file and implement them …
Move definition of logarithms into their own file and implement them …
Move definition of logarithms into their own file and implement them …
Move definition of logarithms into their own file and implement them …
Move definition of logarithms into their own file and implement them …
Move definition of logarithms into their own file and implement them …
Move definition of logarithms into their own file and implement them …
Move definition of logarithms into their own file and implement them …
Move definition of logarithms into their own file and implement them …
Move definition of logarithms into their own file and implement them …
Move definition of logarithms into their own file and implement them …
Move definition of logarithms into their own file and implement them …