OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [testsuite/] [ext/] [pb_ds/] [regression/] [hash_map_rand_debug.cc] - Blame information for rev 749

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 742 jeremybenn
// { dg-require-debug-mode "" }
2
// { dg-require-time "" }
3
// This can take long on simulators, timing out the test.
4
// { dg-options "-DITERATIONS=5" { target simulator } }
5
// { dg-timeout-factor 2.0 }
6
 
7
// -*- C++ -*-
8
 
9
// Copyright (C) 2011 Free Software Foundation, Inc.
10
//
11
// This file is part of the GNU ISO C++ Library.  This library is free
12
// software; you can redistribute it and/or modify it under the terms
13
// of the GNU General Public License as published by the Free Software
14
// Foundation; either version 3, or (at your option) any later
15
// version.
16
 
17
// This library is distributed in the hope that it will be useful, but
18
// WITHOUT ANY WARRANTY; without even the implied warranty of
19
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20
// General Public License for more details.
21
 
22
// You should have received a copy of the GNU General Public License
23
// along with this library; see the file COPYING3.  If not see
24
// <http://www.gnu.org/licenses/>.
25
 
26
/**
27
 * @file hash_data_map_rand.cc
28
 * Contains a random-operation test for maps and sets, separated out.
29
 */
30
 
31
#define PB_DS_REGRESSION
32
//#define PB_DS_REGRESSION_TRACE
33
 
34
#include <regression/rand/assoc/rand_regression_test.hpp>
35
#include <regression/common_type.hpp>
36
#include <ext/throw_allocator.h>
37
#include <ext/pb_ds/tag_and_trait.hpp>
38
 
39
#ifndef ITERATIONS
40
# define ITERATIONS 100
41
#endif
42
 
43
#ifndef KEYS
44
# define KEYS 200
45
#endif
46
 
47
// Debug version of the rand regression tests, based on hash_data_map_rand
48
 
49
// 1
50
// Simplify things by unrolling the typelist of the different
51
// container types into individual statements.
52
//
53
// Unroll the typelist represented by priority_queue_types, from
54
// regression/common_type.hpp. This is just a compile-time list of 5
55
// hash tables, with different policies for the type of table
56
// (gp_hash, cc_hash), for the resize policies and probe functions.
57
using namespace __gnu_pbds::test::detail;
58
using namespace __gnu_pbds;
59
typedef __gnu_pbds::test::basic_type                    basic_type;
60
typedef __gnu_cxx::throw_allocator_random<basic_type>   allocator_type;
61
typedef std::equal_to<basic_type>                       equal_type;
62
 
63
 
64
typedef __gnu_pbds::test::direct_mod_range_hashing_t_<allocator_type>
65
                                                        cprobe_type1;
66
 
67
typedef __gnu_pbds::test::direct_mask_range_hashing_t_<allocator_type>
68
                                                        cprobe_type2;
69
 
70
 
71
typedef __gnu_pbds::test::quadratic_probe_fn_t_<basic_type, allocator_type>
72
                                                        probe_type1;
73
 
74
typedef __gnu_pbds::test::linear_probe_fn_t_<basic_type, allocator_type>
75
                                                        probe_type2;
76
 
77
 
78
typedef __gnu_pbds::test::hash_load_check_resize_trigger_t_<allocator_type,
79
                                                            1, 8, 1, 2, false>
80
                                                        trigger_type1;
81
 
82
typedef __gnu_pbds::test::hash_load_check_resize_trigger_t_<allocator_type,
83
                                                            1, 8, 1, 2, true>
84
                                                        trigger_type2;
85
 
86
typedef __gnu_pbds::test::hash_load_check_resize_trigger_t_<allocator_type,
87
                                                            1, 8, 1, 1, false>
88
                                                        trigger_type3;
89
 
90
typedef __gnu_pbds::test::cc_hash_max_collision_check_resize_trigger_t_<allocator_type, 1, 2, false>
91
                                                        trigger_type4;
92
 
93
typedef __gnu_pbds::test::cc_hash_max_collision_check_resize_trigger_t_<allocator_type, 1, 2, true>
94
                                                        trigger_type5;
95
 
96
 
97
typedef hash_standard_resize_policy<__gnu_pbds::test::hash_prime_size_policy_t_, trigger_type1, false, unsigned long>                   resize_type1;
98
 
99
typedef hash_standard_resize_policy<__gnu_pbds::test::hash_exponential_size_policy_t_<allocator_type>, trigger_type2, true, unsigned long>
100
                                                        resize_type2;
101
 
102
typedef hash_standard_resize_policy<__gnu_pbds::test::hash_exponential_size_policy_t_<allocator_type>, trigger_type5, false, unsigned long>
103
                                                        resize_type3;
104
 
105
 
106
 
107
// gp_hash 1
108
typedef gp_hash_table<basic_type, basic_type, __gnu_pbds::test::hash,
109
                      equal_type, cprobe_type1, probe_type1, resize_type1,
110
                      false, allocator_type>
111
                                                        gp_hash_type1;
112
 
113
// gp_hash 2
114
typedef gp_hash_table<basic_type, basic_type, __gnu_pbds::test::hash,
115
                      equal_type, cprobe_type2, probe_type2, resize_type2,
116
                      true, allocator_type>
117
                                                        gp_hash_type2;
118
 
119
 
120
// cc_hash 1
121
typedef cc_hash_table<basic_type, basic_type, __gnu_pbds::test::hash,
122
                      equal_type, cprobe_type2, resize_type3,
123
                      false, allocator_type>
124
                                                        cc_hash_type1;
125
 
126
// cc_hash 2
127
typedef cc_hash_table<basic_type, basic_type, __gnu_pbds::test::hash,
128
                      equal_type, cprobe_type2, resize_type2,
129
                      false, allocator_type>
130
                                                        cc_hash_type2;
131
 
132
// cc_hash 3
133
typedef cc_hash_table<basic_type, basic_type, __gnu_pbds::test::hash,
134
                      equal_type, cprobe_type1, resize_type1,
135
                      true, allocator_type>
136
                                                        cc_hash_type3;
137
 
138
// 2
139
// Specialize container_rand_regression_test for specific container
140
// type and test function.
141
 
142
#ifdef SPECIALIZE
143
// For testing one specific container type.
144
typedef cc_hash_type1                                   test_type;
145
 
146
void debug_break_here() { }
147
 
148
namespace __gnu_pbds {
149
  namespace test {
150
    namespace detail {
151
 
152
      template<>
153
      void
154
      container_rand_regression_test<test_type>::operator()()
155
      {
156
      }
157
    }
158
  }
159
}
160
#endif
161
 
162
int
163
main()
164
{
165
  // Set up the test object.
166
  size_t sd = 1303948889;
167
  rand_reg_test test(sd, ITERATIONS, KEYS, 0.2, .6, .2, .001, .25, true);
168
 
169
  // 1
170
  // Determine the problem container, function that fails.
171
  test(gp_hash_type1());
172
  test(gp_hash_type2());
173
 
174
  test(cc_hash_type1());
175
  test(cc_hash_type2());
176
  test(cc_hash_type3());
177
 
178
#ifdef SPECIALIZE
179
  // 2
180
  // With specified problem container set test_type typedef
181
  // appropriately above. Then, specialize operator()(), also
182
  // above. Finally, run this below.
183
  using namespace std;
184
  test_type obj;
185
  test(obj);
186
#endif
187
 
188
  return 0;
189
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.