Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: logb() for fp16/bf16 is used by libc++, but is not defined when compiled with clang & libc++ #2743

Open
1 task done
Artem-B opened this issue Nov 7, 2024 · 1 comment · May be fixed by #2749
Open
1 task done
Labels
bug Something isn't working right.

Comments

@Artem-B
Copy link
Contributor

Artem-B commented Nov 7, 2024

Is this a duplicate?

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

@Artem-B Artem-B added the bug Something isn't working right. label Nov 7, 2024
@github-project-automation github-project-automation bot moved this to Todo in CCCL Nov 7, 2024
miscco added a commit to miscco/cccl that referenced this issue Nov 8, 2024
miscco added a commit to miscco/cccl that referenced this issue Nov 8, 2024
@miscco miscco linked a pull request Nov 8, 2024 that will close this issue
@miscco
Copy link
Collaborator

miscco commented Nov 8, 2024

I found that a ton of our cmath implementation has issues.

I started with log and fmin

miscco added a commit to miscco/cccl that referenced this issue Nov 8, 2024
miscco added a commit to miscco/cccl that referenced this issue Nov 8, 2024
miscco added a commit to miscco/cccl that referenced this issue Nov 8, 2024
miscco added a commit to miscco/cccl that referenced this issue Nov 8, 2024
miscco added a commit to miscco/cccl that referenced this issue Nov 8, 2024
miscco added a commit to miscco/cccl that referenced this issue Nov 9, 2024
miscco added a commit to miscco/cccl that referenced this issue Nov 9, 2024
miscco added a commit to miscco/cccl that referenced this issue Nov 9, 2024
miscco added a commit to miscco/cccl that referenced this issue Nov 10, 2024
miscco added a commit to miscco/cccl that referenced this issue Nov 10, 2024
miscco added a commit to miscco/cccl that referenced this issue Nov 10, 2024
miscco added a commit to miscco/cccl that referenced this issue Nov 12, 2024
miscco added a commit to miscco/cccl that referenced this issue Nov 17, 2024
miscco added a commit to miscco/cccl that referenced this issue Nov 18, 2024
miscco added a commit to miscco/cccl that referenced this issue Nov 19, 2024
miscco added a commit to miscco/cccl that referenced this issue Nov 21, 2024
miscco added a commit to miscco/cccl that referenced this issue Nov 21, 2024
miscco added a commit to miscco/cccl that referenced this issue Nov 22, 2024
miscco added a commit to miscco/cccl that referenced this issue Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working right.
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

2 participants