diff --git a/include/cuco/detail/open_addressing/open_addressing_ref_impl.cuh b/include/cuco/detail/open_addressing/open_addressing_ref_impl.cuh index 1750d5949..e3217cf24 100644 --- a/include/cuco/detail/open_addressing/open_addressing_ref_impl.cuh +++ b/include/cuco/detail/open_addressing/open_addressing_ref_impl.cuh @@ -241,6 +241,16 @@ class open_addressing_ref_impl { return storage_ref_.capacity(); } + /** + * @brief Gets the window extent of the current storage. + * + * @return The window extent. + */ + [[nodiscard]] __host__ __device__ constexpr extent_type window_extent() const noexcept + { + return storage_ref_.window_extent(); + } + /** * @brief Returns a const_iterator to one past the last slot. * diff --git a/include/cuco/detail/static_map/static_map_ref.inl b/include/cuco/detail/static_map/static_map_ref.inl index c6a24bf7e..6ec2d4ef4 100644 --- a/include/cuco/detail/static_map/static_map_ref.inl +++ b/include/cuco/detail/static_map/static_map_ref.inl @@ -115,6 +115,26 @@ static_map_ref return impl_.capacity(); } +template +__host__ __device__ constexpr static_map_ref::extent_type +static_map_ref::window_extent() + const noexcept +{ + return impl_.window_extent(); +} + template ::c return impl_.capacity(); } +template +__host__ __device__ constexpr static_set_ref::extent_type +static_set_ref::window_extent() + const noexcept +{ + return impl_.window_extent(); +} + template ; + cuco::experimental::static_map + map{extent_type{}, cuco::empty_key{-1}, cuco::empty_value{-1}}; + + auto ref = map.ref(cuco::experimental::insert); + auto const num_windows = ref.window_extent(); + STATIC_REQUIRE(static_cast(num_windows) == gold_extent); + } + SECTION("Dynamic extent is evaluated at run time.") { auto constexpr gold_capacity = 422; // 211 x 2 diff --git a/tests/static_set/capacity_test.cu b/tests/static_set/capacity_test.cu index f042cdb73..c4916ca40 100644 --- a/tests/static_set/capacity_test.cu +++ b/tests/static_set/capacity_test.cu @@ -60,6 +60,20 @@ TEST_CASE("Static set capacity", "") constexpr std::size_t num_keys{400}; + SECTION("Static window extent can be evaluated at build time.") + { + std::size_t constexpr gold_extent = 211; + + using extent_type = cuco::experimental::extent; + cuco::experimental:: + static_set + set{extent_type{}, cuco::empty_key{-1}}; + + auto ref = set.ref(cuco::experimental::insert); + auto const num_windows = ref.window_extent(); + STATIC_REQUIRE(static_cast(num_windows) == gold_extent); + } + SECTION("Dynamic extent is evaluated at run time.") { auto constexpr gold_capacity = 422; // 211 x 2