diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8969a9b42..1b28746ea 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -105,7 +105,8 @@ ConfigureTest(STATIC_MULTISET_TEST static_multiset/find_test.cu static_multiset/insert_test.cu static_multiset/for_each_test.cu - static_multiset/retrieve_test.cu) + static_multiset/retrieve_test.cu + static_multiset/large_input_test.cu) ################################################################################################### # - static_multimap tests ------------------------------------------------------------------------- diff --git a/tests/static_multiset/large_input_test.cu b/tests/static_multiset/large_input_test.cu new file mode 100644 index 000000000..015260676 --- /dev/null +++ b/tests/static_multiset/large_input_test.cu @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2024, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include + +template +void test_unique_sequence(Set& set, typename Set::value_type* res_begin, std::size_t num_keys) +{ + using Key = typename Set::key_type; + + auto const keys_begin = thrust::counting_iterator(0); + auto const keys_end = keys_begin + num_keys; + + set.insert(keys_begin, keys_end); + REQUIRE(set.size() == num_keys); + + SECTION("All inserted keys can be retrieved.") + { + auto const [_, res_end] = + set.retrieve(keys_begin, keys_end, thrust::make_discard_iterator(), res_begin); + REQUIRE(static_cast(std::distance(res_begin, res_end)) == num_keys); + + thrust::sort(res_begin, res_end); + + REQUIRE(cuco::test::equal(res_begin, res_end, keys_begin, thrust::equal_to{})); + } +} + +TEMPLATE_TEST_CASE_SIG( + "cuco::static_multiset large input test", + "", + ((typename Key, cuco::test::probe_sequence Probe, int CGSize), Key, Probe, CGSize), + (int64_t, cuco::test::probe_sequence::double_hashing, 1), + (int64_t, cuco::test::probe_sequence::double_hashing, 2)) +{ + constexpr std::size_t num_keys{1'200'000'000}; + + using extent_type = cuco::extent; + using probe = cuco::double_hashing>; + + try { + auto set = cuco::static_multiset{num_keys * 2, cuco::empty_key{-1}, {}, probe{}}; + + thrust::device_vector d_retrieved(num_keys); + test_unique_sequence(set, d_retrieved.data().get(), num_keys); + } catch (cuco::cuda_error&) { + SKIP("Out of memory"); + } catch (std::bad_alloc&) { + SKIP("Out of memory"); + } +}