MultiLevelHashSet test, bugfixing
[libcds.git] / tests / test-hdr / set / hdr_intrusive_multilevel_hashset_rcu_shb.cpp
1 //$$CDS-header$$
2
3 #include "set/hdr_intrusive_multilevel_hashset.h"
4 #include <cds/urcu/signal_buffered.h>
5 #include <cds/intrusive/multilevel_hashset_rcu.h>
6 #include "unit/print_multilevel_hashset_stat.h"
7
8 namespace set {
9 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
10     namespace {
11         typedef cds::urcu::gc<cds::urcu::signal_buffered<>> rcu_type;
12     } // namespace
13 #endif
14
15     void IntrusiveMultiLevelHashSetHdrTest::rcu_shb_nohash()
16     {
17 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
18         typedef size_t key_type;
19
20         struct traits : public ci::multilevel_hashset::traits
21         {
22             typedef get_key<key_type> hash_accessor;
23             typedef item_disposer disposer;
24         };
25         typedef ci::MultiLevelHashSet< rcu_type, Item<key_type>, traits > set_type;
26         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!");
27         test_rcu<set_type, nohash<key_type>>(4, 2);
28
29         typedef ci::MultiLevelHashSet<
30             rcu_type,
31             Item<key_type>,
32             typename ci::multilevel_hashset::make_traits<
33                 ci::multilevel_hashset::hash_accessor< get_key<key_type>>
34                 , ci::opt::disposer< item_disposer >
35             >::type
36         > set_type2;
37         test_rcu<set_type2, nohash<key_type>>(4, 2);
38 #endif
39     }
40
41     void IntrusiveMultiLevelHashSetHdrTest::rcu_shb_stdhash()
42     {
43 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
44         typedef size_t hash_type;
45
46         struct traits: public ci::multilevel_hashset::traits
47         {
48             typedef get_hash<hash_type> hash_accessor;
49             typedef item_disposer disposer;
50         };
51         typedef ci::MultiLevelHashSet< rcu_type, Item<hash_type>, traits > set_type;
52         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
53         test_rcu<set_type, std::hash<hash_type>>(4, 2);
54
55         typedef ci::MultiLevelHashSet<
56             rcu_type,
57             Item<hash_type>,
58             typename ci::multilevel_hashset::make_traits<
59                 ci::multilevel_hashset::hash_accessor< get_hash<hash_type>>
60                 , ci::opt::disposer< item_disposer >
61             >::type
62         > set_type2;
63         test_rcu<set_type2, std::hash<hash_type>>(4, 2);
64 #endif
65     }
66
67     void IntrusiveMultiLevelHashSetHdrTest::rcu_shb_hash128()
68     {
69 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
70         typedef hash128 hash_type;
71
72         struct traits: public ci::multilevel_hashset::traits
73         {
74             typedef get_hash<hash_type> hash_accessor;
75             typedef item_disposer disposer;
76             typedef hash128::less less;
77         };
78         typedef ci::MultiLevelHashSet< rcu_type, Item<hash_type>, traits > set_type;
79         static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash128!!!" );
80         test_rcu<set_type, hash128::make>(4, 2);
81
82         typedef ci::MultiLevelHashSet<
83             rcu_type,
84             Item<hash_type>,
85             typename ci::multilevel_hashset::make_traits<
86                 ci::multilevel_hashset::hash_accessor< get_hash<hash_type>>
87                 , ci::opt::disposer< item_disposer >
88                 , ci::opt::less< hash_type::less >
89             >::type
90         > set_type2;
91         test_rcu<set_type2, hash128::make>(4, 2);
92 #endif
93     }
94
95     void IntrusiveMultiLevelHashSetHdrTest::rcu_shb_nohash_stat()
96     {
97 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
98         typedef size_t key_type;
99
100         struct traits : public ci::multilevel_hashset::traits
101         {
102             typedef get_key<key_type> hash_accessor;
103             typedef item_disposer disposer;
104             typedef ci::multilevel_hashset::stat<> stat;
105         };
106         typedef ci::MultiLevelHashSet< rcu_type, Item<key_type>, traits > set_type;
107         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!");
108         test_rcu<set_type, nohash<key_type>>(4, 2);
109
110         typedef ci::MultiLevelHashSet<
111             rcu_type,
112             Item<key_type>,
113             typename ci::multilevel_hashset::make_traits<
114             ci::multilevel_hashset::hash_accessor< get_key<key_type>>
115             , ci::opt::disposer< item_disposer >
116             , co::stat< ci::multilevel_hashset::stat<>>
117             >::type
118         > set_type2;
119         test_rcu<set_type2, nohash<key_type>>(4, 2);
120 #endif
121     }
122
123     void IntrusiveMultiLevelHashSetHdrTest::rcu_shb_stdhash_stat()
124     {
125 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
126         typedef size_t hash_type;
127
128         struct traits: public ci::multilevel_hashset::traits
129         {
130             typedef get_hash<hash_type> hash_accessor;
131             typedef item_disposer disposer;
132             typedef ci::multilevel_hashset::stat<> stat;
133         };
134         typedef ci::MultiLevelHashSet< rcu_type, Item<hash_type>, traits > set_type;
135         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
136         test_rcu<set_type, std::hash<hash_type>>(4, 2);
137
138         typedef ci::MultiLevelHashSet<
139             rcu_type,
140             Item<hash_type>,
141             typename ci::multilevel_hashset::make_traits<
142                 ci::multilevel_hashset::hash_accessor< get_hash<hash_type>>
143                 , ci::opt::disposer< item_disposer >
144                 ,co::stat< ci::multilevel_hashset::stat<>>
145             >::type
146         > set_type2;
147         test_rcu<set_type2, std::hash<hash_type>>(4, 2);
148 #endif
149     }
150
151     void IntrusiveMultiLevelHashSetHdrTest::rcu_shb_hash128_stat()
152     {
153 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
154         typedef hash128 hash_type;
155
156         struct traits: public ci::multilevel_hashset::traits
157         {
158             typedef get_hash<hash_type> hash_accessor;
159             typedef item_disposer disposer;
160             typedef hash128::cmp  compare;
161             typedef ci::multilevel_hashset::stat<> stat;
162         };
163         typedef ci::MultiLevelHashSet< rcu_type, Item<hash_type>, traits > set_type;
164         static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
165         test_rcu<set_type, hash_type::make>(4, 2);
166
167         typedef ci::MultiLevelHashSet<
168             rcu_type,
169             Item<hash_type>,
170             typename ci::multilevel_hashset::make_traits<
171                 ci::multilevel_hashset::hash_accessor< get_hash<hash_type>>
172                 , ci::opt::disposer< item_disposer >
173                 ,co::stat< ci::multilevel_hashset::stat<>>
174                 ,co::compare< hash128::cmp >
175             >::type
176         > set_type2;
177         test_rcu<set_type2, hash_type::make>(4, 2);
178 #endif
179     }
180
181     void IntrusiveMultiLevelHashSetHdrTest::rcu_shb_nohash_5_3()
182     {
183 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
184         typedef size_t key_type;
185
186         struct traits : public ci::multilevel_hashset::traits
187         {
188             typedef get_key<key_type> hash_accessor;
189             typedef item_disposer disposer;
190         };
191         typedef ci::MultiLevelHashSet< 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);
194
195         typedef ci::MultiLevelHashSet<
196             rcu_type,
197             Item<key_type>,
198             typename ci::multilevel_hashset::make_traits<
199             ci::multilevel_hashset::hash_accessor< get_key<key_type>>
200             , ci::opt::disposer< item_disposer >
201             >::type
202         > set_type2;
203         test_rcu<set_type2, nohash<key_type>>(5, 3);
204 #endif
205     }
206
207     void IntrusiveMultiLevelHashSetHdrTest::rcu_shb_stdhash_5_3()
208     {
209 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
210         typedef size_t hash_type;
211
212         struct traits: public ci::multilevel_hashset::traits
213         {
214             typedef get_hash<hash_type> hash_accessor;
215             typedef item_disposer disposer;
216         };
217         typedef ci::MultiLevelHashSet< rcu_type, Item<hash_type>, traits > set_type;
218         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
219         test_rcu<set_type, std::hash<hash_type>>(5, 3);
220
221         typedef ci::MultiLevelHashSet<
222             rcu_type,
223             Item<hash_type>,
224             typename ci::multilevel_hashset::make_traits<
225                 ci::multilevel_hashset::hash_accessor< get_hash<hash_type>>
226                 , ci::opt::disposer< item_disposer >
227             >::type
228         > set_type2;
229         test_rcu<set_type2, std::hash<hash_type>>(5, 3);
230 #endif
231     }
232
233     void IntrusiveMultiLevelHashSetHdrTest::rcu_shb_hash128_4_3()
234     {
235 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
236         typedef hash128 hash_type;
237
238         struct traits: public ci::multilevel_hashset::traits
239         {
240             typedef get_hash<hash_type> hash_accessor;
241             typedef item_disposer disposer;
242             typedef co::v::sequential_consistent memory_model;
243         };
244         typedef ci::MultiLevelHashSet< rcu_type, Item<hash_type>, traits > set_type;
245         static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
246         test_rcu<set_type, hash128::make >(4, 3);
247
248         typedef ci::MultiLevelHashSet<
249             rcu_type,
250             Item<hash_type>,
251             typename ci::multilevel_hashset::make_traits<
252                 ci::multilevel_hashset::hash_accessor< get_hash<hash_type>>
253                 , ci::opt::disposer< item_disposer >
254                 ,co::memory_model< co::v::sequential_consistent >
255             >::type
256         > set_type2;
257         test_rcu<set_type2, hash128::make >(4, 3);
258 #endif
259     }
260
261     void IntrusiveMultiLevelHashSetHdrTest::rcu_shb_nohash_5_3_stat()
262     {
263 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
264         typedef size_t key_type;
265
266         struct traits: public ci::multilevel_hashset::traits
267         {
268             typedef get_key<key_type> hash_accessor;
269             typedef item_disposer disposer;
270             typedef ci::multilevel_hashset::stat<> stat;
271         };
272         typedef ci::MultiLevelHashSet< rcu_type, Item<key_type>, traits > set_type;
273         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
274         test_rcu<set_type, nohash<key_type>>(5, 3);
275
276         typedef ci::MultiLevelHashSet<
277             rcu_type,
278             Item<key_type>,
279             typename ci::multilevel_hashset::make_traits<
280                 ci::multilevel_hashset::hash_accessor< get_key<key_type>>
281                 , ci::opt::disposer< item_disposer >
282                 ,co::stat< ci::multilevel_hashset::stat<>>
283             >::type
284         > set_type2;
285         test_rcu<set_type2, nohash<key_type>>(5, 3);
286 #endif
287     }
288
289     void IntrusiveMultiLevelHashSetHdrTest::rcu_shb_stdhash_5_3_stat()
290     {
291 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
292         typedef size_t hash_type;
293
294         struct traits: public ci::multilevel_hashset::traits
295         {
296             typedef get_hash<hash_type> hash_accessor;
297             typedef item_disposer disposer;
298             typedef ci::multilevel_hashset::stat<> stat;
299         };
300         typedef ci::MultiLevelHashSet< rcu_type, Item<hash_type>, traits > set_type;
301         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
302         test_rcu<set_type, std::hash<hash_type>>(5, 3);
303
304         typedef ci::MultiLevelHashSet<
305             rcu_type,
306             Item<hash_type>,
307             typename ci::multilevel_hashset::make_traits<
308                 ci::multilevel_hashset::hash_accessor< get_hash<hash_type>>
309                 , ci::opt::disposer< item_disposer >
310                 ,co::stat< ci::multilevel_hashset::stat<>>
311             >::type
312         > set_type2;
313         test_rcu<set_type2, std::hash<hash_type>>(5, 3);
314 #endif
315     }
316
317     void IntrusiveMultiLevelHashSetHdrTest::rcu_shb_hash128_4_3_stat()
318     {
319 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
320         typedef hash128 hash_type;
321
322         struct traits: public ci::multilevel_hashset::traits
323         {
324             typedef get_hash<hash_type> hash_accessor;
325             typedef item_disposer disposer;
326             typedef ci::multilevel_hashset::stat<> stat;
327             typedef hash128::less less;
328             typedef hash128::cmp compare;
329         };
330         typedef ci::MultiLevelHashSet< rcu_type, Item<hash_type>, traits > set_type;
331         static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
332         test_rcu<set_type, hash_type::make>(4, 3);
333
334         typedef ci::MultiLevelHashSet<
335             rcu_type,
336             Item<hash_type>,
337             typename ci::multilevel_hashset::make_traits<
338                 ci::multilevel_hashset::hash_accessor< get_hash<hash_type>>
339                 , ci::opt::disposer< item_disposer >
340                 , co::stat< ci::multilevel_hashset::stat<>>
341                 , co::less< hash_type::less >
342                 , co::compare< hash128::cmp >
343             >::type
344         > set_type2;
345         test_rcu<set_type2, hash_type::make>(4, 3);
346 #endif
347     }
348
349 } // namespace set