AcademySoftwareFoundation / AcademySoftwareFoundation/Imath
redefinition of `half` in `imath` when using with `hip-runtime-amd`
- Dominant language
- C++
- Stars
- 488
- Forks
- 161
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 3
Description
I am using `imath-3.1.11-2` together with `hip-runtime-amd-6.0.2-4` on Arch Linux, and I am getting this error during compilation:
```
/usr/include/Imath/half.h:989:7: error: type alias redefinition with different types ('Imath_3_1::half' vs '__half')
using half = IMATH_INTERNAL_NAMESPACE::half;
^
/opt/rocm/include/hip/amd_detail/amd_hip_fp16.h:1743:19: note: previous definition is here
using half = __half;
```
It seems to be caused by the combination of [this](https://github.com/AcademySoftwareFoundation/Imath/blob/2fc9d89ec52003350fcfd20f337bb3d0b870ff5a/src/Imath/half.h#L989) and [that](https://github.com/ROCm/clr/blob/cf0320a0b91a64a7825e374494b6a64db8ca7a4b/hipamd/include/hip/amd_detail/amd_hip_fp16.h#L1779).
This must have been introduced by ROCM recently, since I did not get this in the past. I would have written this on ROCM, but there seems to be an exception in imath for CUDA already (see first link above, line 988), so I guess an appropriate exception for ROCM would also make sense.
For my purposes, I temporarily removed `using half = IMATH_INTERNAL_NAMESPACE::half;`, but maybe a cleaner solution might be more widely accepted.
Contributor guide
Research direction
Start with src/Imath/half.h around the CUDA exception and compare it with hip/amd_detail/amd_hip_fp16.h around the conflicting half alias. Reproduce the compilation failure with imath-3.1.11-2 and hip-runtime-amd-6.0.2-4, then verify that the chosen compatibility change allows both headers to compile together without breaking the existing CUDA case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100