Zero  0.1.0
skewer.h
Go to the documentation of this file.
1 /* -*- mode:C++; c-basic-offset:4 -*-
2  Shore-kits -- Benchmark implementations for Shore-MT
3 
4  Copyright (c) 2007-2009
5  Data Intensive Applications and Systems Labaratory (DIAS)
6  Ecole Polytechnique Federale de Lausanne
7 
8  All Rights Reserved.
9 
10  Permission to use, copy, modify and distribute this software and
11  its documentation is hereby granted, provided that both the
12  copyright notice and this permission notice appear in all copies of
13  the software, derivative works or modified versions, and any
14  portions thereof, and that both notices appear in supporting
15  documentation.
16 
17  This code 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. THE AUTHORS
20  DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER
21  RESULTING FROM THE USE OF THIS SOFTWARE.
22 */
23 
31 #ifndef __SKEWER_H
32 #define __SKEWER_H
33 
34 #include <iostream>
35 #include <vector>
36 
37 /* ---------------------------------------------------------------
38  *
39  * @enum: skew_type_t
40  *
41  * @brief: There are different options for handling dynamic skew
42  * SKEW_NONE - means there is no data skew
43  * SKEW_NORMAL - the skew given in the input command will be applied
44  * SKEW_DYNAMIC - the initial area of the skew will be changed in random time durations
45  * SKEW_CHAOTIC - both the initial area and load of the skew will be changed in random time durations
46  *
47  * --------------------------------------------------------------- */
48 
50  SKEW_NONE = 0x0,
51  SKEW_NORMAL = 0x1,
52  SKEW_DYNAMIC = 0x2,
54 };
55 
56 using namespace std;
57 
58 /*********************************************************************
59  *
60  * @class skewer_t
61  *
62  * @brief Class that keeps the skew information for creating dynamic skew
63  * With zipf we can just create a static skew on some area
64  *
65  *********************************************************************/
66 
67 class skewer_t {
68 
69 private:
70 
71  // the % of the total area that the skew will be applied
72  int _area;
73 
74  // the % of the load to apply to _area
75  int _load;
76 
77  // the boundaries of the whole area
78  int _lower;
79 
80  int _upper;
81 
82  // the boundaries of the area that the load will be applied to
83  // this area doesn't have to be continuous
84  // vector<int> _interval_l;
85  // vector<int> _interval_u;
87 
89 
90  // the boundaries of the area that the remaining load will be applied to
91  // this area doesn't have to be continuous
92  // vector<int> _non_interval_l;
93  // vector<int> _non_interval_u;
94 
95  // indicates whether the set intervals was used once
96  bool _is_used;
97 
98  bool _shifting;
99 
100 public:
101 
102  // empty constructor, things should be set later
104  _is_used = false;
105  }
106 
107  // initialization
108  void set(int area, int lower, int upper, int load, bool shifting);
109 
110  // cleans the intervals
111  void clear();
112 
113  // re-decides on intervals
114  void reset(skew_type_t type);
115 
116  // gives input to the input creators
117  int get_input();
118 
119  // to be called on deciding whether to set or reset
120  bool is_used();
121 
122  // shift interval
123  void increment_intervals(int amount = 1);
124 
125  // for debugging
126  void print_intervals();
127 
128 private:
129 
130  void _set_intervals();
131 
132  void _add_interval(int interval_lower, int interval_upper);
133 };
134 
135 #endif // __SKEWER_H
int _interval_l
Definition: skewer.h:86
int _load
Definition: skewer.h:75
int _lower
Definition: skewer.h:78
Definition: skewer.h:50
STL namespace.
Definition: skewer.h:67
skewer_t()
Definition: skewer.h:103
int _interval_u
Definition: skewer.h:88
bool _is_used
Definition: skewer.h:96
int _area
Definition: skewer.h:72
Definition: skewer.h:51
Definition: skewer.h:52
skew_type_t
Definition: skewer.h:49
bool _shifting
Definition: skewer.h:98
Definition: skewer.h:53
int _upper
Definition: skewer.h:80