mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Fix some CUDA warnings.
Added `EIGEN_HAS_STD_HASH` macro, checking for C++11 support and not running on GPU. `std::hash<float>` is not a device function, so cannot be used by `std::hash<bfloat16>`. Removed `EIGEN_DEVICE_FUNC` and only define if `EIGEN_HAS_STD_HASH`. Same for `half`. Added `EIGEN_CUDA_HAS_FP16_ARITHMETIC` to improve readability, eliminate warnings about `EIGEN_CUDA_ARCH` not being defined. Replaced a couple C-style casts with `reinterpret_cast` for aligned loading of `half*` to `half2*`. This eliminates `-Wcast-align` warnings in clang. Although not ideal due to potential type aliasing, this is how CUDA handles these conversions internally.
This commit is contained in:
committed by
Rasmus Munk Larsen
parent
88d4c6d4c8
commit
db5691ff2b
@@ -668,6 +668,17 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Does the compiler support std::hash?
|
||||
#ifndef EIGEN_HAS_STD_HASH
|
||||
// The std::hash struct is defined in C++11 but is not labelled as a __device__
|
||||
// function and is not constexpr, so cannot be used on device.
|
||||
#if EIGEN_HAS_CXX11 && !EIGEN_GPU_COMPILE_PHASE
|
||||
#define EIGEN_HAS_STD_HASH 1
|
||||
#else
|
||||
#define EIGEN_HAS_STD_HASH 0
|
||||
#endif
|
||||
#endif // EIGEN_HAS_STD_HASH
|
||||
|
||||
#ifndef EIGEN_HAS_ALIGNAS
|
||||
#if EIGEN_MAX_CPP_VER>=11 && EIGEN_HAS_CXX11 && \
|
||||
( __has_feature(cxx_alignas) \
|
||||
|
||||
Reference in New Issue
Block a user