Skip to content

Commit c6b22c2

Browse files
committed
Add large input test
1 parent 7cfef2f commit c6b22c2

File tree

2 files changed

+79
-1
lines changed

2 files changed

+79
-1
lines changed

tests/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ ConfigureTest(STATIC_MULTISET_TEST
105105
static_multiset/find_test.cu
106106
static_multiset/insert_test.cu
107107
static_multiset/for_each_test.cu
108-
static_multiset/retrieve_test.cu)
108+
static_multiset/retrieve_test.cu
109+
static_multiset/large_input_test.cu)
109110

110111
###################################################################################################
111112
# - static_multimap tests -------------------------------------------------------------------------
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright (c) 2024, NVIDIA CORPORATION.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include <test_utils.hpp>
18+
19+
#include <cuco/static_multiset.cuh>
20+
21+
#include <thrust/device_vector.h>
22+
#include <thrust/functional.h>
23+
#include <thrust/iterator/counting_iterator.h>
24+
#include <thrust/iterator/discard_iterator.h>
25+
#include <thrust/sort.h>
26+
27+
#include <catch2/catch_template_test_macros.hpp>
28+
29+
#include <cstdint>
30+
#include <iterator>
31+
32+
template <typename Set>
33+
void test_unique_sequence(Set& set, typename Set::value_type* res_begin, std::size_t num_keys)
34+
{
35+
using Key = typename Set::key_type;
36+
37+
auto const keys_begin = thrust::counting_iterator<Key>(0);
38+
auto const keys_end = keys_begin + num_keys;
39+
40+
set.insert(keys_begin, keys_end);
41+
REQUIRE(set.size() == num_keys);
42+
43+
SECTION("All inserted keys can be retrieved.")
44+
{
45+
auto const [_, res_end] =
46+
set.retrieve(keys_begin, keys_end, thrust::make_discard_iterator(), res_begin);
47+
REQUIRE(static_cast<std::size_t>(std::distance(res_begin, res_end)) == num_keys);
48+
49+
thrust::sort(res_begin, res_end);
50+
51+
REQUIRE(cuco::test::equal(res_begin, res_end, keys_begin, thrust::equal_to<Key>{}));
52+
}
53+
}
54+
55+
TEMPLATE_TEST_CASE_SIG(
56+
"cuco::static_multiset large input test",
57+
"",
58+
((typename Key, cuco::test::probe_sequence Probe, int CGSize), Key, Probe, CGSize),
59+
(int64_t, cuco::test::probe_sequence::double_hashing, 1),
60+
(int64_t, cuco::test::probe_sequence::double_hashing, 2))
61+
{
62+
constexpr std::size_t num_keys{1'200'000'000};
63+
64+
using extent_type = cuco::extent<std::size_t>;
65+
using probe = cuco::double_hashing<CGSize, cuco::default_hash_function<Key>>;
66+
67+
try {
68+
auto set = cuco::static_multiset{num_keys * 2, cuco::empty_key<Key>{-1}, {}, probe{}};
69+
70+
thrust::device_vector<Key> d_retrieved(num_keys);
71+
test_unique_sequence(set, d_retrieved.data().get(), num_keys);
72+
} catch (cuco::cuda_error&) {
73+
SKIP("Out of memory");
74+
} catch (std::bad_alloc&) {
75+
SKIP("Out of memory");
76+
}
77+
}

0 commit comments

Comments
 (0)