-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmicro_driver.cu
241 lines (227 loc) · 7.38 KB
/
micro_driver.cu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
//
// Created by Shujian Qian on 2024-04-20.
//
//
// Created by Shujian Qian on 2023-08-08.
//
#include <iostream>
#include <memory>
#include <getopt.h>
#include "gpu_execution_planner.h"
#include "gpu_allocator.h"
#include <benchmarks/benchmark.h>
#include "benchmarks/ycsb.h"
#include "util_log.h"
#include "txn_bridge.h"
#include "benchmarks/micro.h"
#include "gacco/benchmarks/ycsb.h"
static constexpr struct option long_options[] = {{"benchmark", required_argument, nullptr, 'b'},
{"database", required_argument, nullptr, 'd'}, {"num_warehouses", required_argument, nullptr, 'w'},
{"skew_factor", required_argument, nullptr, 'a'}, {"fullread", required_argument, nullptr, 'r'},
{"cpu_exec_num_threads", required_argument, nullptr, 'c'}, {"num_epochs", required_argument, nullptr, 'e'},
{"num_txns", required_argument, nullptr, 's'}, {"split_fields", required_argument, nullptr, 'f'},
{"commutative_ops", required_argument, nullptr, 'm'}, {"num_records", required_argument, nullptr, 'n'},
{"exec_device", required_argument, nullptr, 'x'},
{"abort_percentage", required_argument, nullptr, 'p'},
{nullptr, 0, nullptr, 0}};
static char optstring[] = "b:d:w:a:r:c:e:s:f:m:n:x:p:";
int main(int argc, char **argv)
{
epic::ycsb::YcsbConfig ycsb_config;
epic::micro::MicroConfig micro_config;
int retval = 0;
char *end_char = nullptr;
std::string bench = "micro";
std::string db = "epic";
bool commutative_ops = false;
while ((retval = getopt_long(argc, argv, optstring, long_options, nullptr)) != -1)
{
switch (retval)
{
case 'b':
bench = std::string(optarg);
if (bench == "ycsba")
{
bench = "ycsb";
ycsb_config.txn_mix = {50, 50, 0, 0};
}
else if (bench == "ycsbb")
{
bench = "ycsb";
ycsb_config.txn_mix = {95, 5, 0, 0};
}
else if (bench == "ycsbc")
{
bench = "ycsb";
ycsb_config.txn_mix = {100, 0, 0, 0};
}
else if (bench == "ycsbf")
{
bench = "ycsb";
ycsb_config.txn_mix = {50, 0, 50, 0};
}
else if (bench == "micro")
{
// do nothing
}
else
{
throw std::runtime_error("Invalid benchmark name");
}
break;
case 'd':
db = std::string(optarg);
if (db != "epic" && db != "gacco")
{
throw std::runtime_error("Invalid database name");
}
break;
case 'w':
errno = 0;
break;
case 'a':
errno = 0;
ycsb_config.skew_factor = strtod(optarg, &end_char);
micro_config.skew_factor = strtod(optarg, &end_char);
if (errno != 0 || end_char == optarg || *end_char != '\0')
{
throw std::runtime_error("Invalid skew factor");
}
break;
case 'r':
if (std::string(optarg) == "true")
{
ycsb_config.full_record_read = true;
}
else if (std::string(optarg) == "false")
{
ycsb_config.full_record_read = false;
}
else
{
throw std::runtime_error("Invalid full record read");
}
break;
case 'c':
errno = 0;
ycsb_config.cpu_exec_num_threads = strtoul(optarg, &end_char, 0);
if (errno != 0 || end_char == optarg || *end_char != '\0')
{
throw std::runtime_error("Invalid number of CPU execution threads");
}
break;
case 'e':
errno = 0;
ycsb_config.epochs = strtoul(optarg, &end_char, 0);
micro_config.epochs = ycsb_config.epochs;
if (errno != 0 || end_char == optarg || *end_char != '\0')
{
throw std::runtime_error("Invalid number of epochs");
}
break;
case 's':
errno = 0;
ycsb_config.num_txns = strtoul(optarg, &end_char, 0);
micro_config.num_txns = ycsb_config.num_txns;
if (errno != 0 || end_char == optarg || *end_char != '\0')
{
throw std::runtime_error("Invalid number of transactions");
}
break;
case 'f':
if (std::string(optarg) == "true")
{
ycsb_config.split_field = true;
}
else if (std::string(optarg) == "false")
{
ycsb_config.split_field = false;
}
else
{
throw std::runtime_error("Invalid split fields");
}
break;
case 'm':
if (std::string(optarg) == "true")
{
commutative_ops = true;
}
else if (std::string(optarg) == "false")
{
commutative_ops = false;
}
else
{
throw std::runtime_error("Invalid commutative ops");
}
break;
case 'n':
errno = 0;
ycsb_config.num_records = strtoul(optarg, &end_char, 0);
micro_config.num_records = ycsb_config.num_records;
if (errno != 0 || end_char == optarg || *end_char != '\0')
{
throw std::runtime_error("Invalid number of records");
}
break;
case 'x':
if (std::string(optarg) == "cpu")
{
ycsb_config.execution_device = epic::DeviceType::CPU;
}
else if (std::string(optarg) == "gpu")
{
ycsb_config.execution_device = epic::DeviceType::GPU;
}
else
{
throw std::runtime_error("Invalid execution device");
}
break;
case 'p':
errno = 0;
micro_config.abort_percentage = strtoul(optarg, &end_char, 0);
if (errno != 0 || end_char == optarg || *end_char != '\0')
{
throw std::runtime_error("Invalid abort percentage");
}
break;
default:
throw std::runtime_error("Invalid option");
}
}
/* this is a hack to run gacco NewOrder without holding locks on warehouse... */
std::unique_ptr<epic::Benchmark> benchmark;
if (bench == "ycsb")
{
if (db == "epic")
{
benchmark = std::make_unique<epic::ycsb::YcsbBenchmark>(ycsb_config);
}
else if (db == "gacco")
{
benchmark = std::make_unique<gacco::ycsb::YcsbBenchmark>(ycsb_config);
}
else
{
throw std::runtime_error("Invalid database name");
}
} else if (bench == "micro")
{
if (db == "epic")
{
benchmark = std::make_unique<epic::micro::MicroBenchmark>(micro_config);
} else
{
throw std::runtime_error("Invalid database name for microbenchmark");
}
} else
{
throw std::runtime_error("Unknown workload");
}
benchmark->loadInitialData();
benchmark->generateTxns();
benchmark->runBenchmark();
return 0;
}