29 #if !defined(VTKM_CUDA_DEVICE_PASS)
42 #define VTKM_CUDA_MATH_FUNCTION_32(func) func##f
43 #define VTKM_CUDA_MATH_FUNCTION_64(func) func
52 struct FloatingPointReturnType
55 using representable_as_float_type =
56 std::integral_constant<bool,
57 ((
sizeof(ctype) <
sizeof(
float)) ||
58 std::is_same<ctype, vtkm::Float32>::value)>;
59 using Type =
typename std::
60 conditional<representable_as_float_type::value, vtkm::Float32, vtkm::Float64>::type;
66 template <
typename T = vtkm::Float64>
67 static constexpr
inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type TwoPi()
69 using FT =
typename detail::FloatingPointReturnType<T>::Type;
70 return static_cast<FT
>(6.28318530717958647692528676655900576);
75 template <
typename T = vtkm::Float64>
76 static constexpr
inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type Pi()
78 using FT =
typename detail::FloatingPointReturnType<T>::Type;
79 return static_cast<FT
>(3.14159265358979323846264338327950288);
84 template <
typename T = vtkm::Float64>
85 static constexpr
inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type Pi_2()
87 using FT =
typename detail::FloatingPointReturnType<T>::Type;
88 return static_cast<FT
>(1.57079632679489661923132169163975144);
93 template <
typename T = vtkm::Float64>
94 static constexpr
inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type Pi_3()
96 using FT =
typename detail::FloatingPointReturnType<T>::Type;
97 return static_cast<FT
>(1.04719755119659774615421446109316762);
102 template <
typename T = vtkm::Float64>
103 static constexpr
inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type Pi_4()
105 using FT =
typename detail::FloatingPointReturnType<T>::Type;
106 return static_cast<FT
>(0.78539816339744830961566084581987572);
111 template <
typename T = vtkm::Float64>
112 static constexpr
inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type Pi_180()
114 using FT =
typename detail::FloatingPointReturnType<T>::Type;
115 return static_cast<FT
>(0.01745329251994329547437168059786927);
122 return TwoPi<vtkm::Float32>();
129 return Pi<vtkm::Float32>();
136 return Pi_2<vtkm::Float32>();
143 return Pi_3<vtkm::Float32>();
150 return Pi_4<vtkm::Float32>();
157 return Pi_180<vtkm::Float32>();
183 template <
typename T>
184 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Sin(
const T& x)
186 using RT =
typename detail::FloatingPointReturnType<T>::Type;
189 template <
typename T, vtkm::IdComponent N>
200 template <
typename T>
207 template <
typename T>
214 template <
typename T>
244 template <
typename T>
245 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Cos(
const T& x)
247 using RT =
typename detail::FloatingPointReturnType<T>::Type;
250 template <
typename T, vtkm::IdComponent N>
261 template <
typename T>
268 template <
typename T>
275 template <
typename T>
305 template <
typename T>
306 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Tan(
const T& x)
308 using RT =
typename detail::FloatingPointReturnType<T>::Type;
311 template <
typename T, vtkm::IdComponent N>
322 template <
typename T>
329 template <
typename T>
336 template <
typename T>
366 template <
typename T>
367 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
ASin(
const T& x)
369 using RT =
typename detail::FloatingPointReturnType<T>::Type;
372 template <
typename T, vtkm::IdComponent N>
383 template <
typename T>
390 template <
typename T>
397 template <
typename T>
427 template <
typename T>
428 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
ACos(
const T& x)
430 using RT =
typename detail::FloatingPointReturnType<T>::Type;
433 template <
typename T, vtkm::IdComponent N>
444 template <
typename T>
451 template <
typename T>
458 template <
typename T>
488 template <
typename T>
489 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
ATan(
const T& x)
491 using RT =
typename detail::FloatingPointReturnType<T>::Type;
494 template <
typename T, vtkm::IdComponent N>
505 template <
typename T>
512 template <
typename T>
519 template <
typename T>
537 return std::atan2(x, y);
545 return std::atan2(x, y);
571 template <
typename T>
572 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
SinH(
const T& x)
574 using RT =
typename detail::FloatingPointReturnType<T>::Type;
577 template <
typename T, vtkm::IdComponent N>
588 template <
typename T>
595 template <
typename T>
602 template <
typename T>
632 template <
typename T>
633 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
CosH(
const T& x)
635 using RT =
typename detail::FloatingPointReturnType<T>::Type;
638 template <
typename T, vtkm::IdComponent N>
649 template <
typename T>
656 template <
typename T>
663 template <
typename T>
693 template <
typename T>
694 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
TanH(
const T& x)
696 using RT =
typename detail::FloatingPointReturnType<T>::Type;
699 template <
typename T, vtkm::IdComponent N>
710 template <
typename T>
717 template <
typename T>
724 template <
typename T>
742 return std::asinh(x);
751 return std::asinh(x);
754 template <
typename T>
755 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
ASinH(
const T& x)
757 using RT =
typename detail::FloatingPointReturnType<T>::Type;
760 template <
typename T, vtkm::IdComponent N>
771 template <
typename T>
778 template <
typename T>
785 template <
typename T>
803 return std::acosh(x);
812 return std::acosh(x);
815 template <
typename T>
816 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
ACosH(
const T& x)
818 using RT =
typename detail::FloatingPointReturnType<T>::Type;
821 template <
typename T, vtkm::IdComponent N>
832 template <
typename T>
839 template <
typename T>
846 template <
typename T>
864 return std::atanh(x);
873 return std::atanh(x);
876 template <
typename T>
877 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
ATanH(
const T& x)
879 using RT =
typename detail::FloatingPointReturnType<T>::Type;
882 template <
typename T, vtkm::IdComponent N>
893 template <
typename T>
900 template <
typename T>
907 template <
typename T>
925 return std::pow(x, y);
933 return std::pow(x, y);
960 template <
typename T>
961 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Sqrt(
const T& x)
963 using RT =
typename detail::FloatingPointReturnType<T>::Type;
966 template <
typename T, vtkm::IdComponent N>
977 template <
typename T>
984 template <
typename T>
991 template <
typename T>
1015 template <
typename T>
1029 template <
typename T>
1034 #endif // !VTKM_CUDA
1036 template <
typename T, vtkm::IdComponent N>
1043 result[index] = vtkm::RSqrt(x[index]);
1047 template <
typename T>
1052 vtkm::RSqrt(x[0]), vtkm::RSqrt(x[1]), vtkm::RSqrt(x[2]), vtkm::RSqrt(x[3]));
1054 template <
typename T>
1059 vtkm::RSqrt(x[0]), vtkm::RSqrt(x[1]), vtkm::RSqrt(x[2]));
1061 template <
typename T>
1079 return std::cbrt(x);
1088 return std::cbrt(x);
1091 template <
typename T>
1092 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Cbrt(
const T& x)
1094 using RT =
typename detail::FloatingPointReturnType<T>::Type;
1097 template <
typename T, vtkm::IdComponent N>
1108 template <
typename T>
1115 template <
typename T>
1122 template <
typename T>
1146 template <
typename T>
1160 template <
typename T>
1165 #endif // !VTKM_CUDA
1167 template <
typename T, vtkm::IdComponent N>
1174 result[index] = vtkm::RCbrt(x[index]);
1178 template <
typename T>
1183 vtkm::RCbrt(x[0]), vtkm::RCbrt(x[1]), vtkm::RCbrt(x[2]), vtkm::RCbrt(x[3]));
1185 template <
typename T>
1190 vtkm::RCbrt(x[0]), vtkm::RCbrt(x[1]), vtkm::RCbrt(x[2]));
1192 template <
typename T>
1222 template <
typename T>
1223 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Exp(
const T& x)
1225 using RT =
typename detail::FloatingPointReturnType<T>::Type;
1228 template <
typename T, vtkm::IdComponent N>
1239 template <
typename T>
1246 template <
typename T>
1253 template <
typename T>
1271 return std::exp2(x);
1280 return std::exp2(x);
1283 template <
typename T>
1284 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Exp2(
const T& x)
1286 using RT =
typename detail::FloatingPointReturnType<T>::Type;
1289 template <
typename T, vtkm::IdComponent N>
1300 template <
typename T>
1307 template <
typename T>
1314 template <
typename T>
1333 return std::expm1(x);
1342 return std::expm1(x);
1345 template <
typename T>
1346 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
ExpM1(
const T& x)
1348 using RT =
typename detail::FloatingPointReturnType<T>::Type;
1351 template <
typename T, vtkm::IdComponent N>
1362 template <
typename T>
1369 template <
typename T>
1376 template <
typename T>
1397 template <
typename T>
1405 return vtkm::Pow(10, x);
1409 return vtkm::Pow(10, x);
1411 template <
typename T>
1416 #endif // !VTKM_CUDA
1418 template <
typename T, vtkm::IdComponent N>
1425 result[index] = vtkm::Exp10(x[index]);
1429 template <
typename T>
1434 vtkm::Exp10(x[0]), vtkm::Exp10(x[1]), vtkm::Exp10(x[2]), vtkm::Exp10(x[3]));
1436 template <
typename T>
1441 vtkm::Exp10(x[0]), vtkm::Exp10(x[1]), vtkm::Exp10(x[2]));
1443 template <
typename T>
1473 template <
typename T>
1474 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Log(
const T& x)
1476 using RT =
typename detail::FloatingPointReturnType<T>::Type;
1479 template <
typename T, vtkm::IdComponent N>
1490 template <
typename T>
1497 template <
typename T>
1504 template <
typename T>
1522 return std::log2(x);
1531 return std::log2(x);
1534 template <
typename T>
1535 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Log2(
const T& x)
1537 using RT =
typename detail::FloatingPointReturnType<T>::Type;
1540 template <
typename T, vtkm::IdComponent N>
1551 template <
typename T>
1558 template <
typename T>
1565 template <
typename T>
1583 return std::log10(x);
1592 return std::log10(x);
1595 template <
typename T>
1596 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Log10(
const T& x)
1598 using RT =
typename detail::FloatingPointReturnType<T>::Type;
1601 template <
typename T, vtkm::IdComponent N>
1612 template <
typename T>
1619 template <
typename T>
1626 template <
typename T>
1644 return std::log1p(x);
1653 return std::log1p(x);
1656 template <
typename T>
1657 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Log1P(
const T& x)
1659 using RT =
typename detail::FloatingPointReturnType<T>::Type;
1662 template <
typename T, vtkm::IdComponent N>
1673 template <
typename T>
1680 template <
typename T>
1687 template <
typename T>
1700 template <
typename T>
1705 return (std::max)(x, y);
1709 return (std::max)(x, y);
1711 #else // !VTKM_USE_STL
1717 return std::fmax(x, y);
1725 return std::fmax(x, y);
1728 #endif // !VTKM_USE_STL
1734 template <
typename T>
1736 #if defined(VTKM_USE_STL) && !defined(VTKM_HIP)
1739 return (std::min)(x, y);
1743 return (std::min)(x, y);
1745 #else // !VTKM_USE_STL OR HIP
1751 return std::fmin(x, y);
1759 return std::fmin(x, y);
1762 #endif // !VTKM_USE_STL
1768 template <
typename T>
1771 return (x < y) ? y : x;
1774 template <
typename T>
1781 Traits::SetComponent(
1782 result, index, vtkm::Max(Traits::GetComponent(x, index), Traits::GetComponent(y, index)));
1787 template <
typename T>
1790 return (x < y) ? x : y;
1793 template <
typename T>
1800 Traits::SetComponent(
1801 result, index, vtkm::Min(Traits::GetComponent(x, index), Traits::GetComponent(y, index)));
1810 template <
typename T>
1818 template <
typename T>
1829 return x > lo ? (x < hi ? x : hi) : lo;
1834 return x > lo ? (x < hi ? x : hi) : lo;
1841 #define VTKM_USE_IEEE_NONFINITE
1844 #ifdef VTKM_USE_IEEE_NONFINITE
1849 union IEEE754Bits32 {
1853 #define VTKM_NAN_BITS_32 0x7FC00000U
1854 #define VTKM_INF_BITS_32 0x7F800000U
1855 #define VTKM_NEG_INF_BITS_32 0xFF800000U
1856 #define VTKM_EPSILON_32 1e-5f
1858 union IEEE754Bits64 {
1862 #define VTKM_NAN_BITS_64 0x7FF8000000000000ULL
1863 #define VTKM_INF_BITS_64 0x7FF0000000000000ULL
1864 #define VTKM_NEG_INF_BITS_64 0xFFF0000000000000ULL
1865 #define VTKM_EPSILON_64 1e-9
1867 template <
typename T>
1873 using BitsType = vtkm::detail::IEEE754Bits32;
1893 return neginf.scalar;
1901 struct FloatLimits<
vtkm::Vec<vtkm::Float32, N>>
1903 using BitsType = vtkm::detail::IEEE754Bits32;
1936 using BitsType = vtkm::detail::IEEE754Bits64;
1956 return neginf.scalar;
1964 struct FloatLimits<
vtkm::Vec<vtkm::Float64, N>>
1966 using BitsType = vtkm::detail::IEEE754Bits64;
1996 #undef VTKM_NAN_BITS_32
1997 #undef VTKM_INF_BITS_32
1998 #undef VTKM_NEG_INF_BITS_32
1999 #undef VTKM_EPSILON_32
2000 #undef VTKM_NAN_BITS_64
2001 #undef VTKM_INF_BITS_64
2002 #undef VTKM_NEG_INF_BITS_64
2003 #undef VTKM_EPSILON_64
2006 #endif //VTKM_USE_IEEE_NONFINITE
2015 #ifdef VTKM_USE_IEEE_NONFINITE
2016 template <
typename T>
2019 return detail::FloatLimits<T>::Nan();
2021 #else // !VTKM_USE_IEEE_NONFINITE
2022 template <
typename T>
2025 return std::numeric_limits<T>::quiet_NaN();
2027 #endif // !VTKM_USE_IEEE_NONFINITE
2030 return vtkm::Nan<vtkm::Float32>();
2034 return vtkm::Nan<vtkm::Float64>();
2045 #ifdef VTKM_USE_IEEE_NONFINITE
2046 template <
typename T>
2049 return detail::FloatLimits<T>::Infinity();
2051 #else // !VTKM_USE_IEEE_NONFINITE
2052 template <
typename T>
2055 return std::numeric_limits<T>::infinity();
2057 #endif // !VTKM_USE_IEEE_NONFINITE
2060 return vtkm::Infinity<vtkm::Float32>();
2064 return vtkm::Infinity<vtkm::Float64>();
2076 #ifdef VTKM_USE_IEEE_NONFINITE
2077 template <
typename T>
2080 return detail::FloatLimits<T>::NegativeInfinity();
2082 #else // !VTKM_USE_IEEE_NONFINITE
2083 template <
typename T>
2086 return -std::numeric_limits<T>::infinity();
2088 #endif // !VTKM_USE_IEEE_NONFINITE
2091 return vtkm::NegativeInfinity<vtkm::Float32>();
2095 return vtkm::NegativeInfinity<vtkm::Float64>();
2106 #ifdef VTKM_USE_IEEE_NONFINITE
2107 template <
typename T>
2110 return detail::FloatLimits<T>::Epsilon();
2112 #else // !VTKM_USE_IEEE_NONFINITE
2113 template <
typename T>
2116 return std::numeric_limits<T>::epsilon();
2118 #endif // !VTKM_USE_IEEE_NONFINITE
2121 return vtkm::Epsilon<vtkm::Float32>();
2125 return vtkm::Epsilon<vtkm::Float64>();
2133 template <
typename T>
2139 return (isnan(x) != 0);
2144 template <
typename T>
2150 return (isinf(x) != 0);
2155 template <
typename T>
2159 using std::isfinite;
2161 return (isfinite(x) != 0);
2174 return std::ceil(x);
2183 return std::ceil(x);
2186 template <
typename T>
2187 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Ceil(
const T& x)
2189 using RT =
typename detail::FloatingPointReturnType<T>::Type;
2192 template <
typename T, vtkm::IdComponent N>
2203 template <
typename T>
2210 template <
typename T>
2217 template <
typename T>
2235 return std::floor(x);
2244 return std::floor(x);
2247 template <
typename T>
2248 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Floor(
const T& x)
2250 using RT =
typename detail::FloatingPointReturnType<T>::Type;
2253 template <
typename T, vtkm::IdComponent N>
2264 template <
typename T>
2271 template <
typename T>
2278 template <
typename T>
2296 return std::round(x);
2305 return std::round(x);
2308 template <
typename T>
2309 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Round(
const T& x)
2311 using RT =
typename detail::FloatingPointReturnType<T>::Type;
2314 template <
typename T, vtkm::IdComponent N>
2325 template <
typename T>
2332 template <
typename T>
2339 template <
typename T>
2360 return std::fmod(x, y);
2368 return std::fmod(x, y);
2381 template <
typename T>
2382 static inline VTKM_EXEC_CONT T Remainder(T numerator, T denominator)
2384 T quotient =
vtkm::Round(numerator / denominator);
2385 return numerator - quotient * denominator;
2393 return std::remainder(x, y);
2401 return std::remainder(x, y);
2404 #endif // !VTKM_MSVC
2412 template <
typename QType>
2419 #if defined(VTKM_CUDA) || defined(VTKM_HIP)
2423 const vtkm::Float32 result = std::remquo(numerator, denominator, &iQuotient);
2425 quotient =
static_cast<QType
>(iQuotient);
2428 template <
typename QType>
2438 const vtkm::Float64 result = std::remquo(numerator, denominator, &iQuotient);
2440 quotient =
static_cast<QType
>(iQuotient);
2452 #if defined(VTKM_CUDA) || defined(VTKM_HIP)
2455 return std::modf(x, &integral);
2460 #if defined(VTKM_CUDA)
2463 return std::modf(x, &integral);
2479 #if VTKM_SIZE_LONG == 8
2481 #elif VTKM_SIZE_LONG_LONG == 8
2484 #error Unknown size of Int64.
2492 return std::fabs(x);
2500 return std::fabs(x);
2503 template <
typename T>
2504 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type Abs(T x)
2512 template <
typename T, vtkm::IdComponent N>
2518 result[index] = vtkm::Abs(x[index]);
2522 template <
typename T>
2525 return vtkm::Vec<T, 4>(vtkm::Abs(x[0]), vtkm::Abs(x[1]), vtkm::Abs(x[2]), vtkm::Abs(x[3]));
2527 template <
typename T>
2530 return vtkm::Vec<T, 3>(vtkm::Abs(x[0]), vtkm::Abs(x[1]), vtkm::Abs(x[2]));
2532 template <
typename T>
2563 return (vtkm::SignBit(x) != 0);
2567 return (vtkm::SignBit(x) != 0);
2580 return std::copysign(x, y);
2588 return std::copysign(x, y);
2592 template <
typename T, vtkm::IdComponent N>
2599 result[index] = vtkm::CopySign(x[index], y[index]);
2611 #if defined(VTKM_CUDA) || defined(VTKM_HIP)
2614 return std::frexp(x, exponent);
2623 return std::frexp(x, exponent);
2633 return std::ldexp(x, exponent);
2642 return std::ldexp(x, exponent);
2701 static_assert(std::numeric_limits<vtkm::Float64>::has_denorm == std::denorm_present,
"FloatDistance presumes the floating-point type has subnormal numbers.");
2703 if (!vtkm::IsFinite(x) || !vtkm::IsFinite(y)) {
2704 return 0xFFFFFFFFFFFFFFFFL;
2715 if ( (x < 0 && y >= 0) || (x >= 0 && y < 0) )
2719 dy = detail::FloatDistancePositive(0.0, y);
2720 dx = detail::FloatDistancePositive(0.0, -x);
2723 dy = detail::FloatDistancePositive(0.0, -y);
2724 dx = detail::FloatDistancePositive(0.0, x);
2730 if (x < 0 && y < 0) {
2731 return detail::FloatDistancePositive(-x, -y);
2734 return detail::FloatDistancePositive(x, y);
2741 static_assert(std::numeric_limits<vtkm::Float32>::has_denorm == std::denorm_present,
"FloatDistance presumes the floating-point type has subnormal numbers.");
2743 if (!vtkm::IsFinite(x) || !vtkm::IsFinite(y)) {
2744 return 0xFFFFFFFFFFFFFFFFL;
2754 if ( (x < 0 && y >= 0) || (x >= 0 && y < 0) )
2758 dy = detail::FloatDistancePositive(0.0f, y);
2759 dx = detail::FloatDistancePositive(0.0f, -x);
2762 dy = detail::FloatDistancePositive(0.0f, -y);
2763 dx = detail::FloatDistancePositive(0.0f, x);
2768 if (x < 0 && y < 0) {
2769 return detail::FloatDistancePositive(-x, -y);
2772 return detail::FloatDistancePositive(x, y);
2777 template<
typename T>
2781 T err = std::fma(-c, d, cd);
2782 T dop = std::fma(a, b, -cd);
2794 template<
typename T>
2819 T q = -(b + vtkm::CopySign(
vtkm::Sqrt(delta), b)) / 2;
2834 #ifdef VTKM_CUDA_DEVICE_PASS
2840 return __ffs(
static_cast<int>(word));
2842 #else // CUDA_DEVICE_PASS
2846 # if defined(VTKM_GCC) || defined(VTKM_CLANG)
2849 return __builtin_ffs(
static_cast<int>(word));
2851 # elif defined(VTKM_MSVC)
2855 return _BitScanForward(
reinterpret_cast<DWORD*
>(&firstSet), word) != 0
2858 # elif defined(VTKM_ICC)
2861 return word != 0 ? _bit_scan_forward(word) + 1 : 0;
2872 while ((word & 0x1) == 0)
2881 #endif // CUDA_DEVICE_PASS
2885 #ifdef VTKM_CUDA_DEVICE_PASS
2892 return __ffsll(
static_cast<long long int>(word));
2894 #else // CUDA_DEVICE_PASS
2898 # if defined(VTKM_GCC) || defined(VTKM_CLANG) || defined(VTKM_ICC)
2901 return __builtin_ffsll(
static_cast<long long int>(word));
2903 # elif defined(VTKM_MSVC)
2907 return _BitScanForward64(
reinterpret_cast<DWORD*
>(&firstSet), word) != 0
2919 while ((word & 0x1) == 0)
2928 #endif // CUDA_DEVICE_PASS
2931 #ifdef VTKM_CUDA_DEVICE_PASS
2936 return __popc(word);
2938 #else // CUDA_DEVICE_PASS
2942 # if defined(VTKM_GCC) || defined(VTKM_CLANG)
2944 return __builtin_popcount(word);
2946 # elif defined(VTKM_MSVC) && !defined(_M_ARM64)
2950 # elif defined(VTKM_ICC)
2952 return _popcnt32(
static_cast<int>(word));
2970 #endif // CUDA_DEVICE_PASS
2973 #ifdef VTKM_CUDA_DEVICE_PASS
2978 return __popcll(word);
2980 #else // CUDA_DEVICE_PASS
2984 # if defined(VTKM_GCC) || defined(VTKM_CLANG)
2986 return __builtin_popcountll(word);
2988 # elif defined(VTKM_MSVC) && !defined(_M_ARM64)
2990 return static_cast<vtkm::Int32>(__popcnt64(word));
2992 # elif defined(VTKM_ICC)
3012 #endif // CUDA_DEVICE_PASS
3017 #endif //vtk_m_Math_h