-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathglobals_t_impl.h
More file actions
107 lines (94 loc) · 2.92 KB
/
globals_t_impl.h
File metadata and controls
107 lines (94 loc) · 2.92 KB
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
//
// Created by Ravil Galiev on 27.07.2023.
//
#pragma once
#include <cstdint>
typedef int64_t test_type;
// #ifdef REDIS
// #define VALUE_TYPE test_type
// #define KEY_TO_VALUE(key) key
// #else
// #define VALUE_TYPE void *
// #define KEY_TO_VALUE(key) &key /* note: hack to turn a key into a pointer */
// #endif
//
// #define DS_ADAPTER_T ds_adapter<test_type, VALUE_TYPE, RECLAIM<>, ALLOC<>, POOL<> >
// #ifndef INSERT_FUNC
// #define INSERT_FUNC insertIfAbsent
// #endif
#include <chrono>
#include "workloads/bench_parameters.h"
#include "adapter.h"
#include "globals_t.h"
namespace microbench {
struct globals_t {
PAD;
// const
// void *const NO_VALUE;
VALUE_TYPE const NO_VALUE;
const test_type KEY_MIN; // must be smaller than any key that can be inserted/deleted
const test_type
KEY_MAX; // must be less than std::max(), because the snap collector needs a reserved key
// larger than this! (and larger than any key that can be inserted/deleted)
const int64_t PREFILL_INTERVAL_MILLIS;
PAD;
// write once
int64_t elapsedMillis;
int64_t curKeySum = 0;
int64_t curSize = 0;
std::chrono::time_point<std::chrono::high_resolution_clock> programExecutionStartTime;
std::chrono::time_point<std::chrono::high_resolution_clock> endTime;
PAD;
std::chrono::time_point<std::chrono::high_resolution_clock> startTime;
int64_t startClockTicks;
PAD;
int64_t elapsedMillisNapping;
PAD;
volatile test_type garbage; // used to prevent optimizing out some code
PAD;
DS_ADAPTER_T* dsAdapter; // the data structure
PAD;
workload::BenchParameters* benchParameters;
PAD;
Random64 rngs[MAX_THREADS_POW2]; // create per-thread random number generators (padded to avoid
// false sharing)
// PAD; // not needed because of padding at the end of rngs
volatile bool start;
PAD;
volatile bool done;
PAD;
volatile int running; // number of threads that are running
PAD;
volatile bool debug_print;
PAD;
globals_t(workload::BenchParameters* bench_parameters)
: NO_VALUE(NULL),
KEY_MIN(0) /*std::numeric_limits<test_type>::min()+1)*/
,
KEY_MAX(bench_parameters->range + 1),
PREFILL_INTERVAL_MILLIS(200),
benchParameters(bench_parameters) {
debug_print = 0;
srand(time(0));
for (int i = 0; i < MAX_THREADS_POW2; ++i) {
rngs[i].setSeed(rand());
}
start = false;
done = false;
running = 0;
dsAdapter = nullptr;
garbage = 0;
curKeySum = 0;
curSize = 0;
}
void enable_debug_print() {
debug_print = true;
}
void disable_debug_print() {
debug_print = false;
}
~globals_t() {
delete benchParameters;
}
};
} // namespace microbench