mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-23 10:09:36 +08:00
Fixed another clang warning
This commit is contained in:
parent
f8fbb3f9a6
commit
27f3fb2bcc
@ -28,6 +28,21 @@ namespace Eigen {
|
|||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
template <typename T>
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE int count_leading_zeros(const T val)
|
||||||
|
{
|
||||||
|
#ifndef __CUDA_ARCH__
|
||||||
|
if (sizeof(T) == 8) {
|
||||||
|
return __builtin_clzl(val);
|
||||||
|
}
|
||||||
|
return __builtin_clz(val);
|
||||||
|
#else
|
||||||
|
return __clz(val);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct TensorIntDivisor {
|
struct TensorIntDivisor {
|
||||||
public:
|
public:
|
||||||
@ -44,11 +59,7 @@ struct TensorIntDivisor {
|
|||||||
eigen_assert(divider <= (1<<(N-1)) - 1);
|
eigen_assert(divider <= (1<<(N-1)) - 1);
|
||||||
|
|
||||||
// fast ln2
|
// fast ln2
|
||||||
#ifndef __CUDA_ARCH__
|
const int leading_zeros = count_leading_zeros(divider);
|
||||||
const int leading_zeros = __builtin_clz(divider);
|
|
||||||
#else
|
|
||||||
const int leading_zeros = __clz(divider);
|
|
||||||
#endif
|
|
||||||
const int log_div = N - (leading_zeros+1);
|
const int log_div = N - (leading_zeros+1);
|
||||||
|
|
||||||
multiplier = (static_cast<uint64_t>(1) << (N+log_div)) / divider - (static_cast<uint64_t>(1) << N) + 1;
|
multiplier = (static_cast<uint64_t>(1) << (N+log_div)) / divider - (static_cast<uint64_t>(1) << N) + 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user