From b07fb960e9330af7601ef135241dfef0200f4f74 Mon Sep 17 00:00:00 2001 From: Paul Mattione Date: Tue, 16 Jul 2024 04:19:05 -0400 Subject: [PATCH] Remove 64/128bit switches due to register pressure --- cpp/include/cudf/fixed_point/fixed_point.hpp | 4 +- .../cudf/fixed_point/floating_conversion.hpp | 138 +----------------- 2 files changed, 6 insertions(+), 136 deletions(-) diff --git a/cpp/include/cudf/fixed_point/fixed_point.hpp b/cpp/include/cudf/fixed_point/fixed_point.hpp index 6c3c3b4da07..c9cbc603226 100644 --- a/cpp/include/cudf/fixed_point/fixed_point.hpp +++ b/cpp/include/cudf/fixed_point/fixed_point.hpp @@ -84,8 +84,8 @@ template && - is_supported_representation_type())>* = nullptr> -CUDF_HOST_DEVICE inline Rep ipow(T exponent) + cuda::std::is_integral_v)>* = nullptr> +CUDF_HOST_DEVICE inline constexpr Rep ipow(T exponent) { cudf_assert(exponent >= 0 && "integer exponentiation with negative exponent is not possible."); diff --git a/cpp/include/cudf/fixed_point/floating_conversion.hpp b/cpp/include/cudf/fixed_point/floating_conversion.hpp index c64ae8877d4..f12177c6a4b 100644 --- a/cpp/include/cudf/fixed_point/floating_conversion.hpp +++ b/cpp/include/cudf/fixed_point/floating_conversion.hpp @@ -392,30 +392,7 @@ CUDF_HOST_DEVICE inline T divide_power10_32bit(T value, int pow10) template )> CUDF_HOST_DEVICE inline T divide_power10_64bit(T value, int pow10) { - // See comments in divide_power10_32bit() for discussion. - switch (pow10) { - case 0: return value; - case 1: return value / 10U; - case 2: return value / 100U; - case 3: return value / 1000U; - case 4: return value / 10000U; - case 5: return value / 100000U; - case 6: return value / 1000000U; - case 7: return value / 10000000U; - case 8: return value / 100000000U; - case 9: return value / 1000000000U; - case 10: return value / 10000000000ULL; - case 11: return value / 100000000000ULL; - case 12: return value / 1000000000000ULL; - case 13: return value / 10000000000000ULL; - case 14: return value / 100000000000000ULL; - case 15: return value / 1000000000000000ULL; - case 16: return value / 10000000000000000ULL; - case 17: return value / 100000000000000000ULL; - case 18: return value / 1000000000000000000ULL; - case 19: return value / 10000000000000000000ULL; - default: return 0; - } + return value / ipow(pow10); } /** @@ -429,49 +406,7 @@ CUDF_HOST_DEVICE inline T divide_power10_64bit(T value, int pow10) template )> CUDF_HOST_DEVICE inline constexpr T divide_power10_128bit(T value, int pow10) { - // See comments in divide_power10_32bit() for an introduction. - switch (pow10) { - case 0: return value; - case 1: return value / 10U; - case 2: return value / 100U; - case 3: return value / 1000U; - case 4: return value / 10000U; - case 5: return value / 100000U; - case 6: return value / 1000000U; - case 7: return value / 10000000U; - case 8: return value / 100000000U; - case 9: return value / 1000000000U; - case 10: return value / 10000000000ULL; - case 11: return value / 100000000000ULL; - case 12: return value / 1000000000000ULL; - case 13: return value / 10000000000000ULL; - case 14: return value / 100000000000000ULL; - case 15: return value / 1000000000000000ULL; - case 16: return value / 10000000000000000ULL; - case 17: return value / 100000000000000000ULL; - case 18: return value / 1000000000000000000ULL; - case 19: return value / 10000000000000000000ULL; - case 20: return value / large_power_of_10<20>(); - case 21: return value / large_power_of_10<21>(); - case 22: return value / large_power_of_10<22>(); - case 23: return value / large_power_of_10<23>(); - case 24: return value / large_power_of_10<24>(); - case 25: return value / large_power_of_10<25>(); - case 26: return value / large_power_of_10<26>(); - case 27: return value / large_power_of_10<27>(); - case 28: return value / large_power_of_10<28>(); - case 29: return value / large_power_of_10<29>(); - case 30: return value / large_power_of_10<30>(); - case 31: return value / large_power_of_10<31>(); - case 32: return value / large_power_of_10<32>(); - case 33: return value / large_power_of_10<33>(); - case 34: return value / large_power_of_10<34>(); - case 35: return value / large_power_of_10<35>(); - case 36: return value / large_power_of_10<36>(); - case 37: return value / large_power_of_10<37>(); - case 38: return value / large_power_of_10<38>(); - default: return 0; - } + return value / ipow<__uint128_t, Radix::BASE_10>(pow10); } /** @@ -512,30 +447,7 @@ CUDF_HOST_DEVICE inline constexpr T multiply_power10_32bit(T value, int pow10) template )> CUDF_HOST_DEVICE inline constexpr T multiply_power10_64bit(T value, int pow10) { - // See comments in divide_power10_32bit() for discussion. - switch (pow10) { - case 0: return value; - case 1: return value * 10U; - case 2: return value * 100U; - case 3: return value * 1000U; - case 4: return value * 10000U; - case 5: return value * 100000U; - case 6: return value * 1000000U; - case 7: return value * 10000000U; - case 8: return value * 100000000U; - case 9: return value * 1000000000U; - case 10: return value * 10000000000ULL; - case 11: return value * 100000000000ULL; - case 12: return value * 1000000000000ULL; - case 13: return value * 10000000000000ULL; - case 14: return value * 100000000000000ULL; - case 15: return value * 1000000000000000ULL; - case 16: return value * 10000000000000000ULL; - case 17: return value * 100000000000000000ULL; - case 18: return value * 1000000000000000000ULL; - case 19: return value * 10000000000000000000ULL; - default: return 0; - } + return value * ipow(pow10); } /** @@ -549,49 +461,7 @@ CUDF_HOST_DEVICE inline constexpr T multiply_power10_64bit(T value, int pow10) template )> CUDF_HOST_DEVICE inline constexpr T multiply_power10_128bit(T value, int pow10) { - // See comments in divide_power10_128bit() for discussion. - switch (pow10) { - case 0: return value; - case 1: return value * 10U; - case 2: return value * 100U; - case 3: return value * 1000U; - case 4: return value * 10000U; - case 5: return value * 100000U; - case 6: return value * 1000000U; - case 7: return value * 10000000U; - case 8: return value * 100000000U; - case 9: return value * 1000000000U; - case 10: return value * 10000000000ULL; - case 11: return value * 100000000000ULL; - case 12: return value * 1000000000000ULL; - case 13: return value * 10000000000000ULL; - case 14: return value * 100000000000000ULL; - case 15: return value * 1000000000000000ULL; - case 16: return value * 10000000000000000ULL; - case 17: return value * 100000000000000000ULL; - case 18: return value * 1000000000000000000ULL; - case 19: return value * 10000000000000000000ULL; - case 20: return value * large_power_of_10<20>(); - case 21: return value * large_power_of_10<21>(); - case 22: return value * large_power_of_10<22>(); - case 23: return value * large_power_of_10<23>(); - case 24: return value * large_power_of_10<24>(); - case 25: return value * large_power_of_10<25>(); - case 26: return value * large_power_of_10<26>(); - case 27: return value * large_power_of_10<27>(); - case 28: return value * large_power_of_10<28>(); - case 29: return value * large_power_of_10<29>(); - case 30: return value * large_power_of_10<30>(); - case 31: return value * large_power_of_10<31>(); - case 32: return value * large_power_of_10<32>(); - case 33: return value * large_power_of_10<33>(); - case 34: return value * large_power_of_10<34>(); - case 35: return value * large_power_of_10<35>(); - case 36: return value * large_power_of_10<36>(); - case 37: return value * large_power_of_10<37>(); - case 38: return value * large_power_of_10<38>(); - default: return 0; - } + return value * ipow<__uint128_t, Radix::BASE_10>(pow10); } /**