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
53 struct FloatingPointReturnType
56 using representable_as_float_type = std::integral_constant<bool,
57 ((
sizeof(ctype) <
sizeof(
float)) || std::is_same<ctype, vtkm::Float32>::value)>;
58 using Type =
typename std::conditional<representable_as_float_type::value,
68 return 6.28318530717958647692528676655900576f;
75 return 3.14159265358979323846264338327950288f;
82 return 1.57079632679489661923132169163975144f;
89 return 1.04719755119659774615421446109316762f;
96 return 0.78539816339744830961566084581987572f;
103 return 0.01745329251994329547437168059786927f;
110 return 6.28318530717958647692528676655900576;
117 return 3.14159265358979323846264338327950288;
124 return 1.57079632679489661923132169163975144;
131 return 1.04719755119659774615421446109316762;
138 return 0.78539816339744830961566084581987572;
145 return 0.01745329251994329547437168059786927;
150 template <
typename T>
151 static constexpr
inline VTKM_EXEC_CONT auto TwoPi() ->
typename detail::FloatingPointReturnType<T>::Type
153 using FT =
typename detail::FloatingPointReturnType<T>::Type;
154 using RAFT =
typename detail::FloatingPointReturnType<T>::representable_as_float_type;
155 return static_cast<FT
>(RAFT::value ? TwoPif() : TwoPi());
160 template <
typename T>
161 static constexpr
inline VTKM_EXEC_CONT auto Pi() ->
typename detail::FloatingPointReturnType<T>::Type
163 using FT =
typename detail::FloatingPointReturnType<T>::Type;
164 using RAFT =
typename detail::FloatingPointReturnType<T>::representable_as_float_type;
165 return static_cast<FT
>(RAFT::value ? Pif() : Pi());
170 template <
typename T>
171 static constexpr
inline VTKM_EXEC_CONT auto Pi_2() ->
typename detail::FloatingPointReturnType<T>::Type
173 using FT =
typename detail::FloatingPointReturnType<T>::Type;
174 using RAFT =
typename detail::FloatingPointReturnType<T>::representable_as_float_type;
175 return static_cast<FT
>(RAFT::value ? Pi_2f() : Pi_2());
180 template <
typename T>
181 static constexpr
inline VTKM_EXEC_CONT auto Pi_3() ->
typename detail::FloatingPointReturnType<T>::Type
183 using FT =
typename detail::FloatingPointReturnType<T>::Type;
184 using RAFT =
typename detail::FloatingPointReturnType<T>::representable_as_float_type;
185 return static_cast<FT
>(RAFT::value ? Pi_3f() : Pi_3());
190 template <
typename T>
191 static constexpr
inline VTKM_EXEC_CONT auto Pi_4() ->
typename detail::FloatingPointReturnType<T>::Type
193 using FT =
typename detail::FloatingPointReturnType<T>::Type;
194 using RAFT =
typename detail::FloatingPointReturnType<T>::representable_as_float_type;
195 return static_cast<FT
>(RAFT::value ? Pi_4f() : Pi_4());
199 template <
typename T>
200 static constexpr
inline VTKM_EXEC_CONT auto Pi_180() ->
typename detail::FloatingPointReturnType<T>::Type
202 using FT =
typename detail::FloatingPointReturnType<T>::Type;
203 using RAFT =
typename detail::FloatingPointReturnType<T>::representable_as_float_type;
204 return static_cast<FT
>(RAFT::value ? Pi_180f() : Pi_180());
227 template <
typename T>
228 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Sin(
const T& x)
230 using RT =
typename detail::FloatingPointReturnType<T>::Type;
233 template <
typename T, vtkm::IdComponent N>
244 template <
typename T>
251 template <
typename T>
258 template <
typename T>
286 template <
typename T>
287 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Cos(
const T& x)
289 using RT =
typename detail::FloatingPointReturnType<T>::Type;
292 template <
typename T, vtkm::IdComponent N>
303 template <
typename T>
310 template <
typename T>
317 template <
typename T>
345 template <
typename T>
346 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Tan(
const T& x)
348 using RT =
typename detail::FloatingPointReturnType<T>::Type;
351 template <
typename T, vtkm::IdComponent N>
362 template <
typename T>
369 template <
typename T>
376 template <
typename T>
404 template <
typename T>
405 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
ASin(
const T& x)
407 using RT =
typename detail::FloatingPointReturnType<T>::Type;
410 template <
typename T, vtkm::IdComponent N>
421 template <
typename T>
428 template <
typename T>
435 template <
typename T>
463 template <
typename T>
464 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
ACos(
const T& x)
466 using RT =
typename detail::FloatingPointReturnType<T>::Type;
469 template <
typename T, vtkm::IdComponent N>
480 template <
typename T>
487 template <
typename T>
494 template <
typename T>
522 template <
typename T>
523 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
ATan(
const T& x)
525 using RT =
typename detail::FloatingPointReturnType<T>::Type;
528 template <
typename T, vtkm::IdComponent N>
539 template <
typename T>
546 template <
typename T>
553 template <
typename T>
569 return std::atan2(x, y);
577 return std::atan2(x, y);
601 template <
typename T>
602 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
SinH(
const T& x)
604 using RT =
typename detail::FloatingPointReturnType<T>::Type;
607 template <
typename T, vtkm::IdComponent N>
618 template <
typename T>
625 template <
typename T>
632 template <
typename T>
660 template <
typename T>
661 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
CosH(
const T& x)
663 using RT =
typename detail::FloatingPointReturnType<T>::Type;
666 template <
typename T, vtkm::IdComponent N>
677 template <
typename T>
684 template <
typename T>
691 template <
typename T>
719 template <
typename T>
720 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
TanH(
const T& x)
722 using RT =
typename detail::FloatingPointReturnType<T>::Type;
725 template <
typename T, vtkm::IdComponent N>
736 template <
typename T>
743 template <
typename T>
750 template <
typename T>
766 return std::asinh(x);
775 return std::asinh(x);
778 template <
typename T>
779 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
ASinH(
const T& x)
781 using RT =
typename detail::FloatingPointReturnType<T>::Type;
784 template <
typename T, vtkm::IdComponent N>
795 template <
typename T>
802 template <
typename T>
809 template <
typename T>
825 return std::acosh(x);
834 return std::acosh(x);
837 template <
typename T>
838 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
ACosH(
const T& x)
840 using RT =
typename detail::FloatingPointReturnType<T>::Type;
843 template <
typename T, vtkm::IdComponent N>
854 template <
typename T>
861 template <
typename T>
868 template <
typename T>
884 return std::atanh(x);
893 return std::atanh(x);
896 template <
typename T>
897 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
ATanH(
const T& x)
899 using RT =
typename detail::FloatingPointReturnType<T>::Type;
902 template <
typename T, vtkm::IdComponent N>
913 template <
typename T>
920 template <
typename T>
927 template <
typename T>
943 return std::pow(x, y);
951 return std::pow(x, y);
975 template <
typename T>
976 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Sqrt(
const T& x)
978 using RT =
typename detail::FloatingPointReturnType<T>::Type;
981 template <
typename T, vtkm::IdComponent N>
992 template <
typename T>
999 template <
typename T>
1006 template <
typename T>
1028 template <
typename T>
1042 template <
typename T>
1047 #endif // !VTKM_CUDA
1049 template <
typename T, vtkm::IdComponent N>
1056 result[index] = vtkm::RSqrt(x[index]);
1060 template <
typename T>
1065 vtkm::RSqrt(x[0]), vtkm::RSqrt(x[1]), vtkm::RSqrt(x[2]), vtkm::RSqrt(x[3]));
1067 template <
typename T>
1072 vtkm::RSqrt(x[0]), vtkm::RSqrt(x[1]), vtkm::RSqrt(x[2]));
1074 template <
typename T>
1090 return std::cbrt(x);
1099 return std::cbrt(x);
1102 template <
typename T>
1103 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Cbrt(
const T& x)
1105 using RT =
typename detail::FloatingPointReturnType<T>::Type;
1108 template <
typename T, vtkm::IdComponent N>
1119 template <
typename T>
1126 template <
typename T>
1133 template <
typename T>
1155 template <
typename T>
1169 template <
typename T>
1174 #endif // !VTKM_CUDA
1176 template <
typename T, vtkm::IdComponent N>
1183 result[index] = vtkm::RCbrt(x[index]);
1187 template <
typename T>
1192 vtkm::RCbrt(x[0]), vtkm::RCbrt(x[1]), vtkm::RCbrt(x[2]), vtkm::RCbrt(x[3]));
1194 template <
typename T>
1199 vtkm::RCbrt(x[0]), vtkm::RCbrt(x[1]), vtkm::RCbrt(x[2]));
1201 template <
typename T>
1229 template <
typename T>
1230 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Exp(
const T& x)
1232 using RT =
typename detail::FloatingPointReturnType<T>::Type;
1235 template <
typename T, vtkm::IdComponent N>
1246 template <
typename T>
1253 template <
typename T>
1260 template <
typename T>
1276 return std::exp2(x);
1285 return std::exp2(x);
1288 template <
typename T>
1289 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Exp2(
const T& x)
1291 using RT =
typename detail::FloatingPointReturnType<T>::Type;
1294 template <
typename T, vtkm::IdComponent N>
1305 template <
typename T>
1312 template <
typename T>
1319 template <
typename T>
1336 return std::expm1(x);
1345 return std::expm1(x);
1348 template <
typename T>
1349 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
ExpM1(
const T& x)
1351 using RT =
typename detail::FloatingPointReturnType<T>::Type;
1354 template <
typename T, vtkm::IdComponent N>
1365 template <
typename T>
1372 template <
typename T>
1379 template <
typename T>
1398 template <
typename T>
1406 return vtkm::Pow(10, x);
1410 return vtkm::Pow(10, x);
1412 template <
typename T>
1417 #endif // !VTKM_CUDA
1419 template <
typename T, vtkm::IdComponent N>
1426 result[index] = vtkm::Exp10(x[index]);
1430 template <
typename T>
1435 vtkm::Exp10(x[0]), vtkm::Exp10(x[1]), vtkm::Exp10(x[2]), vtkm::Exp10(x[3]));
1437 template <
typename T>
1442 vtkm::Exp10(x[0]), vtkm::Exp10(x[1]), vtkm::Exp10(x[2]));
1444 template <
typename T>
1472 template <
typename T>
1473 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Log(
const T& x)
1475 using RT =
typename detail::FloatingPointReturnType<T>::Type;
1478 template <
typename T, vtkm::IdComponent N>
1489 template <
typename T>
1496 template <
typename T>
1503 template <
typename T>
1519 return std::log2(x);
1528 return std::log2(x);
1531 template <
typename T>
1532 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Log2(
const T& x)
1534 using RT =
typename detail::FloatingPointReturnType<T>::Type;
1537 template <
typename T, vtkm::IdComponent N>
1548 template <
typename T>
1555 template <
typename T>
1562 template <
typename T>
1578 return std::log10(x);
1587 return std::log10(x);
1590 template <
typename T>
1591 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Log10(
const T& x)
1593 using RT =
typename detail::FloatingPointReturnType<T>::Type;
1596 template <
typename T, vtkm::IdComponent N>
1607 template <
typename T>
1614 template <
typename T>
1621 template <
typename T>
1637 return std::log1p(x);
1646 return std::log1p(x);
1649 template <
typename T>
1650 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Log1P(
const T& x)
1652 using RT =
typename detail::FloatingPointReturnType<T>::Type;
1655 template <
typename T, vtkm::IdComponent N>
1666 template <
typename T>
1673 template <
typename T>
1680 template <
typename T>
1691 template <
typename T>
1696 return (std::max)(x, y);
1700 return (std::max)(x, y);
1702 #else // !VTKM_USE_STL
1708 return std::fmax(x, y);
1716 return std::fmax(x, y);
1719 #endif // !VTKM_USE_STL
1723 template <
typename T>
1725 #if defined(VTKM_USE_STL) && !defined(VTKM_HIP)
1728 return (std::min)(x, y);
1732 return (std::min)(x, y);
1734 #else // !VTKM_USE_STL OR HIP
1740 return std::fmin(x, y);
1748 return std::fmin(x, y);
1751 #endif // !VTKM_USE_STL
1756 template <
typename T>
1759 return (x < y) ? y : x;
1762 template <
typename T>
1769 Traits::SetComponent(
1770 result, index, vtkm::Max(Traits::GetComponent(x, index), Traits::GetComponent(y, index)));
1775 template <
typename T>
1778 return (x < y) ? x : y;
1781 template <
typename T>
1788 Traits::SetComponent(
1789 result, index, vtkm::Min(Traits::GetComponent(x, index), Traits::GetComponent(y, index)));
1798 template <
typename T>
1806 template <
typename T>
1817 return x > lo ? (x < hi ? x : hi) : lo;
1822 return x > lo ? (x < hi ? x : hi) : lo;
1827 #define VTKM_USE_IEEE_NONFINITE
1830 #ifdef VTKM_USE_IEEE_NONFINITE
1835 union IEEE754Bits32 {
1839 #define VTKM_NAN_BITS_32 0x7FC00000U
1840 #define VTKM_INF_BITS_32 0x7F800000U
1841 #define VTKM_NEG_INF_BITS_32 0xFF800000U
1842 #define VTKM_EPSILON_32 1e-5f
1844 union IEEE754Bits64 {
1848 #define VTKM_NAN_BITS_64 0x7FF8000000000000ULL
1849 #define VTKM_INF_BITS_64 0x7FF0000000000000ULL
1850 #define VTKM_NEG_INF_BITS_64 0xFFF0000000000000ULL
1851 #define VTKM_EPSILON_64 1e-9
1853 template <
typename T>
1859 using BitsType = vtkm::detail::IEEE754Bits32;
1879 return neginf.scalar;
1887 struct FloatLimits<
vtkm::
Vec<vtkm::Float32, N>>
1889 using BitsType = vtkm::detail::IEEE754Bits32;
1922 using BitsType = vtkm::detail::IEEE754Bits64;
1942 return neginf.scalar;
1950 struct FloatLimits<
vtkm::
Vec<vtkm::Float64, N>>
1952 using BitsType = vtkm::detail::IEEE754Bits64;
1982 #undef VTKM_NAN_BITS_32
1983 #undef VTKM_INF_BITS_32
1984 #undef VTKM_NEG_INF_BITS_32
1985 #undef VTKM_EPSILON_32
1986 #undef VTKM_NAN_BITS_64
1987 #undef VTKM_INF_BITS_64
1988 #undef VTKM_NEG_INF_BITS_64
1989 #undef VTKM_EPSILON_64
1995 template <
typename T>
1998 return detail::FloatLimits<T>::Nan();
2003 template <
typename T>
2006 return detail::FloatLimits<T>::Infinity();
2011 template <
typename T>
2014 return detail::FloatLimits<T>::NegativeInfinity();
2020 template <
typename T>
2023 return detail::FloatLimits<T>::Epsilon();
2026 #else // !VTKM_USE_IEEE_NONFINITE
2030 template <
typename T>
2033 return std::numeric_limits<T>::quiet_NaN();
2038 template <
typename T>
2041 return std::numeric_limits<T>::infinity();
2046 template <
typename T>
2049 return -std::numeric_limits<T>::infinity();
2055 template <
typename T>
2058 return std::numeric_limits<T>::epsilon();
2060 #endif // !VTKM_USE_IEEE_NONFINITE
2066 return vtkm::Nan<vtkm::Float32>();
2070 return vtkm::Nan<vtkm::Float64>();
2077 return vtkm::Infinity<vtkm::Float32>();
2081 return vtkm::Infinity<vtkm::Float64>();
2088 return vtkm::NegativeInfinity<vtkm::Float32>();
2092 return vtkm::NegativeInfinity<vtkm::Float64>();
2100 return vtkm::Epsilon<vtkm::Float32>();
2104 return vtkm::Epsilon<vtkm::Float64>();
2110 template <
typename T>
2116 return (isnan(x) != 0);
2121 template <
typename T>
2127 return (isinf(x) != 0);
2132 template <
typename T>
2136 using std::isfinite;
2138 return (isfinite(x) != 0);
2150 return std::ceil(x);
2159 return std::ceil(x);
2162 template <
typename T>
2163 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Ceil(
const T& x)
2165 using RT =
typename detail::FloatingPointReturnType<T>::Type;
2168 template <
typename T, vtkm::IdComponent N>
2179 template <
typename T>
2186 template <
typename T>
2193 template <
typename T>
2209 return std::floor(x);
2218 return std::floor(x);
2221 template <
typename T>
2222 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Floor(
const T& x)
2224 using RT =
typename detail::FloatingPointReturnType<T>::Type;
2227 template <
typename T, vtkm::IdComponent N>
2238 template <
typename T>
2245 template <
typename T>
2252 template <
typename T>
2268 return std::round(x);
2277 return std::round(x);
2280 template <
typename T>
2281 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type
Round(
const T& x)
2283 using RT =
typename detail::FloatingPointReturnType<T>::Type;
2286 template <
typename T, vtkm::IdComponent N>
2297 template <
typename T>
2304 template <
typename T>
2311 template <
typename T>
2330 return std::fmod(x, y);
2338 return std::fmod(x, y);
2349 template <
typename T>
2350 static inline VTKM_EXEC_CONT T Remainder(T numerator, T denominator)
2352 T quotient =
vtkm::Round(numerator / denominator);
2353 return numerator - quotient * denominator;
2361 return std::remainder(x, y);
2369 return std::remainder(x, y);
2372 #endif // !VTKM_MSVC
2378 template <
typename QType>
2385 #if defined(VTKM_CUDA) || defined(VTKM_HIP)
2389 const vtkm::Float32 result = std::remquo(numerator, denominator, &iQuotient);
2391 quotient =
static_cast<QType
>(iQuotient);
2394 template <
typename QType>
2404 const vtkm::Float64 result = std::remquo(numerator, denominator, &iQuotient);
2406 quotient =
static_cast<QType
>(iQuotient);
2416 #if defined(VTKM_CUDA) || defined(VTKM_HIP)
2419 return std::modf(x, &integral);
2424 #if defined(VTKM_CUDA)
2427 return std::modf(x, &integral);
2441 #if VTKM_SIZE_LONG == 8
2443 #elif VTKM_SIZE_LONG_LONG == 8
2446 #error Unknown size of Int64.
2454 return std::fabs(x);
2462 return std::fabs(x);
2465 template <
typename T>
2466 static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type Abs(T x)
2474 template <
typename T, vtkm::IdComponent N>
2480 result[index] = vtkm::Abs(x[index]);
2484 template <
typename T>
2487 return vtkm::Vec<T, 4>(vtkm::Abs(x[0]), vtkm::Abs(x[1]), vtkm::Abs(x[2]), vtkm::Abs(x[3]));
2489 template <
typename T>
2492 return vtkm::Vec<T, 3>(vtkm::Abs(x[0]), vtkm::Abs(x[1]), vtkm::Abs(x[2]));
2494 template <
typename T>
2521 return (vtkm::SignBit(x) != 0);
2525 return (vtkm::SignBit(x) != 0);
2536 return std::copysign(x, y);
2544 return std::copysign(x, y);
2548 template <
typename T, vtkm::IdComponent N>
2555 result[index] = vtkm::CopySign(x[index], y[index]);
2566 #if defined(VTKM_CUDA) || defined(VTKM_HIP)
2569 return std::frexp(x, exponent);
2578 return std::frexp(x, exponent);
2587 return std::ldexp(x, exponent);
2596 return std::ldexp(x, exponent);
2621 memcpy(&xi, &x,
sizeof(vtkm::UInt64));
2622 memcpy(&yi, &y,
sizeof(vtkm::UInt64));
2639 vtkm::UInt64 xi = xi_32;
2640 vtkm::UInt64 yi = yi_32;
2651 static_assert(
sizeof(
vtkm::Float64) ==
sizeof(vtkm::UInt64),
"vtkm::Float64 is incorrect size.");
2652 static_assert(std::numeric_limits<vtkm::Float64>::has_denorm == std::denorm_present,
"FloatDistance presumes the floating-point type has subnormal numbers.");
2654 if (!vtkm::IsFinite(x) || !vtkm::IsFinite(y)) {
2655 return 0xFFFFFFFFFFFFFFFFL;
2666 if ( (x < 0 && y >= 0) || (x >= 0 && y < 0) )
2668 vtkm::UInt64 dx, dy;
2670 dy = detail::FloatDistancePositive(0.0, y);
2671 dx = detail::FloatDistancePositive(0.0, -x);
2674 dy = detail::FloatDistancePositive(0.0, -y);
2675 dx = detail::FloatDistancePositive(0.0, x);
2681 if (x < 0 && y < 0) {
2682 return detail::FloatDistancePositive(-x, -y);
2685 return detail::FloatDistancePositive(x, y);
2691 static_assert(std::numeric_limits<vtkm::Float32>::has_denorm == std::denorm_present,
"FloatDistance presumes the floating-point type has subnormal numbers.");
2693 if (!vtkm::IsFinite(x) || !vtkm::IsFinite(y)) {
2694 return 0xFFFFFFFFFFFFFFFFL;
2704 if ( (x < 0 && y >= 0) || (x >= 0 && y < 0) )
2706 vtkm::UInt64 dx, dy;
2708 dy = detail::FloatDistancePositive(0.0f, y);
2709 dx = detail::FloatDistancePositive(0.0f, -x);
2712 dy = detail::FloatDistancePositive(0.0f, -y);
2713 dx = detail::FloatDistancePositive(0.0f, x);
2718 if (x < 0 && y < 0) {
2719 return detail::FloatDistancePositive(-x, -y);
2722 return detail::FloatDistancePositive(x, y);
2727 template<
typename T>
2731 T err = std::fma(-c, d, cd);
2732 T dop = std::fma(a, b, -cd);
2741 template<
typename T>
2766 T q = -(b + vtkm::CopySign(
vtkm::Sqrt(delta), b)) / 2;
2781 #ifdef VTKM_CUDA_DEVICE_PASS
2787 return __ffs(
static_cast<int>(word));
2789 #else // CUDA_DEVICE_PASS
2793 # if defined(VTKM_GCC) || defined(VTKM_CLANG)
2796 return __builtin_ffs(
static_cast<int>(word));
2798 # elif defined(VTKM_MSVC)
2802 return _BitScanForward(
reinterpret_cast<DWORD*
>(&firstSet), word) != 0
2805 # elif defined(VTKM_ICC)
2808 return word != 0 ? _bit_scan_forward(word) + 1 : 0;
2819 while ((word & 0x1) == 0)
2828 #endif // CUDA_DEVICE_PASS
2832 #ifdef VTKM_CUDA_DEVICE_PASS
2839 return __ffsll(
static_cast<long long int>(word));
2841 #else // CUDA_DEVICE_PASS
2845 # if defined(VTKM_GCC) || defined(VTKM_CLANG) || defined(VTKM_ICC)
2848 return __builtin_ffsll(
static_cast<long long int>(word));
2850 # elif defined(VTKM_MSVC)
2854 return _BitScanForward64(
reinterpret_cast<DWORD*
>(&firstSet), word) != 0
2866 while ((word & 0x1) == 0)
2875 #endif // CUDA_DEVICE_PASS
2878 #ifdef VTKM_CUDA_DEVICE_PASS
2883 return __popc(word);
2885 #else // CUDA_DEVICE_PASS
2889 # if defined(VTKM_GCC) || defined(VTKM_CLANG)
2891 return __builtin_popcount(word);
2893 # elif defined(VTKM_MSVC) && !defined(_M_ARM64)
2897 # elif defined(VTKM_ICC)
2899 return _popcnt32(
static_cast<int>(word));
2917 #endif // CUDA_DEVICE_PASS
2920 #ifdef VTKM_CUDA_DEVICE_PASS
2925 return __popcll(word);
2927 #else // CUDA_DEVICE_PASS
2931 # if defined(VTKM_GCC) || defined(VTKM_CLANG)
2933 return __builtin_popcountll(word);
2935 # elif defined(VTKM_MSVC) && !defined(_M_ARM64)
2937 return static_cast<vtkm::Int32>(__popcnt64(word));
2939 # elif defined(VTKM_ICC)
2941 return _popcnt64(
static_cast<vtkm::Int64
>(word));
2959 #endif // CUDA_DEVICE_PASS
2964 #endif //vtk_m_Math_h