From 7d67093faa469ced9bc18697e4953f31c4159fe8 Mon Sep 17 00:00:00 2001 From: Vukasin Milovanovic Date: Mon, 7 Mar 2022 14:12:01 -0800 Subject: [PATCH] Fix floating point data generation in benchmarks (#10372) `numeric_limits::lowest` and `numeric_limits::max` are used as bounds for numeric type generation. However, for normal generators, bounds are shifted to `[0, upper_bound - lower_bound]`, and the random value is shifted back by `lower_bound`. with `lowest` and `max`, `upper_bound - lower_bound` is out of range for floats and generated values are `nan` and `inf`. This PR halves the ranges so that `upper_bound - lower_bound` is still within the type range. Expected to affect benchmarks that use floating point columns (e.g. Parquet reader benchmarks). Authors: - Vukasin Milovanovic (https://github.com/vuule) Approvers: - Bradley Dice (https://github.com/bdice) - https://github.com/nvdbaranec URL: https://github.com/rapidsai/cudf/pull/10372 --- cpp/benchmarks/common/generate_input.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp/benchmarks/common/generate_input.hpp b/cpp/benchmarks/common/generate_input.hpp index 43fee5c50a7..5246de00a73 100644 --- a/cpp/benchmarks/common/generate_input.hpp +++ b/cpp/benchmarks/common/generate_input.hpp @@ -114,7 +114,8 @@ std::pair default_range() template ()>* = nullptr> std::pair default_range() { - return {std::numeric_limits::lowest(), std::numeric_limits::max()}; + // Limits need to be such that `upper - lower` does not overflow + return {std::numeric_limits::lowest() / 2, std::numeric_limits::max() / 2}; } } // namespace