2 This file is a part of libcds - Concurrent Data Structures library
4 (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
6 Source code repo: http://github.com/khizmax/libcds/
7 Download: http://sourceforge.net/projects/libcds/files/
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are met:
12 * Redistributions of source code must retain the above copyright notice, this
13 list of conditions and the following disclaimer.
15 * Redistributions in binary form must reproduce the above copyright notice,
16 this list of conditions and the following disclaimer in the documentation
17 and/or other materials provided with the distribution.
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "set/hdr_feldman_hashset.h"
32 #include <cds/urcu/general_threaded.h>
33 #include <cds/container/feldman_hashset_rcu.h>
34 #include "unit/print_feldman_hashset_stat.h"
38 typedef cds::urcu::gc<cds::urcu::general_threaded<>> rcu_type;
41 void FeldmanHashSetHdrTest::rcu_gpt_nohash()
43 typedef size_t key_type;
45 struct traits : public cc::feldman_hashset::traits
47 typedef get_key<key_type> hash_accessor;
49 typedef cc::FeldmanHashSet< rcu_type, Item<key_type>, traits > set_type;
50 static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!");
51 test_rcu<set_type, nohash<key_type>>(4, 2);
53 typedef cc::FeldmanHashSet<
56 typename cc::feldman_hashset::make_traits<
57 cc::feldman_hashset::hash_accessor< get_key<key_type>>
60 test_rcu<set_type2, nohash<key_type>>(4, 2);
63 void FeldmanHashSetHdrTest::rcu_gpt_stdhash()
65 typedef size_t hash_type;
67 struct traits: public cc::feldman_hashset::traits
69 typedef get_hash<hash_type> hash_accessor;
71 typedef cc::FeldmanHashSet< rcu_type, Item<hash_type>, traits > set_type;
72 static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
73 test_rcu<set_type, std::hash<hash_type>>(4, 2);
75 typedef cc::FeldmanHashSet<
78 typename cc::feldman_hashset::make_traits<
79 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
82 test_rcu<set_type2, std::hash<hash_type>>(4, 2);
85 void FeldmanHashSetHdrTest::rcu_gpt_hash128()
87 typedef hash128 hash_type;
89 struct traits: public cc::feldman_hashset::traits
91 typedef get_hash<hash_type> hash_accessor;
92 typedef hash128::less less;
94 typedef cc::FeldmanHashSet< rcu_type, Item<hash_type>, traits > set_type;
95 static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash128!!!" );
96 test_rcu<set_type, hash128::make>(4, 2);
98 typedef cc::FeldmanHashSet<
101 typename cc::feldman_hashset::make_traits<
102 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
103 , co::less< hash_type::less >
106 test_rcu<set_type2, hash128::make>(4, 2);
109 void FeldmanHashSetHdrTest::rcu_gpt_nohash_stat()
111 typedef size_t key_type;
113 struct traits : public cc::feldman_hashset::traits
115 typedef get_key<key_type> hash_accessor;
116 typedef cc::feldman_hashset::stat<> stat;
118 typedef cc::FeldmanHashSet< rcu_type, Item<key_type>, traits > set_type;
119 static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!");
120 test_rcu<set_type, nohash<key_type>>(4, 2);
122 typedef cc::FeldmanHashSet<
125 typename cc::feldman_hashset::make_traits<
126 cc::feldman_hashset::hash_accessor< get_key<key_type>>
127 , co::stat< cc::feldman_hashset::stat<>>
130 test_rcu<set_type2, nohash<key_type>>(4, 2);
133 void FeldmanHashSetHdrTest::rcu_gpt_stdhash_stat()
135 typedef size_t hash_type;
137 struct traits: public cc::feldman_hashset::traits
139 typedef get_hash<hash_type> hash_accessor;
140 typedef cc::feldman_hashset::stat<> stat;
142 typedef cc::FeldmanHashSet< rcu_type, Item<hash_type>, traits > set_type;
143 static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
144 test_rcu<set_type, std::hash<hash_type>>(4, 2);
146 typedef cc::FeldmanHashSet<
149 typename cc::feldman_hashset::make_traits<
150 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
151 ,co::stat< cc::feldman_hashset::stat<>>
154 test_rcu<set_type2, std::hash<hash_type>>(4, 2);
157 void FeldmanHashSetHdrTest::rcu_gpt_hash128_stat()
159 typedef hash128 hash_type;
161 struct traits: public cc::feldman_hashset::traits
163 typedef get_hash<hash_type> hash_accessor;
164 typedef hash128::cmp compare;
165 typedef cc::feldman_hashset::stat<> stat;
167 typedef cc::FeldmanHashSet< rcu_type, Item<hash_type>, traits > set_type;
168 static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
169 test_rcu<set_type, hash_type::make>(4, 2);
171 typedef cc::FeldmanHashSet<
174 typename cc::feldman_hashset::make_traits<
175 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
176 ,co::stat< cc::feldman_hashset::stat<>>
177 ,co::compare< hash128::cmp >
180 test_rcu<set_type2, hash_type::make>(4, 2);
183 void FeldmanHashSetHdrTest::rcu_gpt_nohash_5_3()
185 typedef size_t key_type;
187 struct traits: public cc::feldman_hashset::traits
189 typedef get_key<key_type> hash_accessor;
191 typedef cc::FeldmanHashSet< rcu_type, Item<key_type>, traits > set_type;
192 static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
193 test_rcu<set_type, nohash<key_type>>(5, 3);
195 typedef cc::FeldmanHashSet<
198 typename cc::feldman_hashset::make_traits<
199 cc::feldman_hashset::hash_accessor< get_key<key_type>>
202 test_rcu<set_type2, nohash<key_type>>(5, 3);
205 void FeldmanHashSetHdrTest::rcu_gpt_stdhash_5_3()
207 typedef size_t hash_type;
209 struct traits: public cc::feldman_hashset::traits
211 typedef get_hash<hash_type> hash_accessor;
213 typedef cc::FeldmanHashSet< rcu_type, Item<hash_type>, traits > set_type;
214 static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
215 test_rcu<set_type, std::hash<hash_type>>(5, 3);
217 typedef cc::FeldmanHashSet<
220 typename cc::feldman_hashset::make_traits<
221 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
224 test_rcu<set_type2, std::hash<hash_type>>(5, 3);
227 void FeldmanHashSetHdrTest::rcu_gpt_hash128_4_3()
229 typedef hash128 hash_type;
231 struct traits: public cc::feldman_hashset::traits
233 typedef get_hash<hash_type> hash_accessor;
234 typedef co::v::sequential_consistent memory_model;
236 typedef cc::FeldmanHashSet< rcu_type, Item<hash_type>, traits > set_type;
237 static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
238 test_rcu<set_type, hash128::make >(4, 3);
240 typedef cc::FeldmanHashSet<
243 typename cc::feldman_hashset::make_traits<
244 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
245 ,co::memory_model< co::v::sequential_consistent >
248 test_rcu<set_type2, hash128::make >(4, 3);
251 void FeldmanHashSetHdrTest::rcu_gpt_nohash_5_3_stat()
253 typedef size_t key_type;
255 struct traits: public cc::feldman_hashset::traits
257 typedef get_key<key_type> hash_accessor;
258 typedef cc::feldman_hashset::stat<> stat;
260 typedef cc::FeldmanHashSet< rcu_type, Item<key_type>, traits > set_type;
261 static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
262 test_rcu<set_type, nohash<key_type>>(5, 3);
264 typedef cc::FeldmanHashSet<
267 typename cc::feldman_hashset::make_traits<
268 cc::feldman_hashset::hash_accessor< get_key<key_type>>
269 ,co::stat< cc::feldman_hashset::stat<>>
272 test_rcu<set_type2, nohash<key_type>>(5, 3);
275 void FeldmanHashSetHdrTest::rcu_gpt_stdhash_5_3_stat()
277 typedef size_t hash_type;
279 struct traits: public cc::feldman_hashset::traits
281 typedef get_hash<hash_type> hash_accessor;
282 typedef cc::feldman_hashset::stat<> stat;
284 typedef cc::FeldmanHashSet< rcu_type, Item<hash_type>, traits > set_type;
285 static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
286 test_rcu<set_type, std::hash<hash_type>>(5, 3);
288 typedef cc::FeldmanHashSet<
291 typename cc::feldman_hashset::make_traits<
292 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
293 ,co::stat< cc::feldman_hashset::stat<>>
296 test_rcu<set_type2, std::hash<hash_type>>(5, 3);
299 void FeldmanHashSetHdrTest::rcu_gpt_hash128_4_3_stat()
301 typedef hash128 hash_type;
303 struct traits: public cc::feldman_hashset::traits
305 typedef get_hash<hash_type> hash_accessor;
306 typedef cc::feldman_hashset::stat<> stat;
307 typedef hash128::less less;
308 typedef hash128::cmp compare;
310 typedef cc::FeldmanHashSet< rcu_type, Item<hash_type>, traits > set_type;
311 static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
312 test_rcu<set_type, hash_type::make>(4, 3);
314 typedef cc::FeldmanHashSet<
317 typename cc::feldman_hashset::make_traits<
318 cc::feldman_hashset::hash_accessor< get_hash<hash_type>>
319 , co::stat< cc::feldman_hashset::stat<>>
320 , co::less< hash_type::less >
321 , co::compare< hash128::cmp >
324 test_rcu<set_type2, hash_type::make>(4, 3);