From cfd773a0437c192a0a9d25cf37d241043ab84b5f Mon Sep 17 00:00:00 2001 From: Tobias Ribizel Date: Mon, 13 Jan 2025 10:15:02 +0100 Subject: [PATCH] reduce constexpr complexity --- common/unified/components/range_minimum_query_kernels.cpp | 4 ++-- core/components/range_minimum_query.hpp | 4 +--- core/test/components/range_minimum_query.cpp | 8 ++++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/common/unified/components/range_minimum_query_kernels.cpp b/common/unified/components/range_minimum_query_kernels.cpp index b44e6fe0ca4..a6de0474d0f 100644 --- a/common/unified/components/range_minimum_query_kernels.cpp +++ b/common/unified/components/range_minimum_query_kernels.cpp @@ -35,11 +35,11 @@ void compute_lookup_small(std::shared_ptr exec, 1 << (std::decay_t::bits_per_word_log2 - ceil_log2_constexpr(ceil_log2_constexpr(small_block_size))); const device_lut_type lut{exec}; - constexpr auto infinity = std::numeric_limits::max(); run_kernel( exec, [] GKO_KERNEL(auto collated_block_idx, auto values, auto block_argmin, auto block_min, auto block_type, auto lut, auto size) { + constexpr auto infinity = std::numeric_limits::max(); const auto num_blocks = ceildiv(size, small_block_size); for (auto block_idx = collated_block_idx * collation_width; block_idx < @@ -87,12 +87,12 @@ void compute_lookup_large( // we need to collate all writes that target the same memory word in a // single thread constexpr auto level0_collation_width = sizeof(word_type) * CHAR_BIT; - constexpr auto infinity = std::numeric_limits::max(); // initialize the first level of blocks run_kernel( exec, [] GKO_KERNEL(auto collated_i, auto block_min, auto superblocks, auto num_blocks) { + constexpr auto infinity = std::numeric_limits::max(); for (auto i = collated_i * level0_collation_width; i < std::min((collated_i + 1) * level0_collation_width, num_blocks); diff --git a/core/components/range_minimum_query.hpp b/core/components/range_minimum_query.hpp index d9c31c7dd87..3899a40516f 100644 --- a/core/components/range_minimum_query.hpp +++ b/core/components/range_minimum_query.hpp @@ -122,8 +122,6 @@ struct cartesian_tree { } return all_representatives[num_nodes]; } - - constexpr static auto representatives = compute_tree_representatives(); }; @@ -141,7 +139,7 @@ class block_range_minimum_query_lookup_table { constexpr block_range_minimum_query_lookup_table() : lookup_table{} { - const auto& representatives = tree::representatives; + const auto& representatives = tree::compute_tree_representatives(); for (int tree = 0; tree < num_trees; tree++) { const auto& rep = representatives[tree]; for (int first = 0; first < block_size; first++) { diff --git a/core/test/components/range_minimum_query.cpp b/core/test/components/range_minimum_query.cpp index d00dd7a525f..d35bbbd8555 100644 --- a/core/test/components/range_minimum_query.cpp +++ b/core/test/components/range_minimum_query.cpp @@ -17,7 +17,7 @@ TEST(RangeMinimumQuery, RepresentativesAreExhaustive) using tree = gko::detail::cartesian_tree; int values[size]{}; std::iota(values, values + size, 0); - constexpr auto reps = tree::representatives; + const auto reps = tree::compute_tree_representatives(); do { const auto tree_number = tree::compute_tree_index(values); const auto rep_tree_number = @@ -34,7 +34,7 @@ TEST(RangeMinimumQuery, RepresentativesLargeAreExhaustive) using tree = gko::detail::cartesian_tree; int values[size]{}; std::iota(values, values + size, 0); - constexpr auto reps = tree::representatives; + const auto reps = tree::compute_tree_representatives(); do { const auto tree_number = tree::compute_tree_index(values); const auto rep_tree_number = @@ -49,8 +49,8 @@ TEST(RangeMinimumQuery, LookupRepresentatives) { constexpr auto size = 8; using tree = gko::detail::cartesian_tree; - /*constexpr*/ gko::block_range_minimum_query_lookup_table table; - auto reps = tree::compute_tree_representatives(); + gko::block_range_minimum_query_lookup_table table; + const auto reps = tree::compute_tree_representatives(); for (const auto& rep : reps) { const auto tree = tree::compute_tree_index(rep); for (const auto first : gko::irange{size}) {