Closed AngryLoki closed 2 weeks ago
Hi @AngryLoki Thanks for reporting the issue! It seems like I am unable to reproduce your issue on ubuntu. Here are the steps I took:
docker run -it rocm/pytorch /bin/bash
sudo apt install lsb-release
wget software-properties-commonwget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 20
sudo apt install libc++-20-dev libc++abi-20-dev
vi test.cpp
#include <half/half.cpp>
#include <cmath>
int main(){ half_float::half v(0.2); std::isfinite(v); return 0; }
- Compile with hipcc and libc++
```bash
hipcc -O2 --stdlib=libc++ test.cpp
All I got was some warning regarding unused return value:
test.cpp:6:9: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
6 | std::isfinite(v);
| ^~~~~~~~~~~~~ ~
1 warning generated when compiling for gfx906.
test.cpp:6:9: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
6 | std::isfinite(v);
| ^~~~~~~~~~~~~ ~
Would you be able to double check on your end and see if the issue persists?
Also, please keep in mind that ROCm does not officially support Gentoo. I will label this issue with "enhancement" to reflect this properly.
Thanks :D
Hi, sorry for the lack of updates, as multiple things changed since I reported about this issue:
1) bug with no matching function for call to 'isfinite'
was fixed on llvm side - https://github.com/llvm/llvm-project/issues/98816
2) about second part (slow ADT-based code) developer in https://sourceforge.net/p/half/discussion/general/thread/7bee917723/#1046/0082 responded that adding std::isfinite
specialization has some issues, so they won't add it.
Note that the part of inoptimal code (std::isfinite(fp16_value_implicitly_casted_to_fp32)
) affects all platforms, both libc++/libstdc++. However I encountered this pattern only in miopen tests code, and there are no expectations for test code to be fast. And as https://github.com/ROCm/half/issues/8 plans to synchronize with upstream, while upstream has no plans to specialize isfinite
, I am closing this task.
Problem Description
Hi,
I noticed a few problems affecting ROCm/half and upstream (v2.2 incl. trunk), so I'll report in both places.
Both are related to
std::isfinite
. First problem is that it does not work with libc++. Here is a breakdown why: 1) Since C++11 std::isfinite is defined for integral types (having specific traits) 2) Used trait is std::is_arithmetic, it uses std::is_floating_point. Both traits have no specialization forhalf_float::half
3) What happens in gcc/libstdc++/msvc is thatstd::isfinite(half_value)
does implicit conversion to float and then checks for "isfinite". But it does not work in libc++.My current understanding is that it is a bug of libc++ (caused by misunderstanding of https://wg21.cmeerw.net/lwg/issue2086), so I reported it to https://github.com/llvm/llvm-project/issues/98816
Anyways, the second problem is that this conversion to float should not be called at all, because check could be much simpler:
Here is link to conformance view: https://godbolt.org/z/hhWebb9os
It looks safe, it fixes both problems mentioned above. Could you add it to half.hpp?
This affects ROCm/miopen, which currently fails with libc++ with:
Operating System
Gentoo
CPU
-
GPU
AMD Instinct MI300X
ROCm Version
ROCm 6.1.0
ROCm Component
No response
Steps to Reproduce
No response
(Optional for Linux users) Output of /opt/rocm/bin/rocminfo --support
No response
Additional Information
No response