MultiLevelHashSet test, bugfixing
[libcds.git] / tests / test-hdr / set / hdr_multilevel_hashset_rcu_gpi.cpp
1 //$$CDS-header$$
2
3 #include "set/hdr_multilevel_hashset.h"
4 #include <cds/urcu/general_instant.h>
5 #include <cds/container/multilevel_hashset_rcu.h>
6 #include "unit/print_multilevel_hashset_stat.h"
7
8 namespace set {
9     namespace {
10         typedef cds::urcu::gc<cds::urcu::general_instant<>> rcu_type;
11     } // namespace
12
13     void MultiLevelHashSetHdrTest::rcu_gpi_nohash()
14     {
15         typedef size_t key_type;
16
17         struct traits : public cc::multilevel_hashset::traits
18         {
19             typedef get_key<key_type> hash_accessor;
20         };
21         typedef cc::MultiLevelHashSet< rcu_type, Item<key_type>, traits > set_type;
22         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!");
23         test_rcu<set_type, nohash<key_type>>(4, 2);
24
25         typedef cc::MultiLevelHashSet<
26             rcu_type,
27             Item<key_type>,
28             typename cc::multilevel_hashset::make_traits<
29             cc::multilevel_hashset::hash_accessor< get_key<key_type>>
30             >::type
31         > set_type2;
32         test_rcu<set_type2, nohash<key_type>>(4, 2);
33     }
34
35     void MultiLevelHashSetHdrTest::rcu_gpi_stdhash()
36     {
37         typedef size_t hash_type;
38
39         struct traits: public cc::multilevel_hashset::traits
40         {
41             typedef get_hash<hash_type> hash_accessor;
42         };
43         typedef cc::MultiLevelHashSet< rcu_type, Item<hash_type>, traits > set_type;
44         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
45         test_rcu<set_type, std::hash<hash_type>>(4, 2);
46
47         typedef cc::MultiLevelHashSet<
48             rcu_type,
49             Item<hash_type>,
50             typename cc::multilevel_hashset::make_traits<
51                 cc::multilevel_hashset::hash_accessor< get_hash<hash_type>>
52             >::type
53         > set_type2;
54         test_rcu<set_type2, std::hash<hash_type>>(4, 2);
55     }
56
57     void MultiLevelHashSetHdrTest::rcu_gpi_hash128()
58     {
59         typedef hash128 hash_type;
60
61         struct traits: public cc::multilevel_hashset::traits
62         {
63             typedef get_hash<hash_type> hash_accessor;
64             typedef hash128::less less;
65         };
66         typedef cc::MultiLevelHashSet< rcu_type, Item<hash_type>, traits > set_type;
67         static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash128!!!" );
68         test_rcu<set_type, hash128::make>(4, 2);
69
70         typedef cc::MultiLevelHashSet<
71             rcu_type,
72             Item<hash_type>,
73             typename cc::multilevel_hashset::make_traits<
74                 cc::multilevel_hashset::hash_accessor< get_hash<hash_type>>
75                 , co::less< hash_type::less >
76             >::type
77         > set_type2;
78         test_rcu<set_type2, hash128::make>(4, 2);
79     }
80
81     void MultiLevelHashSetHdrTest::rcu_gpi_nohash_stat()
82     {
83         typedef size_t key_type;
84
85         struct traits : public cc::multilevel_hashset::traits
86         {
87             typedef get_key<key_type> hash_accessor;
88             typedef cc::multilevel_hashset::stat<> stat;
89         };
90         typedef cc::MultiLevelHashSet< rcu_type, Item<key_type>, traits > set_type;
91         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!");
92         test_rcu<set_type, nohash<key_type>>(4, 2);
93
94         typedef cc::MultiLevelHashSet<
95             rcu_type,
96             Item<key_type>,
97             typename cc::multilevel_hashset::make_traits<
98             cc::multilevel_hashset::hash_accessor< get_key<key_type>>
99             , co::stat< cc::multilevel_hashset::stat<>>
100             >::type
101         > set_type2;
102         test_rcu<set_type2, nohash<key_type>>(4, 2);
103     }
104
105     void MultiLevelHashSetHdrTest::rcu_gpi_stdhash_stat()
106     {
107         typedef size_t hash_type;
108
109         struct traits: public cc::multilevel_hashset::traits
110         {
111             typedef get_hash<hash_type> hash_accessor;
112             typedef cc::multilevel_hashset::stat<> stat;
113         };
114         typedef cc::MultiLevelHashSet< rcu_type, Item<hash_type>, traits > set_type;
115         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
116         test_rcu<set_type, std::hash<hash_type>>(4, 2);
117
118         typedef cc::MultiLevelHashSet<
119             rcu_type,
120             Item<hash_type>,
121             typename cc::multilevel_hashset::make_traits<
122                 cc::multilevel_hashset::hash_accessor< get_hash<hash_type>>
123                 ,co::stat< cc::multilevel_hashset::stat<>>
124             >::type
125         > set_type2;
126         test_rcu<set_type2, std::hash<hash_type>>(4, 2);
127     }
128
129     void MultiLevelHashSetHdrTest::rcu_gpi_hash128_stat()
130     {
131         typedef hash128 hash_type;
132
133         struct traits: public cc::multilevel_hashset::traits
134         {
135             typedef get_hash<hash_type> hash_accessor;
136             typedef hash128::cmp  compare;
137             typedef cc::multilevel_hashset::stat<> stat;
138         };
139         typedef cc::MultiLevelHashSet< rcu_type, Item<hash_type>, traits > set_type;
140         static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
141         test_rcu<set_type, hash_type::make>(4, 2);
142
143         typedef cc::MultiLevelHashSet<
144             rcu_type,
145             Item<hash_type>,
146             typename cc::multilevel_hashset::make_traits<
147                 cc::multilevel_hashset::hash_accessor< get_hash<hash_type>>
148                 ,co::stat< cc::multilevel_hashset::stat<>>
149                 ,co::compare< hash128::cmp >
150             >::type
151         > set_type2;
152         test_rcu<set_type2, hash_type::make>(4, 2);
153     }
154
155     void MultiLevelHashSetHdrTest::rcu_gpi_nohash_5_3()
156     {
157         typedef size_t key_type;
158
159         struct traits: public cc::multilevel_hashset::traits
160         {
161             typedef get_key<key_type> hash_accessor;
162         };
163         typedef cc::MultiLevelHashSet< rcu_type, Item<key_type>, traits > set_type;
164         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
165         test_rcu<set_type, nohash<key_type>>(5, 3);
166
167         typedef cc::MultiLevelHashSet<
168             rcu_type,
169             Item<key_type>,
170             typename cc::multilevel_hashset::make_traits<
171                 cc::multilevel_hashset::hash_accessor< get_key<key_type>>
172             >::type
173         > set_type2;
174         test_rcu<set_type2, nohash<key_type>>(5, 3);
175     }
176
177     void MultiLevelHashSetHdrTest::rcu_gpi_stdhash_5_3()
178     {
179         typedef size_t hash_type;
180
181         struct traits: public cc::multilevel_hashset::traits
182         {
183             typedef get_hash<hash_type> hash_accessor;
184         };
185         typedef cc::MultiLevelHashSet< rcu_type, Item<hash_type>, traits > set_type;
186         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
187         test_rcu<set_type, std::hash<hash_type>>(5, 3);
188
189         typedef cc::MultiLevelHashSet<
190             rcu_type,
191             Item<hash_type>,
192             typename cc::multilevel_hashset::make_traits<
193                 cc::multilevel_hashset::hash_accessor< get_hash<hash_type>>
194             >::type
195         > set_type2;
196         test_rcu<set_type2, std::hash<hash_type>>(5, 3);
197     }
198
199     void MultiLevelHashSetHdrTest::rcu_gpi_hash128_4_3()
200     {
201         typedef hash128 hash_type;
202
203         struct traits: public cc::multilevel_hashset::traits
204         {
205             typedef get_hash<hash_type> hash_accessor;
206             typedef co::v::sequential_consistent memory_model;
207         };
208         typedef cc::MultiLevelHashSet< rcu_type, Item<hash_type>, traits > set_type;
209         static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
210         test_rcu<set_type, hash128::make >(4, 3);
211
212         typedef cc::MultiLevelHashSet<
213             rcu_type,
214             Item<hash_type>,
215             typename cc::multilevel_hashset::make_traits<
216                 cc::multilevel_hashset::hash_accessor< get_hash<hash_type>>
217                 ,co::memory_model< co::v::sequential_consistent >
218             >::type
219         > set_type2;
220         test_rcu<set_type2, hash128::make >(4, 3);
221     }
222
223     void MultiLevelHashSetHdrTest::rcu_gpi_nohash_5_3_stat()
224     {
225         typedef size_t key_type;
226
227         struct traits: public cc::multilevel_hashset::traits
228         {
229             typedef get_key<key_type> hash_accessor;
230             typedef cc::multilevel_hashset::stat<> stat;
231         };
232         typedef cc::MultiLevelHashSet< rcu_type, Item<key_type>, traits > set_type;
233         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
234         test_rcu<set_type, nohash<key_type>>(5, 3);
235
236         typedef cc::MultiLevelHashSet<
237             rcu_type,
238             Item<key_type>,
239             typename cc::multilevel_hashset::make_traits<
240                 cc::multilevel_hashset::hash_accessor< get_key<key_type>>
241                 ,co::stat< cc::multilevel_hashset::stat<>>
242             >::type
243         > set_type2;
244         test_rcu<set_type2, nohash<key_type>>(5, 3);
245     }
246
247     void MultiLevelHashSetHdrTest::rcu_gpi_stdhash_5_3_stat()
248     {
249         typedef size_t hash_type;
250
251         struct traits: public cc::multilevel_hashset::traits
252         {
253             typedef get_hash<hash_type> hash_accessor;
254             typedef cc::multilevel_hashset::stat<> stat;
255         };
256         typedef cc::MultiLevelHashSet< rcu_type, Item<hash_type>, traits > set_type;
257         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
258         test_rcu<set_type, std::hash<hash_type>>(5, 3);
259
260         typedef cc::MultiLevelHashSet<
261             rcu_type,
262             Item<hash_type>,
263             typename cc::multilevel_hashset::make_traits<
264                 cc::multilevel_hashset::hash_accessor< get_hash<hash_type>>
265                 ,co::stat< cc::multilevel_hashset::stat<>>
266             >::type
267         > set_type2;
268         test_rcu<set_type2, std::hash<hash_type>>(5, 3);
269     }
270
271     void MultiLevelHashSetHdrTest::rcu_gpi_hash128_4_3_stat()
272     {
273         typedef hash128 hash_type;
274
275         struct traits: public cc::multilevel_hashset::traits
276         {
277             typedef get_hash<hash_type> hash_accessor;
278             typedef cc::multilevel_hashset::stat<> stat;
279             typedef hash128::less less;
280             typedef hash128::cmp compare;
281         };
282         typedef cc::MultiLevelHashSet< rcu_type, Item<hash_type>, traits > set_type;
283         static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
284         test_rcu<set_type, hash_type::make>(4, 3);
285
286         typedef cc::MultiLevelHashSet<
287             rcu_type,
288             Item<hash_type>,
289             typename cc::multilevel_hashset::make_traits<
290                 cc::multilevel_hashset::hash_accessor< get_hash<hash_type>>
291                 , co::stat< cc::multilevel_hashset::stat<>>
292                 , co::less< hash_type::less >
293                 , co::compare< hash128::cmp >
294             >::type
295         > set_type2;
296         test_rcu<set_type2, hash_type::make>(4, 3);
297     }
298
299
300 } // namespace set